<div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Jun 17, 2025 at 12:43 PM Noam T. <<a href="mailto:dontbugthedevs@proton.me" 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">Thank you. For now, I am dealing with vertices only.</div><div style="font-family:Arial,sans-serif;font-size:14px"><br>Perhaps I did not explain myself properly, or I misunderstood your response.</div><div style="font-family:Arial,sans-serif;font-size:14px">What I meant to say is, given an element of order higher than one, the connectivity matrix I obtain this way only contains as many entries as the first order element: 3 for a triangle, 4 for a tetrahedron, etc.</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 the closure of any cell in the mesh, this is also the case.However, the nodes are definitely present; e.g. from</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px"><span>DMPlexGetCellCoordinates</span>(dm, cell, NULL, nc, NULL, NULL)</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">nc returns the expected value (12 for a 2nd order 6-node planar triangle, 30 for a 2nd order 10-node tetrahedron, etc).</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">The question is, are the indices of these extra nodes obtainable in a similar way as with the code shared before? So that one can have e.g. [0, 1, 2, 3, 4, 5] for a second order triangle, not just [0, 1, 2].</div></blockquote><div><br></div><div>I am having a hard time understanding what you are after. I think this is because many FEM approaches confuse topology with analysis.</div><div><br></div><div>The Plex stores topology, and you can retrieve adjacencies between any two mesh points.</div><div><br></div><div>The PetscSection maps mesh points (cells, faces, edges , vertices) to sets of dofs. This is how higher order elements are implemented. Thus, we do not have to change topology to get different function spaces.</div><div><br></div><div>The intended interface is for you to call DMPlexVecGetClosure() to get the closure of a cell (or face, or edge). You can also call DMPlexGetClosureIndices(), but index wrangling is what I intended to eliminate.</div><div><br></div><div>What exactly are you looking for here?</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">Thank you.</div><div style="font-family:Arial,sans-serif;font-size:14px">Noam<br></div><div>
On Friday, June 13th, 2025 at 3:05 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
<blockquote type="cite">
<div dir="ltr"><div dir="ltr">On Thu, Jun 12, 2025 at 4:26 PM 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 style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><br></div><div>Thank you for the code; it provides exactly what I was looking for.</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)">Following up on this matter, does this method not work for higher order elements? For example, using an 8-node quadrilateral, exporting to a <span>PETSC_VIEWER_HDF5_VIZ</span> viewer provides the correct matrix of node coordinates in geometry/vertices</div></blockquote><div><br></div><div>If you wanted to include edges/faces, you could do it. First, you would need to decide how you would number things For example, would you number all points contiguously, or separately number cells, vertices, faces and edges. Second, you would check for faces/edges in the closure loop. Right now, we only check for vertices.</div><div><br></div><div>I would say that this is what convinced me not to do FEM this way.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">(here a quadrilateral in [0, 10])</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span>5.0, 5.0</span><div><span>0.0, 0.0</span></div><div><span>10.0, 0.0</span></div><div><span>10.0, 10.0</span></div><div><span>0.0, 10.0</span></div><div><span>5.0, 0.0</span></div><div><span>10.0, 5.0</span></div><div><span>5.0, 10.0</span></div><div><span>0.0, 5.0</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)">but the connectivity in viz/topology is</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)">0 1 2 3</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)">which are likely the corner nodes of the initial, first-order element, before adding extra nodes for the higher degree element.</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)">This connectivity values [0, 1, 2, 3, ...] are always the same, including for other elements, whereas the coordinates are correct</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)">E.g. for 3rd order triangle in [0, 1], coordinates are given left to right, bottom to top<br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">0, 0</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">1/3, 0,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">2/3, 0,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">1, 0</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">0, 1/3</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">1/3, 1/3</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">2/3, 1/3</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">0, 2/3,</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">1/3, 2/3</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">0, 1<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)">but the connectivity (viz/topology/cells) is [0, 1, 2].</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)">Test meshes were created with gmsh from the python API, using</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span>gmsh.option.setNumber("Mesh.ElementOrder", n), for n = 1, 2, 3, ...</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)">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<br></div><div>
On Friday, May 23rd, 2025 at 12:56 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 Thu, May 22, 2025 at 12:25 PM Noam T. <<a rel="noreferrer nofollow noopener" href="mailto:dontbugthedevs@proton.me" 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">Hello,</div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">Thank you the various options. <br></div><div style="font-family:Arial,sans-serif;font-size:14px"><br></div><div style="font-family:Arial,sans-serif;font-size:14px">Use case here would be obtaining the exact output generated by option 1), DMView() with PETSC_VIEWER_HDF5_VIZ; in particular, the matrix generated under /viz/topology/cells. </div><div style="font-family:Arial,sans-serif;font-size:14px"><br>
<blockquote type="cite">
<div dir="ltr"><div><div>There are several ways you might do this. It helps to know what you are aiming for.</div><div><br></div><div>1)
If you just want this output, it might be easier to just DMView() with
the PETSC_VIEWER_HDF5_VIZ format, since that just outputs the
cell-vertex topology and coordinates</div></div></div></blockquote><div><br></div><div>Is it possible to get this information in memory, onto a Mat, Vec or
some other Int array object directly? it would be handy to have it in order to manipulate it and/or save it to a different format/file. Saving to an HDF5 and loading it
again seems redundant. <br></div><div><br></div><blockquote type="cite"><div dir="ltr"><div><br></div><div><div>2) You can call DMPlexUninterpolate() to produce a mesh with just cells and vertices, and output it in any format.</div><div><br></div><div>3)
If you want it in memory, but still with global indices (I don't
understand this use case), then you can use DMPlexCreatePointNumbering()
for an overall global numbering, or DMPlexCreateCellNumbering() and
DMPlexCreateVertexNumbering() for separate global numberings.</div><div><br></div></div></div>
</blockquote><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Perhaps I missed it, but getting the connectivity matrix in /viz/topology/cells/ did not seem directly trivial to me from the list of global indices returned by DMPlexGetCell/Point/VertexNumbering() (i.e. I assume all the operations done when calling DMView()).</div></blockquote><div><br></div><div>Something like</div><div><br></div><div>DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);</div><div>DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd);</div><div>DMPlexGetVertexNumbering(dm, &globalVertexNumbers);</div><div>ISGetIndices(globalVertexNumbers, &gv);</div><div>for (PetscInt c = cStart; c < cEnd; ++c) {</div><div> PetscInt *closure = NULL;</div><div><br></div><div> DMPlexGetTransitiveClosure(dm, c, PETSC_TRUE, &Ncl, &closure);</div><div> for (PetscInt cl = 0; c < Ncl * 2; cl += 2) {</div><div> if (closure[cl] < vStart || closure[cl] >= vEnd) continue;</div><div> const PetscInt v = gv[closure[cl]] < 0 ? -(gv[closure[cl]] + 1) : gv[closure[cl]];</div><div><br></div><div> // Do something with v</div><div> }</div><div> DMPlexRestoreTransitiveClosure(dm, c, PETSC_TRUE, &Ncl, &closure);</div><div>}</div><div>ISRestoreIndices(globalVertexNumbers, &gv);</div><div>ISDestroy(&globalVertexNumbers);</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><br></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)">Thanks,<br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Noam.<br></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 rel="noreferrer nofollow noopener" href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!buGhhRYyQDY3kig5GA6tIzeIOCoCAtlZzIz_UTAH1bZ-05GXENI3VZos9r4s6fXhktg7wUl--lMKoHYcPmhy$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote><br>
</div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div class="gmail_signature" dir="ltr"><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!buGhhRYyQDY3kig5GA6tIzeIOCoCAtlZzIz_UTAH1bZ-05GXENI3VZos9r4s6fXhktg7wUl--lMKoHYcPmhy$" 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></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!buGhhRYyQDY3kig5GA6tIzeIOCoCAtlZzIz_UTAH1bZ-05GXENI3VZos9r4s6fXhktg7wUl--lMKoHYcPmhy$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</div>