← Back to team overview

dolfin team mailing list archive

Re: Boundary conditions work now

 

It can't just now, but let's add it. As far as I can see, the only
thing we need to fix is add an argument to bc.apply().

FFC now treats vector-valued Lagrange elements as mixed elements, so
they are just tensor products of scalar Lagrange elements. (Note to
Rob: the vector-valued Lagrange elements in FIAT are no longer used in
FFC.) What one needs to do is to say that a condition should be set
for a certain sub system.

For example, if we have just a vector-valued Lagrange element with two
components, then you can either set a boundary condition for the whole
system (both components) or set boundary conditions for each sub
system (each one of the scalar components). We could add an extra
argument to bc.apply() for this:

  // Apply bc0 (which is a scalar boundary condition) to u0
  bc0.apply(A, b, form, 0);

  // Apply bc1 (which is a scalar boundary condition) to u1
  bc1.apply(A, b, form, 1);

  // Apply bc01 (which is a vector-valued boundary condition) to u
  bc.apply(A, b, form);

As another example, one can set boundary conditions for the scalar sub
system p or the vector-valued sub system u in Stokes.

So the boundary conditions themselves don't know anything about sub
systems or which components they correspond to (they are just a scalar
or vector-valued functions on a sub domain), but then these boundary
conditions can be applied to different parts of the system or to the
whole system.

Could this work?

/Anders


> >   bc.apply(A, b, form);


On Sat, Apr 14, 2007 at 09:39:50AM +0200, Garth N. Wells wrote:
> How can a Dirichlet boundary condition be applied to only one component 
> of a vector-valued function?
> 
> Garth
> 
> Anders Logg wrote:
> > Boundary conditions are now in place. Take a look and see if you like
> > it. If so, we can rename NewBoundaryCondition --> BoundaryCondition
> > and remove BoundaryValue (no longer needed).
> > 
> > The interface look as follows:
> > 
> >   // Define a function (the values of the boundary condition)
> >   class DirichletBC : public Function
> >   {
> >     real eval(const real* x)
> >     {
> >       return sin(x[0])*cos(x[1]);
> >     }
> >   };
> > 
> >   DirichletBC g;
> > 
> >   // Define a sub domain (where to put the boundary condition)
> >   class DirichletBoundary : public SubDomain
> >   {
> >     bool inside(const real* x, bool on_boundary)
> >     {
> >       return x[0] < DOLFIN_EPS && on_boundary;
> >     }
> >   };
> > 
> >   DirichleBoundary G;
> > 
> >   // Define the boundary condition (function + sub domain)
> >   NewBoundaryCondition bc(g, mesh, G);
> > 
> >   // Apply boundary condition to linear system
> >   bc.apply(A, b, form);
> > 
> > Note that I have also added an alternative interface for user-defined
> > functions that are scalar. The function above just returns the value.
> > The standard interface is 
> > 
> >   void eval(real* values, const real* x)
> >   {
> >     values[0] = ...
> >     values[1] = ...
> >     ...
> >   }
> > 
> > but for scalar functions, one can just return the value (or choose to
> > use the non-scalar version and set values[0]).
> > 
> > Also note that the boundary markers can still be defined by
> > MeshFunction over the facets, and a MeshFunction can also be read from
> > file. So one can have an XML mesh file and an XML mesh function file
> > that together define a mesh and its sub domains.
> > 
> > /Anders
> > _______________________________________________
> > DOLFIN-dev mailing list
> > DOLFIN-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/dolfin-dev
> > 
> 
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


References