tag-fem:
$ \newcommand{\cross}{\times} \newcommand{\inner}{\cdot} \newcommand{\div}{\nabla\cdot} \newcommand{\curl}{\nabla\times} \newcommand{\grad}{\nabla} \newcommand{\ddx}[1]{\frac{d#1}{dx}} \newcommand{\abs}[1]{|#1|} \newcommand{\dO}{{\partial\Omega}} $
MFEM supports boundary conditions of mixed type through the definition of boundary attributes on the mesh. A boundary attribute is a positive integer assigned to each boundary element of the mesh. Since each boundary element can have only one attribute number the boundary attributes split the boundary into a group of disjoint sets. MFEM allows the user to define boundary conditions on a subset of boundary attributes.
Typically mixed boundary conditions are imposed on disjoint portions of the boundary defined as:
| Symbol | Description |
|---|---|
| Boundary of the Domain ( |
|
| Dirichlet Boundary | |
| Neumann Boundary | |
| Robin Boundary | |
| Natural Boundary |
Where we assume
// Assume we start with an array containing boundary attribute numbers
// stored in bdr_attr.
//
// Prepare a marker array from a set of attributes
Array<int> bdr_marker(pmesh.bdr_attributes.Max());
bdr_marker = 0;
for (int i=0; i<bdr_attr.Size(); i++)
{
bdr_marker[bdr_attr[i]-1] = 1;
}Separate marker arrays of this type can be prepared for the Dirichlet,
Neumann, and Robin portions of the boundary. It is left to the user
to ensure that
In continuous formulations essential boundary conditions are set by
modifying the linear system to require the degrees of freedom on the
boundary to obtain specific values. This limits the types of
constraints that can be imposed on fields. For example,
| Space | Essential BC |
|---|---|
| H1 |
|
| H1$^d$ |
|
| ND |
|
| RT |
|
MFEM provides a convenience method, called FormLinearSystem, on the
[Par]BilinearForm class which can prepare a linear system with these
essential constraints.
// Set the Dirichlet values in the solution vector
ParGridFunction u(&fespace);
u = 0.0;
u.ProjectBdrCoefficient(dbcCoef, dbc_marker);
// Prepare the source term in the right-hand-side
ParLinearForm b(&fespace);
b.AddDomainIntegrator(new DomainLFIntegrator(rhsCoef));
b.Assemble();
// Prepare the bilinear form
ParBilinearForm a(&fespace);
a.AddDomainIntegrator(new DiffusionIntegrator(matCoef));
a.Assemble();
// Determine the essential degrees of freedom corresponding to the set of
// boundary attributes marked in dbc_marker
Array<int> ess_tdof_list(0);
fespace.GetEssentialTrueDofs(dbc_marker, ess_tdof_list);
// Prepare the linear system with enforcement of the essential boundary
// conditions
OperatorPtr A;
Vector B, X;
a.FormLinearSystem(ess_tdof_list, u, b, A, X, B);The so called "Natural Boundary Conditions" arise whenever weak derivatives occur in a PDE (see below for more on weak derivatives). Weak derivatives must be handled using integration by parts which introduces a boundary integral. If this boundary integral is ignored, its value is implicitly set to zero which creates an implicit constraint on the solution called a "natural boundary condition".
| Continuous Operator | Weak Operator | Natural BC |
|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
No additional implementation is necessary to impose natural boundary conditions. Any portion of the boundary where a Dirichlet, Neumann, or Robin boundary condition has not been applied will receive a natural boundary condition by default.
Neumann boundary conditions are closely related to natural boundary conditions. Rather than ignoring the boundary integral we integrate a known function on the boundary which approximates the desired value of the boundary condition (often a involving a derivative of the field). The following table shows a variety of common operators and their related Neumann boundary condition.
| Operator | Continuous Operator | Neumann BC |
|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
To impose these boundary conditions in MFEM simply modify the
right-hand side of your linear system by adding the appropriate
boundary integral of either BoundaryLFIntegrator
with an appropriate coefficient for [Par]LinearForm object.
Neumann boundary conditions can be added to the above example code by adding the following line before the call to b.Assemble().
// Add Neumann BCs n.(matCoef Grad u) = nbcCoef on the boundary marked in
// the nbc_marker array.
b.AddBoundaryIntegrator(new BoundaryLFIntegrator(nbcCoef), nbc_marker);For H(Curl) fields this can be accomplished by adding the
VectorFEBoundaryTangentLFIntegrator with an appropriate vector
coefficient for [Par]LinearForm object. And
finally, for H(Div) fields this can be accomplished by adding the
VectorFEBoundaryFluxLFIntegrator with an appropriate scalar
coefficient for [Par]LinearForm
object. Other integrators may be appropriate if it is desirable to
express the functions
Robin boundary conditions typically involve a linear function of the field and its normal derivative. As such they also arise from weak derivatives and the boundary integrals they introduce to the system of equations. Typical forms of the Robin boundary condition include the following.
| Operator | Continuous Operator | Robin BC |
|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
Robin boundary conditions are applied in the same manner as Neumann
boundary conditions except that one must also add a boundary integral
to the [Par]BilinearForm object to account for the term involving
MassIntegrator with an appropriate scalar coefficient for
The implementation of a Robin boundary condition requires precisely
the same change to the right-hand-side as the Neumann boundary
condition as well as a new term in the bilinear form before a.Assemble():
// Add Robin BCs n.(matCoef Grad u) + rbcACoef u = rbcBCoef on the boundary
// marked in the rbc_marker array.
b.AddBoundaryIntegrator(new BoundaryLFIntegrator(rbcBCoef), rbc_marker);
...
// Add Robin BCs n.(matCoef grad u) + rbcACoef u = rbcBCoef on the boundary
// marked in the rbc_marker array.
a.AddBoundaryIntegrator(new MassIntegrator(rbcACoef), rbc_marker);In the Discontinuous Galerkin (DG) formulation the
Natural,
Neumann, and Robin
can be implemented in a similar manner as in the continuous case
(adding the appropriate LinearFormIntegrator as a boundary face integrator
instead of a boundary integrator and, for Robin conditions, using
BoundaryMassIntegrator instead of MassIntegrator for the
// Add the desired value for the Dirichlet constraint on the boundary
// marked in the dbc_marker array.
b.AddBdrFaceIntegrator(new DGDirichletLFIntegrator(dbcCoef, matCoef, sigma, kappa),
dbc_marker);
...
// Add the n.Grad(u) boundary integral on the Dirichlet portion of the
// boundary marked in the dbc_marker array.
a.AddBdrFaceIntegrator(new DGDiffusionIntegrator(matCoef, sigma, kappa),
dbc_marker);Where sigma and kappa are parameters controlling the symmetry and
interior penalty used in the DG diffusion formulation. These two
integrators work together to balance the natural boundary condition
associated with the DiffusionIntegrator and to penalize solutions
which differ from the desired Dirichlet value near the boundary.
Similar pairs of integrators can be implemented to accommodate
other PDEs.