# [petsc-users] Applying Multi-Point-Constraints with SNES

Matthew Knepley knepley at gmail.com
Fri Jul 7 15:07:56 CDT 2023

```On Fri, Jul 7, 2023 at 3:59 PM Hongrui Yu <yuhongrui at utexas.edu> wrote:

> Thanks Matt. To clarify, were you referring to the following section in
> DMPlexCreateBoxMesh_Tensor_SFC_Periodicity_Private()?
>
>
>
>   PetscCall(DMPlexSetIsoperiodicFaceSF(dm, sfper));
>
>
>
>   PetscScalar t[4][4] = {{0}};
>
>   t[0][0]             = 1;
>
>   t[1][1]             = 1;
>
>   t[2][2]             = 1;
>
>   t[3][3]             = 1;
>
>   for (PetscInt i = 0; i < dim; i++)
>
>     if (periodicity[i] == DM_BOUNDARY_PERIODIC) t[i][3] = upper[i] -
> lower[i];
>
>   PetscCall(DMPlexSetIsoperiodicFaceTransform(dm, &t[0][0]));
>
>
>
> In my understanding, DMPlexSetIsoperiodicFaceSF() defines the points where
> the constrains exists. The constrains are specified in t matrix and set by
> calling DMPlexSetIsoperiodicFaceTransform(). Is this correct?
>

The t matrix is an affine transform to apply to the field before matching.
Here it is just the identity, which is what I think you want.

> Does constraints set by this also apply to non-displacement DoFs? Our
> application is of phase-field fracture in elasticity so we have a scalar
> DoF on each vertices in addition to displacement field. In other words, the
> section has two fields, where displacement field has 2 DoFs and phase-field
> has 1 DoF.
>

It should just work.

Thanks,

Matt

> Thanks,
>
> Hongrui
>
>
>
> *From:* Matthew Knepley <knepley at gmail.com>
> *Sent:* Thursday, July 6, 2023 3:34 PM
> *To:* Hongrui Yu <yuhongrui at utexas.edu>
> *Cc:* petsc-users at mcs.anl.gov
> *Subject:* Re: [petsc-users] Applying Multi-Point-Constraints with SNES
>
>
>
> On Thu, Jul 6, 2023 at 3:40 PM Hongrui Yu <yuhongrui at utexas.edu> wrote:
>
> Hello PETSc users,
>
>
>
> In our Finite Element application we would like to apply
> Multi-Point-Constraints to some vertices. In these Multi-Point-Constraints
> we force certain DoF in the following nodes to be the same as those in
> controlling nodes. We use DMPlex to store our mesh. I’m wondering what
> would be a good way to implement this together with SNES? Or is there an
> example that does similar thing?
>
>
>
> There is a simple thing that Jed implemented call "isoperiodicity" in
> plexsfc.c, and you can see
>
> him using it to define a periodic box in
>
>
>
>   DMPlexCreateBoxMesh_Tensor_SFC_Periodicity_Private()
>
>
>
> You could use exactly this to define an affine relation between two dofs.
>
>
>
> Currently both right-hand-side and solution vectors in out application are
> created using DMCreateGlobalVec(). And we tried (unsuccessfully) to modify
> solution within FormRHS or FormJacobian routines but the solution vector
> seems to be read-only (for good reason). Is there a way to tell SNES about
> these constraints? Or perhaps one can somehow create a vector with only a
> subset of the DoFs (the actual “unknowns”)?
>
>
>
> Doing it as above will eliminate the constrained unknowns from the SNES
> automatically, so this will not be a concern.
>
>
>
>   Thanks,
>
>
>
>      Matt
>
>
>
>
>
>
> Hongrui
>
>
>
>
>
>
> --
>
> 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/>
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their