← Back to team overview

dolfin team mailing list archive

Boundary conditions

 

I have added a first version of a new approach (according to previous
discussion) for specifying Dirichlet boundary conditions. Neumann and
other conditions are imposed weakly as before. Here's how it works:

  // Define boundary condition
  NewBoundaryCondition bc(g, mesh, sub_domains, 0);

  // Apply boundary condition
  bc.apply(A, b, form);

The boundary condition knows everything it needs to know. It knows the
function g that has the values, it knows the sub domains of the mesh
and it knows which sub domain (0 in this case) on which to apply the
boundary condition.

Then, one can just apply the boundary condition to one or more systems
(A, b).

The downside is that one needs to specify the sub domains. In the
Poisson demo, this is now done as follows:

  MeshFunction<unsigned int> sub_domains(mesh, 1);
  for (FacetIterator facet(mesh); !facet.end(); ++facet)
  {
    sub_domains(*facet) = 0;
    for (VertexIterator vertex(facet); !vertex.end(); ++vertex)
    {
      if ( vertex->x(0) > DOLFIN_EPS )
        sub_domains(*facet) = 1;
    }
  }

This creates a mesh function over the facets (dimension 1) and marks
everything at x = 0 as sub domain 0 and everything else as sub domain
0.

But we can easily create a simple wrapper for specifying sub domains:

   class SubDomain
   {
   public:

     virtual bool inside(real* x) = 0;

   };

The callback foo returns true when x is inside the sub domain.

Then one can create a boundary condition by

  NewBoundaryCondition bc(g, mesh, sub_domain);

Could this work?

/Anders