← Back to team overview

dolfin team mailing list archive

Re: Boundary conditions work now

 

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





Follow ups

References