58
58
method(method), user_sub_domain(0)
60
60
// Initialize sub domain markers
61
initFromMesh(sub_domain);
63
63
//-----------------------------------------------------------------------------
64
64
DirichletBC::DirichletBC(Function& g,
96
96
sub_system(sub_system), method(method), user_sub_domain(0)
98
98
// Initialize sub domain markers
99
initFromMesh(sub_domain);
101
101
//-----------------------------------------------------------------------------
102
102
DirichletBC::~DirichletBC()
133
133
const GenericVector* x, const DofMap& dof_map, const ufc::form& form)
135
135
// FIXME: How do we reuse the dof map for u?
138
138
const uint N = dof_map.global_dimension();
139
139
if (N != A.size(0) || N != A.size(1))
140
140
error("Incorrect dimension of matrix for application of boundary conditions. Did you assemble it on a different mesh?");
141
141
if (N != b.size())
142
142
error("Incorrect dimension of matrix for application of boundary conditions. Did you assemble it on a different mesh?");
144
144
// Set message string
146
146
if (method == topological)
254
255
sub_domain.mark(*sub_domains, 0);
256
257
//-----------------------------------------------------------------------------
257
void DirichletBC::initFromMesh()
258
void DirichletBC::initFromMesh(uint sub_domain)
260
dolfin_assert(facets.size() == 0);
259
262
cout << "Creating sub domain markers for boundary condition." << endl;
262
265
Array<uint>* facet_cells = _mesh.data().array("boundary facet cells");
263
266
Array<uint>* facet_numbers = _mesh.data().array("boundary facet numbers");
276
279
dolfin_assert(size == facet_numbers->size());
277
280
dolfin_assert(size == indicators->size());
279
// Create mesh function for sub domain markers on facets
280
const uint dim = _mesh.topology().dim();
282
sub_domains = new MeshFunction<uint>(_mesh, dim - 1);
283
sub_domains_local = true;
285
// Compute the maximum boundary indicator
287
for (uint i = 0; i < size; i++)
288
maxid = std::max(maxid, (*indicators)[i]);
289
cout << "maxid = " << maxid << endl;
291
// Mark everything with the maximum value + 1
292
(*sub_domains) = maxid + 1;
294
// Mark facets according to data
282
// Build set of boundary facets
295
283
for (uint i = 0; i < size; i++)
297
// Get cell incident with facet
298
Cell cell(_mesh, (*facet_cells)[i]);
301
uint facet = cell.entities(dim - 1)[(*facet_numbers)[i]];
304
sub_domains->set(facet, (*indicators)[i]);
285
// Skip facets not on this boundary
286
if ((*indicators)[i] != sub_domain)
290
facets.push_back(std::pair<uint, uint>((*facet_cells)[i], (*facet_numbers)[i]));
307
293
//-----------------------------------------------------------------------------
380
366
//-----------------------------------------------------------------------------
381
367
void DirichletBC::computeBCPointwise(std::map<uint, real>& boundary_values,
383
BoundaryCondition::LocalData& data)
369
BoundaryCondition::LocalData& data)
385
UFCCell ufc_cell(cell);
371
dolfin_assert(user_sub_domain);
387
373
// Interpolate function on cell
374
UFCCell ufc_cell(cell);
388
375
g.interpolate(data.w, ufc_cell, *data.finite_element, cell);
390
377
// Tabulate dofs on cell, and their coordinates