<div dir="ltr"><div dir="ltr">On Thu, May 22, 2025 at 12:25 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 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 href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!c-kIsacyZtVK0QT5hSQ6TYjx-_vFWjrr6SXhV0Q8o9GcMLSLwko9mlT7CXjpNSVCT4bRPKeSkCoQJGpFQC8u$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>