<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><br></div><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"><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"><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"><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" class="gmail_signature" data-smartmail="gmail_signature"><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>