<div dir="ltr"><div dir="ltr">On Thu, Jun 12, 2025 at 4:26 PM Noam T. <<a href="mailto:dontbugthedevs@proton.me">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><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 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)">(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" 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 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 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 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)">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 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!ZA5yOw1wQdQdd1QT0ndwemC5JH9XGk4qzeUI8a6lD8ieAGoEqoAcyXjE2Jf7p7NhTntf6c-fCz4hsjSS7x2y$" 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!ZA5yOw1wQdQdd1QT0ndwemC5JH9XGk4qzeUI8a6lD8ieAGoEqoAcyXjE2Jf7p7NhTntf6c-fCz4hsjSS7x2y$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>