# [petsc-users] How do constraint dofs work?

Matthew Knepley knepley at gmail.com
Sun Dec 6 19:02:27 CST 2020

```On Sun, Dec 6, 2020 at 1:46 PM Alexis Marboeuf <alexis.marboeuf at hotmail.fr>
wrote:

> Hello,
>
> I intend to contribute to the Petsc documentation, especially on PetscSF
> and PetscSection objects. I'm writing an example where I solve a linear
> elasticity problem in parallel on unstructured meshes. I discretize the
> system with a finite element method and P1 Lagrange base functions. I only
> use Petsc basics such as PetscSF, PetscSection, Mat, Vec and SNES objects
> and I need to implement Dirichlet and/or Neuman boundary conditions.
> PetscSectionSetConstraintDof and related routines allow to define which
> dofs are removed from the global system but are kept in local Vec. I don't
> how it works? In particular, do I have to manually add terms related to
> inhomogeneous Dirichlet boundary condition in the RHS? Am I missing
> something?
>

The way this mechanism is intended to work is to support removal of
constrained dofs from the global system. This means it solves for only
unconstrained dofs and no modification of the system is necessary. However,
you would be responsible for putting the correct boundary values into
any local vector you use. Note that this mechanism is really only effective
when you can constrain a dof itself, not a linear combination. For that, we
do something more involved.

Operationally, SetConstraintDof() keeps track of how many dofs are
constrained on each point. Then SetConstraintIndices() tells us which dofs
on that
point are constrained, where the indices are in [0, n) if there are n dofs
on that point. If you make a global Section, constrained dofs have negative
offsets,
just like ghost dofs.

Thanks,

Matt

> Regards,
> Alexis Marboeuf
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20201206/da33608c/attachment.html>
```