<div style="font-family: Arial, sans-serif; font-size: 14px;">Moving on to the values of the closure.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Initially I create a vector for the DM with DMCreateLocal/GlobalVector, which is used for e.g. the solution. Following the example before, it will have size 8 (coordinates) + nc (for the p field).</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">I am getting a seemingly random order when I test with different values of nc. Say, I initialize the vector (VecSetValues) with the coordinates x_i, y_i . The rest nc components are set to zero. The closure returns:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><div><span>-- nc = 1</span></div><div><span>closure = y0 x1 y1 x2 y2 x3 y3 0 x0</span></div><div><br></div><div><span>-- nc = 3</span></div><div><span>closure = y1 x2 y2 x3 y3 0 0 0 x0 y0 x1</span></div><div><br><span></span></div><div><span>-- nc = 7 </span></div><div><span>closure = y3 0 0 0 0 0 0 0 x0 y0 x1 y1 x2 y2</span></div></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Looking at that output: </div><div style="font-family: Arial, sans-serif; font-size: 14px;">- The first value is always a y coordinate (second component of u field).</div><div style="font-family: Arial, sans-serif; font-size: 14px;">- The position of the nc = 0 components change (starting with nc = 8, all zero values come first, followed by the coordinates).</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Looking again at ex77.c (<span><a target="_blank" rel="noreferrer nofollow noopener" href="https://urldefense.us/v3/__https://petsc.org/release/src/snes/tutorials/ex77.c.html__;!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIvmj8bxC$">https://petsc.org/release/src/snes/tutorials/ex77.c.html</a></span>), it says the closure stacks up the fields, which aligns with the output above (all u values, then all p values), but which is the starting point seems arbitrary.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">The vector is initialized as [x0 y0 .... x3 y3 0 0 ... 0], which may not be correct to start with.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">I noticed I could instead use DMPlexVecGetClosureAtDepth( ..., depth = 0, ...) so that I only get the u field DoF. But I will need to deal with the p field values as well at some point.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Thanks,</div><div style="font-family: Arial, sans-serif; font-size: 14px;">Noam</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div class="protonmail_quote">
On Friday, May 8th, 2026 at 11:05 AM, Matthew Knepley <knepley@gmail.com> wrote:<br>
<blockquote class="protonmail_quote" type="cite">
<div dir="ltr"><div dir="ltr">On Fri, May 8, 2026 at 5:08 AM Noam T. <<a href="mailto:dontbugthedevs@proton.me" rel="noreferrer nofollow noopener">dontbugthedevs@proton.me</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px">On the plus side, using the flags you provided in the previous email </div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">-dm_plex_simplex 0 -mech_petscspace_degree 1 -pres_petscspace_degree 1
-pres_petscspace_poly_tensor 0 -pres_petscdualspace_lagrange_continuity 0</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">the output of -ds_view is identical to yours, so setting up the fields should be correct. </div><div style="font-family:Arial,sans-serif;font-size:14px">Thanks. I forgot about the flag "-[]_petscdualspace_lagrange_continuity 0" so as to have a discontinuous field. </div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">However, the closure size was still wrong. </div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">But, I figured out the reason: the manual set up of the section.</div><div style="font-family:Arial,sans-serif;font-size:14px">For the argument "numDof" in DMPlexCreateSection(), I was computing the number of DoF with PetscSectionGetDof() (which was fine until now, since there was a single field), instead of PetscSectionGetFieldDof().</div><div style="font-family:Arial,sans-serif;font-size:14px">So as you previously suggested<br><div style="background-color:rgb(255,255,255)"><br></div><blockquote type="cite"><div dir="ltr"><div><div>[...] It sounds like somehow you have a copy of your fields.</div></div></div></blockquote><div style="background-color:rgb(255,255,255)"><br></div><div style="background-color:rgb(255,255,255)">the number of DoF per field were indeed "doubled" with the sum of both fields.</div></div></blockquote><div><br></div><div>Excellent. Let me know if you have any more issues.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px">Thanks,</div><div style="font-family:Arial,sans-serif;font-size:14px">Noam</div><div style="font-family:Arial,sans-serif;font-size:14px"><br><div>
On Wednesday, May 6th, 2026 at 2:06 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer nofollow noopener">knepley@gmail.com</a>> wrote:<br>
<blockquote type="cite">
<div dir="ltr">Okay, this is a problem with specifying the space I believe. You want a discontinuous space for pressure.<div><br></div><div>Here is what I get<div><br></div><div>Discrete System with 2 fields<br> cell total dim 11 total comp 3<br> Field Q1 FEM 2 components (implicit) (Nq 4 Nqc 1) 1-jet<br> PetscFE Object: Q1 (mech_) 1 MPI process<br> type: vector<br> Vector Finite Element in 2 dimensions with 2 components<br> PetscSpace Object: Q1 (mech_) 1 MPI process<br> type: sum<br> Space in 2 variables with 2 components, size 8<br> Sum space of 2 concatenated subspaces (all identical)<br> PetscSpace Object: Q1 (mech_sumcomp_) 1 MPI process<br> type: tensor<br> Space in 2 variables with 1 components, size 4<br> Tensor space of 2 subspaces (all identical)<br> PetscSpace Object: sum component tensor component (mech_sumcomp_tensorcomp_) 1 MPI process<br> type: poly<br> Space in 1 variables with 1 components, size 2<br> Polynomial space of degree 1<br> PetscDualSpace Object: Q1 (mech_) 1 MPI process<br> type: sum<br> Dual space with 2 components, size 8<br> Sum dual space of 2 concatenated subspaces (all identical)<br> PetscDualSpace Object: Q1 1 MPI process<br> type: lagrange<br> Dual space with 1 components, size 4<br> Continuous tensor Lagrange dual space<br> Quadrature on a quadrilateral of order 3 on 4 points (dim 2)<br> Field Q1 FEM 1 component (implicit) (Nq 4 Nqc 1) 1-jet<br> PetscFE Object: Q1 (pres_) 1 MPI process<br> type: basic<br> Basic Finite Element in 2 dimensions with 1 components<br> PetscSpace Object: Q1 (pres_) 1 MPI process<br> type: poly<br> Space in 2 variables with 1 components, size 3<br> Polynomial space of degree 1<br> PetscDualSpace Object: Q1 (pres_) 1 MPI process<br> type: lagrange<br> Dual space with 1 components, size 3<br> Discontinuous Lagrange dual space<br> Quadrature on a quadrilateral of order 3 on 4 points (dim 2)<br> Weak Form System with 2 fields<br></div><div><br></div><div>I have attached the code I used.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 6, 2026 at 9:32 AM Noam T. <<a href="mailto:dontbugthedevs@proton.me" rel="noreferrer nofollow noopener" target="_blank">dontbugthedevs@proton.me</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><blockquote type="cite"><div dir="ltr"><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><span> Field p FEM 3 components (implicit) (Nq 4 Nqc 1) 1-jet</span></div></blockquote><div><br></div><div>1. Why does pressure have 3 components in 2D?</div></div></div></blockquote><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">I used nc = 3 when calling PetscFECreateDefault() for the pressure field. Confusion between wanting 3 addditional DoF and components.</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">With nc = 1 the closure size is 18 instead.</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><blockquote type="cite"><div dir="ltr"><div><div> </div><div>2. Did you look at the incompressible example SNES ex69? It sets up this exact element.</div></div></div></blockquote><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">I changed some of my code following the example and got rid of some errors. But I'll have a more thorough look again.</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><blockquote type="cite"><div dir="ltr"><div><div>3. Please send me that code that sets up your DM. It sounds like somehow you have a copy of your fields.</div><div><br></div><div> Thanks,</div></div></div></blockquote><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">For reference, -ds_view with only one (displacements) fields shows:</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">---</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span>Discrete System with 1 fields</span><div><span> cell total dim 8 total comp 2</span></div><div><span> Field u FEM 2 components (implicit) (Nq 4 Nqc 1) 1-jet</span></div><div><span> PetscFE Object: u (disp_) 1 MPI process</span></div><div><span> type: vector</span></div><div><span> Vector Finite Element in 2 dimensions with 2 components</span></div><div><span> PetscSpace Object: Q1 (disp_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Space in 2 variables with 2 components, size 8</span></div><div><span> Sum space of 2 concatenated subspaces (all identical)</span></div><div><span> PetscSpace Object: Q1 (disp_sumcomp_) 1 MPI process</span></div><div><span> type: tensor</span></div><div><span> Space in 2 variables with 1 components, size 4</span></div><div><span> Tensor space of 2 subspaces (all identical)</span></div><div><span> PetscSpace Object: sum component tensor component (disp_sumcomp_tensorcomp_) 1 MPI process</span></div><div><span> type: poly</span></div><div><span> Space in 1 variables with 1 components, size 2</span></div><div><span> Polynomial space of degree 1</span></div><div><span> PetscDualSpace Object: Q1 (disp_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Dual space with 2 components, size 8</span></div><div><span> Sum dual space of 2 concatenated subspaces (all identical)</span></div><div><span> PetscDualSpace Object: Q1 1 MPI process</span></div><div><span> type: lagrange</span></div><div><span> Dual space with 1 components, size 4</span></div><div><span> Continuous tensor Lagrange dual space</span></div><div><span> Quadrature on a quadrilateral of order 3 on 4 points (dim 2)</span></div><div><span> Weak Form System with 1 fields</span></div><span></span>---</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">and -dm_view</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">---</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span>DM Object: 1 MPI process</span><div><span> type: plex</span></div><div><span>DM_0x55c117db1b00_2 in 2 dimensions:</span></div><div><span> Number of 0-cells per rank: 4</span></div><div><span> Number of 1-cells per rank: 4</span></div><div><span> Number of 2-cells per rank: 1</span></div><div><span>Labels:</span></div><div><span> celltype: 3 strata with value/size (0 (4), 1 (4), 4 (1))</span></div><div><span> depth: 3 strata with value/size (0 (4), 1 (4), 2 (1))</span></div><div><span> Cell Sets: 1 strata with value/size (1 (1))</span></div><div><span> surf: 1 strata with value/size (1 (1))</span></div><div><span> Face Sets: 2 strata with value/size (2 (1), 3 (1))</span></div><div><span> edge_right: 1 strata with value/size (3 (1))</span></div><div><span> edge_left: 1 strata with value/size (2 (1))</span></div><div><span> Vertex Sets: 4 strata with value/size (4 (1), 5 (1), 6 (1), 7 (1))</span></div><div><span> P1: 1 strata with value/size (4 (1))</span></div><div><span> P2: 1 strata with value/size (5 (1))</span></div><div><span> P3: 1 strata with value/size (6 (1))</span></div><div><span> P4: 1 strata with value/size (7 (1))</span></div><div><span>Field u:</span></div><div><span> adjacency FEM</span></div><div><span>/// With the second field, the two lines below are added </span></div><div><span><span>Field p:</span><div><span> adjacency FEM</span></div></span></div></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">---</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">DM set up</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span> DM :: dm_mesh</span><div><span> PetscFE :: u_FE, p_FE</span></div><div><span> PetscInt :: dim, dim_u_FE, tdim</span></div><div><span> PetscDS :: dm_ds</span></div><div><br></div><div><br></div><div><span> DMCreate(PETSC_COMM_WORLD, dm_mesh)</span></div><div><span> DMSetType(dm_mesh, DMPLEX)</span></div><div><span> DMGetDimension(dm_mesh, dim) // dim = 2</span></div><div><span> DMSetFromOptions(dm_mesh) // this was called twice by mistake, now removed; no changes that I can see</span></div><div><br></div><div><span> -- using flags</span></div><div><br></div><div><span> -dm_plex_filename QUAD1.msh</span></div><div><span> -dm_plex_interpolate 1</span></div><div><span> -dm_plex_gmsh_use_generic</span></div><div><span> -dm_plex_gmsh_use_regions</span></div><div><span> -dm_plex_gmsh_multiple_tags</span></div><div><span> -dm_plex_gmsh_mark_vertices</span></div><div><br></div><div><span> -- some operations with labels</span></div><div><br></div><div><span> // u field</span></div><div><span> PetscFECreateDefault(PETSC_COMM_SELF, dim, dim, PETSC_FALSE, "mech_", PETSC_DETERMINE, u_FE)</span></div><div><span> PetscFEGetDimension(u_FE, dim_u_FE) // dim_u_FE = 8</span></div><div><span> DMAddField(dm_mesh, NULL, (PetscObject)u_FE)</span></div><div><br></div><div><span> // p field</span></div><div><span> PetscFECreateDefault(PETSC_COMM_SELF, dim , 1, PETSC_FALSE, "pres_", PETSC_DETERMINE, p_FE)</span></div><div><span> PetscFEGetDimension(p_FE, dim_p_FE) // dim_p_FE = 1</span></div><div><span> DMAddField(dm_mesh, NULL, (PetscObject)p_FE)</span></div><div><br></div><div><span> DMCreateDS(dm_mesh)</span></div><div><span> DMGetDS(dm_mesh, dm_DS)</span></div><div><span> PetscDSGetTotalDimension(dm_DS, tdim) // tdim </span></div><div><br></div><div><span> with flags</span></div><div><br></div><div><span> -disp_petscdualspace_lagrange_node_type equispaced </span></div><div><span> -disp_petscdualspace_lagrange_node_endpoints 1</span></div><span></span><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">I believe these are all the DM related calls.</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Thanks,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Noam</div><div style="font-family:Arial,sans-serif;font-size:14px"><br><div>
On Wednesday, May 6th, 2026 at 11:39 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" rel="noreferrer nofollow noopener" target="_blank">knepley@gmail.com</a>> wrote:<br>
<blockquote type="cite">
<div dir="ltr"><div dir="ltr">On Wed, May 6, 2026 at 6:56 AM Noam T. <<a href="mailto:dontbugthedevs@proton.me" rel="noreferrer nofollow noopener" target="_blank">dontbugthedevs@proton.me</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px"><div><div><div>Hello,</div><div><br></div><blockquote type="cite"><div dir="ltr"><div><span>That is wrong. Are you sure about 22?</span></div></div></blockquote></div></div><br></div><div style="font-family:Arial,sans-serif;font-size:14px">That's what I get, from the argument "csize" in DMPlexGetVecClosure(). </div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">Here's the output of PetscDSView:</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px"></div><span></span><span>Discrete System with 2 fields</span><div><span> cell total dim 11 total comp 5</span></div><div><span> Field u FEM 2 components (implicit) (Nq 4 Nqc 1) 1-jet</span></div><div><span> PetscFE Object: u (mech_) 1 MPI process</span></div><div><span> type: vector</span></div><div><span> Vector Finite Element in 2 dimensions with 2 components</span></div><div><span> PetscSpace Object: Q1 (mech_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Space in 2 variables with 2 components, size 8</span></div><div><span> Sum space of 2 concatenated subspaces (all identical)</span></div><div><span> PetscSpace Object: Q1 (mech_sumcomp_) 1 MPI process</span></div><div><span> type: tensor</span></div><div><span> Space in 2 variables with 1 components, size 4</span></div><div><span> Tensor space of 2 subspaces (all identical)</span></div><div><span> PetscSpace Object: sum component tensor component (mech_sumcomp_tensorcomp_) 1 MPI process</span></div><div><span> type: poly</span></div><div><span> Space in 1 variables with 1 components, size 2</span></div><div><span> Polynomial space of degree 1</span></div><div><span> PetscDualSpace Object: Q1 (mech_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Dual space with 2 components, size 8</span></div><div><span> Sum dual space of 2 concatenated subspaces (all identical)</span></div><div><span> PetscDualSpace Object: Q1 1 MPI process</span></div><div><span> type: lagrange</span></div><div><span> Dual space with 1 components, size 4</span></div><div><span> Continuous tensor Lagrange dual space</span></div><div><span> Quadrature on a quadrilateral of order 3 on 4 points (dim 2)</span></div><div><span> Field p FEM 3 components (implicit) (Nq 4 Nqc 1) 1-jet</span></div></blockquote><div><br></div><div>1. Why does pressure have 3 components in 2D?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><span> PetscFE Object: p (pres_) 1 MPI process</span></div><div><span> type: vector</span></div><div><span> Vector Finite Element in 2 dimensions with 3 components</span></div><div><span> PetscSpace Object: Q0 (pres_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Space in 2 variables with 3 components, size 3</span></div><div><span> Sum space of 3 concatenated subspaces (all identical)</span></div><div><span> PetscSpace Object: Q0 (pres_sumcomp_) 1 MPI process</span></div><div><span> type: tensor</span></div><div><span> Space in 2 variables with 1 components, size 1</span></div><div><span> Tensor space of 2 subspaces (all identical)</span></div><div><span> PetscSpace Object: sum component tensor component (pres_sumcomp_tensorcomp_) 1 MPI process</span></div><div><span> type: poly</span></div><div><span> Space in 1 variables with 1 components, size 1</span></div><div><span> Polynomial space of degree 0</span></div><div><span> PetscDualSpace Object: Q0 (pres_) 1 MPI process</span></div><div><span> type: sum</span></div><div><span> Dual space with 3 components, size 3</span></div><div><span> Sum dual space of 3 concatenated subspaces (all identical)</span></div><div><span> PetscDualSpace Object: Q0 1 MPI process</span></div><div><span> type: lagrange</span></div><div><span> Dual space with 1 components, size 1</span></div><div><span> Discontinuous tensor Lagrange dual space</span></div><div><span> Quadrature on a quadrilateral of order 3 on 4 points (dim 2)</span></div><div><span> Weak Form System with 2 fields</span></div><span></span><div><span></span></div><span></span><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">using as the second field (dim = 2, nc = 3, prefix = "pres") and setting the FE object name to "p".</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">The entry "cell total dim 10" agrees with the output of PetscFEGetTotalDimension(); "comp = 5" I assume is 2 (u) + 3 (p)</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">However, the closure of a Vec is still 22.</div></blockquote><div><br></div><div>2. Did you look at the incompressible example SNES ex69? It sets up this exact element.</div><div><br></div><div>3. Please send me that code that sets up your DM. It sounds like somehow you have a copy of your fields.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px"><div>
On Tuesday, May 5th, 2026 at 1:58 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" rel="noreferrer nofollow noopener" target="_blank">knepley@gmail.com</a>> wrote:<br>
<blockquote type="cite">
<div dir="ltr"><div dir="ltr">On Tue, May 5, 2026 at 9:06 AM Noam T. via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" rel="noreferrer nofollow noopener" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hello,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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... </div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Looking at example 77 (<span><a rel="noreferrer nofollow noopener" href="https://urldefense.us/v3/__https://petsc.org/release/src/snes/tutorials/ex77.c.html__;!!G_uCfscf7eWS!aZNOxZZeoHYqe6lRZV0wHMVVTu3YIEfc1Sr-dca7xiGVfG3enULFD4_g6_fxWIa7A_Cu9LcXU-MuxRj4sOwDRyWqvsdGdrEd$" style="word-break:break-word" target="_blank">https://petsc.org/release/src/snes/tutorials/ex77.c.html</a></span>) 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.</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Then add the new field:</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">PetscFECreateDefault(..., nc = 3, ..., p_FE) /* not sure about the value of nc here */</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">DMAddField(dm, ..., p_FE) </div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">The total dimension, from <span>PetscDSGetTotalDimension</span>(), is now 11 (8 + 3). This results in a closure of size 22.</div></blockquote><div><br></div><div>That is wrong. Are you sure about 22?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"> 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 </div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"> [K_uu, K_up | K_pu, K_pp] { u | p } = RHS</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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. </div></blockquote><div><br></div><div>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</div><div><br></div><div> <a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex69.c?ref_type=heads*L3454__;Iw!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIg7lpe7Y$" style="word-break:break-word" rel="noreferrer nofollow noopener" target="_blank">https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex69.c?ref_type=heads#L3454</a></div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">"point X has a number of DoF not divisible by 2 field components"</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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)?</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Thank you,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Noam.</div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIvxj9Rqc$" style="word-break:break-word" rel="noreferrer nofollow noopener" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote><br>
</div></div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIvxj9Rqc$" style="word-break:break-word" rel="noreferrer nofollow noopener" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote><br>
</div></div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIvxj9Rqc$" style="word-break:break-word" rel="noreferrer nofollow noopener" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>
</blockquote><br>
</div></div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZJz_pZR7M_mMi6gIDNMkNQy_6DO0K3sPQyCW-lCG3GWkYxEDauwvsaPpgiykvB00ywn3uvdURZsfZd4cNU2ZdMtLIvxj9Rqc$" target="_blank" style="word-break: break-word;" rel="noreferrer nofollow noopener">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote><br>
</div>