<div dir="ltr"><div dir="ltr">On Mon, Oct 13, 2025 at 11:17 AM Semplice Matteo <<a href="mailto:matteo.semplice@uninsubria.it">matteo.semplice@uninsubria.it</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>
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div id="m_-7837019136620973688ms-outlook-mobile-body-separator-line" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt" dir="auto">
<div dir="auto" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt" id="m_-7837019136620973688ms-outlook-mobile-signature" dir="auto">
<span style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">Inviato da
<a href="https://urldefense.us/v3/__https://aka.ms/AAb9ysg__;!!G_uCfscf7eWS!bufWgyONsvb66zmOv6LgtJsh0Yr4dFXIovj8jn6nt7Ugtd0-U5Tthdyj_F0vRS7qG9mtw4BzudiTClCJsK8z$" target="_blank">Outlook per Android</a></span></div>
<div dir="auto" id="m_-7837019136620973688mail-editor-reference-message-container"><br>
<hr style="display:inline-block;width:98%">
<div id="m_-7837019136620973688divRplyFwdMsg" style="font-size:11pt" dir="auto"><b>Da:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Inviato:</b> Sabato, Ottobre 11, 2025 11:19:23 PM<br>
<b>A:</b> Semplice Matteo <<a href="mailto:matteo.semplice@uninsubria.it" target="_blank">matteo.semplice@uninsubria.it</a>><br>
<b>Cc:</b> PETSc <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Oggetto:</b> Re: [petsc-users] extract arbitrary subset of a DMDA<br>
</div>
<br>
<div dir="auto">On Fri, Oct 10, 2025 at 11:15 AM Matteo Semplice <<a href="mailto:matteo.semplice@uninsubria.it" target="_blank">matteo.semplice@uninsubria.it</a>> wrote:</div>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)">
<p dir="ltr" class="gmail_quote">On 10/10/2025 16:39, Matthew Knepley wrote:</p>
<blockquote>
<div dir="auto" class="gmail_quote">On Fri, Oct 10, 2025 at 9:48 AM Matteo Semplice via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)">
<div dir="auto" class="gmail_quote">Dear all,<br>
<br>
I am wondering if there is a way to extract a subset of a DMDA and<br>
use it as a mesh. The use case is to program a finite-difference method<br>
in which the domain is defined by a levelset function: if I could<br>
completely ignore the parts of the background DMDA that are "far away"<br>
from the object, I guess I would avoid some cores having almost no<br>
workload. I figure that I could setup a DMDA, load/compute the levelset<br>
on the entire box, then mark the nodes to be retained, extract the<br>
submesh and repartition it. I would also need a mean to transfer some<br>
Vec data from the DMDA to the new mesh.<br>
<br>
I guess that the extracted mesh would then become a DMPlex and it would<br>
not retain any DMDA flavour (like notions of which are the grid nodes<br>
sitting on top/bottom, left/right of a given node), right?</div>
</blockquote>
<div class="gmail_quote"><br>
</div>
<div dir="auto" class="gmail_quote">If you are planning on extracting a Plex anyway, I think it would be easier to just</div>
<div dir="auto" class="gmail_quote">start with a Cartesian Plex, instead of a DA, and use DMPlexCreateSubmesh(). </div>
</blockquote>
<p dir="ltr" class="gmail_quote">Hmmm... doable, but I have a couple of questions.</p>
<p dir="ltr" class="gmail_quote">By Cartesian Plex you mean a Plex created by DMPlexCreateBoxMesh with simplex=false, right?</p>
</blockquote>
<div dir="auto" class="gmail_quote">Yes, exactly</div>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)">
<p dir="ltr" class="gmail_quote">And, could you point me to the routines that can perform data tranfer from Vecs associated to the DM to the ones asscoiated to the subDM? Is DMPlexGetSubpointIS the way to go?</p>
</blockquote>
<div dir="auto" class="gmail_quote">Yes. You get the IS and then you can use</div>
<div dir="auto" class="gmail_quote"><br>
</div>
<div dir="auto" class="gmail_quote"> <a href="https://urldefense.us/v3/__https://petsc.org/main/manualpages/Vec/VecISCopy/__;!!G_uCfscf7eWS!bufWgyONsvb66zmOv6LgtJsh0Yr4dFXIovj8jn6nt7Ugtd0-U5Tthdyj_F0vRS7qG9mtw4BzudiTCi5Y9fxK$" target="_blank">
https://petsc.org/main/manualpages/Vec/VecISCopy/</a> </div>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)">
<p dir="ltr" class="gmail_quote">Next, I will load the levelsets from the output of another code that is DA-based and that I'd really like to reuse some code in the setup phase which relies on the DA indexing. So maybe I'd rather, create the DMDA and the associated
Vecs, do the setup phase, then DMConvert the DMDA to a "large" DMPlex that covers the entire box, transfer the DA Vecs to the "large" Plex vectors and then extract the submesh. Would this be feasible? If so, can you point me to the routines to transfer the
vecs from the dmda to the large plex?</p>
</blockquote>
<div dir="auto" class="gmail_quote">Yes, this sounds doable, and once we write it, we should just put it in the library.</div>
<div dir="auto" class="gmail_quote"><br>
</div>
<div dir="auto" class="gmail_quote">In serial this is completely trivial. The DA has a known ordering and the Plex has a known ordering. We can use an AO</div>
<div dir="auto" class="gmail_quote">or just a VecScatter to permute the Vec. In parallel, the DA is partitioned geometrically, whereas the Plex, by default, is partitioned using a graph partitioner, like ParMetis. To me, if this project
is important, it seems worth it to build a simple partitioner for the Plex that mimics the DA. Then we are back to the trivial remapping. Finally, we probably want the Plex dual to the DA due to the way that DAs partition things.</div>
<div dir="auto" class="gmail_quote"><br>
</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
____</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
Hi Matt,</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
doing some research on parallel Plex I found this thread on the list from 2020</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<a href="https://lists.mcs.anl.gov/pipermail/petsc-users/2020-August/041934.html" rel="noreferrer noopener" target="_blank">https://lists.mcs.anl.gov/pipermail/petsc-users/2020-August/041934.html</a></div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
I will explore this way to create a basic cartesian Plex from my distributed da. I think that there are enough info there, but I will come back if I run into troubles.</div></div></div></blockquote><div><br></div><div>Sure this is doable. Creating the SF is morally the same thing as creating the partition I was asking for with CreateBoxMesh.</div><div><br></div><div>As I mentioned at the end of the last post, DA partitions "vertices" and shares "edges", which is not how we normally think in finite element land. If you are using the Plex for finite difference, then I would just match the DA. If you are using it for finite elements, I would create the dual mesh instead.</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><div dir="auto" id="m_-7837019136620973688mail-editor-reference-message-container">
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
Or do you suggest that I should instead study the private methods used in DMPlexCreateBoxMesh?</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
Thanks </div>
<div dir="auto" class="gmail_quote" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
Matteo</div>
<div dir="auto" class="gmail_signature"><br>
</div>
</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!bufWgyONsvb66zmOv6LgtJsh0Yr4dFXIovj8jn6nt7Ugtd0-U5Tthdyj_F0vRS7qG9mtw4BzudiTChMNFZIy$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>