[petsc-users] Additiional DoF per cell
Matthew Knepley
knepley at gmail.com
Tue May 5 08:57:46 CDT 2026
On Tue, May 5, 2026 at 9:06 AM Noam T. via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Hello,
>
> I am trying to work with a "mixed" FE discretization, where besides the
> usual displacements DoF in nodes, there is an additional field (e.g.
> pressure) that is also part of the system. This additional field has a
> certain number of additional dof : p0, p1, p2...
>
> Looking at example 77 (
> https://urldefense.us/v3/__https://petsc.org/release/src/snes/tutorials/ex77.c.html__;!!G_uCfscf7eWS!d2oAkBYY7K4cid5hk6pHYh2SJmG3IV32CRLu9ioTzh_Fod3pljEWEAFr55I2vDgRnMxVpuyJvyvod7ZOJWk1$
> <https://urldefense.us/v3/__https://petsc.org/release/src/snes/tutorials/ex77.c.html__;!!G_uCfscf7eWS!aZNOxZZeoHYqe6lRZV0wHMVVTu3YIEfc1Sr-dca7xiGVfG3enULFD4_g6_fxWIa7A_Cu9LcXU-MuxRj4sOwDRyWqvsdGdrEd$>)
> this seems to be handled with an additional field, added to the DM. I've
> tried so, but then I am getting from the DM arrays whose size/contents are
> not what I expected.
>
> For example, a four-noded Q1 element (PetscFE created with a 2x2 Gauss
> rule for quadrature), with just one field, a call to DMPlexGetVecClosure()
> gives me an array with 8 entries (say, the coordinates of the initial
> mesh): x = x0, y0, .... x3, y3
>
> Then add the new field:
>
> PetscFECreateDefault(..., nc = 3, ..., p_FE) /* not sure about the value
> of nc here */
> DMAddField(dm, ..., p_FE)
>
> The total dimension, from PetscDSGetTotalDimension(), is now 11 (8 + 3).
> This results in a closure of size 22.
>
That is wrong. Are you sure about 22?
> However, what I am looking for is a closure of size 8 + 3 i.e. the
> original 8 DoF at the nodes, plus exactly 3 DoF (for the cell, so to speak)
> p0, p1, p2, so that in a system with "block" matrices of the form
>
> [K_uu, K_up | K_pu, K_pp] { u | p } = RHS
>
> the unknowns {p} has size 3 per cell. Is this possible? I tried some
> combinations of dim / nc for the new PetscFE, but when creating the DM
> section I get errors e.g.
>
This is what you should get. I definitely have examples that do this. For
example, here is Q1-P0 (I think that is what you are suggesting) for
incompressible Stokes
https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex69.c?ref_type=heads*L3454__;Iw!!G_uCfscf7eWS!d2oAkBYY7K4cid5hk6pHYh2SJmG3IV32CRLu9ioTzh_Fod3pljEWEAFr55I2vDgRnMxVpuyJvyvod2tCkJS0$
Thanks,
Matt
> "point X has a number of DoF not divisible by 2 field components"
>
> Is this a hint that I should have 3 x dim new DoF, and simply not deal
> with entries that I don't need? Or I am not setting up the section properly
> (works with just one field)?
>
> Thank you,
> Noam.
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!d2oAkBYY7K4cid5hk6pHYh2SJmG3IV32CRLu9ioTzh_Fod3pljEWEAFr55I2vDgRnMxVpuyJvyvodxncmM78$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!d2oAkBYY7K4cid5hk6pHYh2SJmG3IV32CRLu9ioTzh_Fod3pljEWEAFr55I2vDgRnMxVpuyJvyvod4g01US8$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260505/1b77be41/attachment.html>
More information about the petsc-users
mailing list