[petsc-users] Additiional DoF per cell
Noam T.
dontbugthedevs at proton.me
Wed May 6 05:56:05 CDT 2026
Hello,
> That is wrong. Are you sure about 22?
That's what I get, from the argument "csize" in DMPlexGetVecClosure().
Here's the output of PetscDSView:
Discrete System with 2 fields
cell total dim 11 total comp 5
Field u FEM 2 components (implicit) (Nq 4 Nqc 1) 1-jet
PetscFE Object: u (mech_) 1 MPI process
type: vector
Vector Finite Element in 2 dimensions with 2 components
PetscSpace Object: Q1 (mech_) 1 MPI process
type: sum
Space in 2 variables with 2 components, size 8
Sum space of 2 concatenated subspaces (all identical)
PetscSpace Object: Q1 (mech_sumcomp_) 1 MPI process
type: tensor
Space in 2 variables with 1 components, size 4
Tensor space of 2 subspaces (all identical)
PetscSpace Object: sum component tensor component (mech_sumcomp_tensorcomp_) 1 MPI process
type: poly
Space in 1 variables with 1 components, size 2
Polynomial space of degree 1
PetscDualSpace Object: Q1 (mech_) 1 MPI process
type: sum
Dual space with 2 components, size 8
Sum dual space of 2 concatenated subspaces (all identical)
PetscDualSpace Object: Q1 1 MPI process
type: lagrange
Dual space with 1 components, size 4
Continuous tensor Lagrange dual space
Quadrature on a quadrilateral of order 3 on 4 points (dim 2)
Field p FEM 3 components (implicit) (Nq 4 Nqc 1) 1-jet
PetscFE Object: p (pres_) 1 MPI process
type: vector
Vector Finite Element in 2 dimensions with 3 components
PetscSpace Object: Q0 (pres_) 1 MPI process
type: sum
Space in 2 variables with 3 components, size 3
Sum space of 3 concatenated subspaces (all identical)
PetscSpace Object: Q0 (pres_sumcomp_) 1 MPI process
type: tensor
Space in 2 variables with 1 components, size 1
Tensor space of 2 subspaces (all identical)
PetscSpace Object: sum component tensor component (pres_sumcomp_tensorcomp_) 1 MPI process
type: poly
Space in 1 variables with 1 components, size 1
Polynomial space of degree 0
PetscDualSpace Object: Q0 (pres_) 1 MPI process
type: sum
Dual space with 3 components, size 3
Sum dual space of 3 concatenated subspaces (all identical)
PetscDualSpace Object: Q0 1 MPI process
type: lagrange
Dual space with 1 components, size 1
Discontinuous tensor Lagrange dual space
Quadrature on a quadrilateral of order 3 on 4 points (dim 2)
Weak Form System with 2 fields
using as the second field (dim = 2, nc = 3, prefix = "pres") and setting the FE object name to "p".
The entry "cell total dim 10" agrees with the output of PetscFEGetTotalDimension(); "comp = 5" I assume is 2 (u) + 3 (p)
However, the closure of a Vec is still 22.
On Tuesday, May 5th, 2026 at 1:58 PM, Matthew Knepley <knepley at gmail.com> wrote:
> 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*5D(https:/*urldefense.us/v3/__https:/*petsc.org/release/src/snes/tutorials/ex77.c.html__;!!G_uCfscf7eWS!aZNOxZZeoHYqe6lRZV0wHMVVTu3YIEfc1Sr-dca7xiGVfG3enULFD4_g6_fxWIa7A_Cu9LcXU-MuxRj4sOwDRyWqvsdGdrEd$)__;JS8v!!G_uCfscf7eWS!e56d5TY3E06BjaC77FED7jTCooWx_yV4rzNMykCHBix2ArsRqkepXOSXKwSsWnQUWVeiX4KtVgIMFD4ie8w-ZTbGcPkTPPXu$ ) 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!e56d5TY3E06BjaC77FED7jTCooWx_yV4rzNMykCHBix2ArsRqkepXOSXKwSsWnQUWVeiX4KtVgIMFD4ie8w-ZTbGcNvtZhBB$
>
> 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/*5D(http:/*www.cse.buffalo.edu/*knepley/)__;fiUvfg!!G_uCfscf7eWS!e56d5TY3E06BjaC77FED7jTCooWx_yV4rzNMykCHBix2ArsRqkepXOSXKwSsWnQUWVeiX4KtVgIMFD4ie8w-ZTbGcKCEU3eo$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260506/1ee9a4a7/attachment.html>
More information about the petsc-users
mailing list