<div dir="ltr"><div dir="ltr">On Fri, Jan 14, 2022 at 9:07 AM Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com">thibault.bridelbertomeu@gmail.com</a>> wrote:<br></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 dir="ltr"><div dir="ltr"><div>Also, if we still consider my example with Solid and Fluid, let's image we call DMPlexFilter twice. We then get two new DMs with Solid in one and Fluid in the other one.</div><div><br></div><div>The labels will be communicated, so fluidDM will still know Wall, Inlet, Freestream and Outlet and on the other hand, solidDM will still know Wall and Insulation : those two domain share the Wall stratum of the Face Sets.</div><div><br></div><div>Can I extract data at the Wall label from the solidDM and transfer it to the Wall label of the fluidDM ?</div></div></div></blockquote><div><br></div><div>Yes, conceptually here is how that would work. You iterate over the label, extracting the values you want. You map those points</div><div>to points in the original mesh using the subpointMap, and then map them again using the subpointMap from the fluidDM down to it.</div><div>Now you can insert the values using the section in the fluidDM. I think the easiest way to do this is to setup a VecScatter (or PetscSF)</div><div>from one boundary to the other. Then you would just stick in the two vectors and call VecScatterBegin/End()</div><div><br></div><div>If this turns out to be useful, this construction is something we could easily automate in the library.</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 dir="ltr"><div dir="ltr"><div>Thanks !<br></div><div>Thibault<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 14 janv. 2022 à 14:55, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank">thibault.bridelbertomeu@gmail.com</a>> a écrit :<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>Hi Matt, <br></div><div><br></div><div>Thank you for your help in this matter !</div><div>Do you mind posting the link to the gitlab issue when you have the occasion to open it ?</div><div><br></div><div>Thanks !</div><div>Thibault<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 14 janv. 2022 à 14:37, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> a écrit :<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">On Fri, Jan 14, 2022 at 8:23 AM Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank">thibault.bridelbertomeu@gmail.com</a>> wrote:<br></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 dir="ltr"><div>Dear all,</div><div><br></div><div>I have a new question - in relation with my other ongoing thread "Fluid-Structure interaction with multiple DMPlex" actually.</div><div>Is it possible to filter a DMPlex and keep in the new piece of DM the strata from the Face Sets label that belong to that piece ?</div></div></blockquote><div><br></div><div>You are right. We are not doing labels. That is just an oversight. I will fix it.</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 dir="ltr"><div>Consider for instance the following example :</div><div><br></div><div><div style="color:rgb(248,248,242);background-color:rgb(39,40,34);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><div style="color:rgb(248,248,242);background-color:rgb(39,40,34);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><span style="color:rgb(136,132,111)">// Standard includes</span><div><span style="color:rgb(249,38,114)">#include</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(230,219,116)"><cstdlib></span></div><br><div><span style="color:rgb(136,132,111)">// PETSc includes</span></div><div><span style="color:rgb(249,38,114)">#include</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(230,219,116)"><petscsys.h></span></div><div><span style="color:rgb(249,38,114)">#include</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(230,219,116)"><petscdmplex.h></span></div><div><span style="color:rgb(249,38,114)">#include</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(230,219,116)"><petscds.h></span></div><div><span style="color:rgb(230,219,116)"><br></span></div></div><span style="color:rgb(102,217,239);font-style:italic"></span></div><div><span style="color:rgb(102,217,239);font-style:italic">int</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">main</span><span style="color:rgb(248,248,242)">(</span></div><div><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(102,217,239);font-style:italic">int</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(253,151,31);font-style:italic">argc</span><span style="color:rgb(248,248,242)">,</span><span style="color:rgb(136,132,111)"> /**< Number of CLI arguments */</span></div><div><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(102,217,239);font-style:italic">char</span><span style="color:rgb(249,38,114)">*</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(253,151,31);font-style:italic">argv</span><span style="color:rgb(248,248,242)">[]</span><span style="color:rgb(136,132,111)"> /**< List of CLI arguments as strings */</span></div><div><span style="color:rgb(248,248,242)"> )</span></div><div><span style="color:rgb(248,248,242)">{</span></div><div><span style="color:rgb(248,248,242)"> User user;</span></div><div><span style="color:rgb(248,248,242)"> DM dm;</span></div><div><span style="color:rgb(248,248,242)"> PetscErrorCode ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> EXIT_SUCCESS;</span></div><br><div><span style="color:rgb(136,132,111)"> // Start-up the PETSc interface</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscInitialize</span><span style="color:rgb(248,248,242)">(</span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">argc, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">argv, (</span><span style="color:rgb(102,217,239);font-style:italic">char</span><span style="color:rgb(249,38,114)">*</span><span style="color:rgb(248,248,242)">)</span><span style="color:rgb(174,129,255)">0</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(249,38,114)">if</span><span style="color:rgb(248,248,242)"> (ierr) </span><span style="color:rgb(249,38,114)">return</span><span style="color:rgb(248,248,242)"> ierr;</span></div><br><div><span style="color:rgb(136,132,111)"> // Allocate whatever needs to be</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscNew</span><span style="color:rgb(248,248,242)">(</span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">user);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><br><div><span style="color:rgb(136,132,111)"> // Parse the mesh given by the user</span></div><div><span style="color:rgb(136,132,111)"> //+ Mesh filename</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscOptionsBegin</span><span style="color:rgb(248,248,242)">(PETSC_COMM_WORLD, </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">"PETSc DMPlex Coupled Physics Demo Mesh Options"</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">""</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> {</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscStrcpy</span><span style="color:rgb(248,248,242)">(user->meshName, </span><span style="color:rgb(230,219,116)">"data/divided_square/divided_square_gmsh22ascii.msh"</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscOptionsString</span><span style="color:rgb(248,248,242)">(</span><span style="color:rgb(230,219,116)">"-meshname"</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">"Mesh filename"</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">""</span><span style="color:rgb(248,248,242)">, user->meshName, user->meshName, </span><span style="color:rgb(249,38,114)">sizeof</span><span style="color:rgb(248,248,242)">(user->meshName), </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> }</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscOptionsEnd</span><span style="color:rgb(248,248,242)">();</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(136,132,111)"> //+ Read the mesh in</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMPlexCreateFromFile</span><span style="color:rgb(248,248,242)">(PETSC_COMM_WORLD, user->meshName, </span><span style="color:rgb(230,219,116)">"CoupledPhysics_Plex"</span><span style="color:rgb(248,248,242)">, PETSC_TRUE, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">dm);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMSetFromOptions</span><span style="color:rgb(248,248,242)">(dm);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMViewFromOptions</span><span style="color:rgb(248,248,242)">(dm, </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">"-dm_view"</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"><br></span></div><div><div style="color:rgb(248,248,242);background-color:rgb(39,40,34);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(136,132,111)"> // Extract both domains separately</span></div><div><span style="color:rgb(136,132,111)"> //+ Label of the fluid domain</span></div><div><span style="color:rgb(248,248,242)"> DMLabel fluidLabel;</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMGetLabel</span><span style="color:rgb(248,248,242)">(dm, </span><span style="color:rgb(230,219,116)">"Fluid"</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">fluidLabel);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(136,132,111)"> //+ Sub-DM for the fluid domain</span></div><div><span style="color:rgb(248,248,242)"> DM fluidDM;</span></div><div><span style="color:rgb(136,132,111)"> // ierr = DMPlexFilter(dm, domainsLabel, 2, &fluidDM);CHKERRQ(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMPlexFilter</span><span style="color:rgb(248,248,242)">(dm, fluidLabel, </span><span style="color:rgb(174,129,255)">2</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">fluidDM);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMViewFromOptions</span><span style="color:rgb(248,248,242)">(fluidDM, </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">"-fluid_dm_view"</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(136,132,111)"> //+ Label of the solid domain</span></div><div><span style="color:rgb(248,248,242)"> DMLabel solidLabel;</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMGetLabel</span><span style="color:rgb(248,248,242)">(dm, </span><span style="color:rgb(230,219,116)">"Solid"</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">solidLabel);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(136,132,111)"> //+ Sub-DM for the solid domain</span></div><div><span style="color:rgb(248,248,242)"> DM solidDM;</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMPlexFilter</span><span style="color:rgb(248,248,242)">(dm, solidLabel, </span><span style="color:rgb(174,129,255)">1</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(249,38,114)">&</span><span style="color:rgb(248,248,242)">solidDM);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">DMViewFromOptions</span><span style="color:rgb(248,248,242)">(solidDM, </span><span style="color:rgb(174,129,255)">NULL</span><span style="color:rgb(248,248,242)">, </span><span style="color:rgb(230,219,116)">"-solid_dm_view"</span><span style="color:rgb(248,248,242)">);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><br><div><span style="color:rgb(136,132,111)"> // Close the PETSc interface and end the parallel communicator</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscFree</span><span style="color:rgb(248,248,242)">(user);</span><span style="color:rgb(166,226,46)">CHKERRQ</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)"> ierr </span><span style="color:rgb(249,38,114)">=</span><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(166,226,46)">PetscFinalize</span><span style="color:rgb(248,248,242)">();</span></div><div><span style="color:rgb(248,248,242)"> </span><span style="color:rgb(249,38,114)">return</span><span style="color:rgb(248,248,242)">(ierr);</span></div><div><span style="color:rgb(248,248,242)">}</span></div></div><span style="color:rgb(248,248,242)"></span></div></div></div><div><br></div><div>run with the mesh attached to this email and the command ./program
-meshname divided_square_gmsh41ascii.msh -dm_plex_gmsh_use_regions
-dm_view -fluid_dm_view.</div><div>It yields :</div><div><br></div><div>DM Object: CoupledPhysics_Plex 1 MPI processes<br> type: plex<br>CoupledPhysics_Plex in 2 dimensions:<br> Number of 0-cells per rank: 1409<br> Number of 1-cells per rank: 4084<br> Number of 2-cells per rank: 2676<br>Labels:<br> celltype: 3 strata with value/size (0 (1409), 3 (2676), 1 (4084))<br> depth: 3 strata with value/size (0 (1409), 1 (4084), 2 (2676))<br> Cell Sets: 2 strata with value/size (1 (924), 2 (1752))<br> Solid: 1 strata with value/size (1 (924))<br> Fluid: 1 strata with value/size (2 (1752))<br> Face Sets: 5 strata with value/size (4 (60), 3 (40), 7 (20), 5 (40), 6 (20))<br> Insulation: 1 strata with value/size (4 (60))<br> Wall: 1 strata with value/size (3 (40))<br> Outlet: 1 strata with value/size (7 (20))<br> Freestream: 1 strata with value/size (5 (40))<br> Inlet: 1 strata with value/size (6 (20))</div><div><br></div><div>DM Object: 1 MPI processes<br> type: plex<br>DM_0x557ff009be70_1 in 2 dimensions:<br> Number of 0-cells per rank: 937<br> Number of 1-cells per rank: 2688<br> Number of 2-cells per rank: 1752<br>Labels:<br> celltype: 3 strata with value/size (0 (937), 1 (2688), 3 (1752))<br> depth: 3 strata with value/size (0 (937), 1 (2688), 2 (1752))</div><div><br></div><div>In the attached mesh, Wall, Outlet, Freestream and Inlet "belong" to the Fluid domain, therefore I would like to transfer them to the fluidDM during or right after the DMPlexFilter action.</div><div>Is that possible ? I was looking at extracting the IS from those labels of dm and creating new labels in fluidDM from those IS, but the indices won't match, will they ? The filtering operation renumbers everything right ?</div><div><br></div><div>Thank you very much !!<br></div><div><br></div><div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><div><div><div>Thibault Bridel-Bertomeu<br>—<br></div></div></div></div>Eng, MSc, PhD</div><div>Research Engineer</div><div>CEA/CESTA</div><div>33114 LE BARP</div><div>Tel.: (+33)557046924</div><div>Mob.: (+33)611025322<br></div><div>Mail: <a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank">thibault.bridelbertomeu@gmail.com</a><br></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div 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="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <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="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>