[petsc-users] Additiional DoF per cell
Noam T.
dontbugthedevs at proton.me
Tue May 5 08:06:09 CDT 2026
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!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. 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.
"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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260505/2a9680e2/attachment.html>
More information about the petsc-users
mailing list