<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"></div><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">On 24 Apr 2025, at 6:08 PM, neil liu <liufield@gmail.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Thanks a lot, Pierre. It works now. <div>Another question is, with the present strategy, after the adapting, we will get a pseudo DM object, which has all information on rank 0 and nothing on all other ranks. </div><div>Then I tried to use DMPlexdistribute to partition it and the partitioned DMs seem correct. Is it safe to do things like this?</div></div></div></blockquote><div><br></div><div>I think this is sane, but if that triggers an error down the road, feel free to send a reproducer.</div><div><br></div><div>Thanks,</div><div>Pierre</div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>Thanks, </div><div><br></div><div>Xiaodong </div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Apr 23, 2025 at 4:33 PM Pierre Jolivet <<a href="mailto:pierre@joliv.et">pierre@joliv.et</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"><div dir="auto"><div dir="ltr"></div><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">On 23 Apr 2025, at 7:28 PM, neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p><strong>MMG only supports serial execution, whereas ParMMG supports parallel mode (although ParMMG is not as robust or mature as MMG).</strong><br>
Given this, could you please provide some guidance on how to handle this in the code?</p>
<p>Here are my current thoughts; please let know whether it could work as a temporary solution. <br></p></div></div></div></blockquote><div>That could work,</div><div>Pierre</div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p>
We may only need to make minor modifications in the <code>DMAdaptMetric_Mmg_Plex()</code> subroutine. Specifically:</p>
<ul>
<li>
<p>Allow all <strong>collective PETSc functions</strong> to run across all ranks as usual.</p>
</li>
<li>
<p>Restrict the <strong>MMG-specific logic</strong> to run <strong>only on rank 0</strong>, since MMG is serial-only.</p>
</li>
<li>
<p>Add a check before MMG is called to ensure that <strong>only rank 0 holds mesh cells</strong>, i.e., validate that <code>cEnd - cStart > 0</code> only on rank 0. If more than one rank holds cells, raise a clear warning or error.</p></li></ul></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 23, 2025 at 1:11 PM Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</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"><div dir="ltr">If mmg does not support parallel communicators, we should handle it internally in the code, always use commself, and raise an error if there are two or more processes in the comm that have cEnd - cStart > 0</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mer 23 apr 2025 alle ore 20:05 neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font size="4">Thanks a lot. Pierre.</font><div><font size="4">Do you have any suggestions to build a real serial DM from this gatherDM? </font></div><div><font size="4">I tried several ways, which don't work.</font></div><div><font size="4">DMClone? </font></div><div><font size="4"><br></font></div><div><font size="4">Thanks,</font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 23, 2025 at 11:39 AM Pierre Jolivet <<a href="mailto:pierre@joliv.et" target="_blank">pierre@joliv.et</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"><div><br id="m_8496100641179273378m_-1666321652640993054m_4165382568992225911m_9066577954782136701m_-8954130641156169468lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On 23 Apr 2025, at 5:31 PM, neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="4">Thanks a lot, Stefano. </font><div><font size="4">I tried DMPlexGetGatherDM and DMPlexDistributeField. It can give what we expected. </font></div><div><font size="4">The final gatherDM is listed as follows, rank 0 has all information (which is right) while rank 1 has nothing. </font></div><div><font size="4">Then I tried to feed this gatherDM  into adaptMMG on rank 0 only (it seems MMG works better than ParMMG, that is why I want MMG to be tried first). But it was stuck at collective petsc functions in DMAdaptMetric_Mmg_Plex(). By the way, the present work can work well with 1 rank.</font></div><div><font size="4"><br></font></div><div><font size="4">Do you have any suggestions ?  B</font><span style="font-size:large">uild a real serial DM? </span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Yes, you need to change the underlying MPI_Comm as well, but I’m not sure if there is any user-facing API for doing this with a one-liner.</div><div><br></div><div>Thanks,</div><div>Pierre</div><br><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-size:large">Thanks a lot.</span></div><div><span style="font-size:large">Xiaodong </span></div><div><font size="4"><br></font></div><div><div>DM Object: Parallel Mesh 2 MPI processes</div><div>  type: plex</div><div>Parallel Mesh in 3 dimensions:</div><div>  Number of 0-cells per rank: 56 0</div><div>  Number of 1-cells per rank: 289 0</div><div>  Number of 2-cells per rank: 452 0</div><div>  Number of 3-cells per rank: 216 0</div><div>Labels:</div><div>  depth: 4 strata with value/size (0 (56), 1 (289), 2 (452), 3 (216))</div><div>  celltype: 4 strata with value/size (0 (56), 1 (289), 3 (452), 6 (216))</div><div>  Cell Sets: 2 strata with value/size (29 (152), 30 (64))</div><div>  Face Sets: 3 strata with value/size (27 (8), 28 (40), 101 (20))</div><div>  Edge Sets: 1 strata with value/size (10 (10))</div><div>  Vertex Sets: 5 strata with value/size (27 (2), 28 (6), 29 (2), 101 (4), 106 (4))</div><div>Field Field_0:</div><div>  adjacency FEM</div></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 18, 2025 at 10:09 AM Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</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"><div dir="ltr">If you have a vector distributed on the original mesh, then you can use the SF returned by DMPlexGetGatherDM and use that in a call to DMPlexDistributeField</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno ven 18 apr 2025 alle ore 17:02 neil liu <<a href="mailto:liufield@gmail.com" target="_blank">liufield@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><p>Dear PETSc developers and users,</p><p>I am currently exploring the integration of MMG3D with PETSc. Since MMG3D supports only serial execution, I am planning to combine parallel and serial computing in my workflow. Specifically, after solving the linear systems in parallel using PETSc:</p>
<ol>
<li><p>I intend to use <code>DMPlexGetGatherDM</code> to collect the entire mesh on the root process for input to MMG3D.</p>
</li>
<li><p>Additionally, I plan to gather the error field onto the root process using <code>VecScatter</code>.</p>
</li>
</ol><p>However, I am concerned that the nth value in the gathered error vector (step 2) may not correspond to the nth element in the gathered mesh (step 1). Is this a valid concern?</p><p>Do you have any suggestions or recommended practices for ensuring correct correspondence between the solution fields and the mesh when switching from parallel to serial mode?</p><div><br></div><div>Thanks, </div><div><br></div><div>Xiaodong </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">Stefano</div>
</blockquote></div>
</div></blockquote></div><br></div></blockquote></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Stefano</div>
</blockquote></div>
</div></blockquote></div></blockquote></div>
</div></blockquote></body></html>