[petsc-users] DMPlex filter with Face Sets

Thibault Bridel-Bertomeu thibault.bridelbertomeu at gmail.com
Fri Jan 14 07:55:11 CST 2022


Hi Matt,

Thank you for your help in this matter !
Do you mind posting the link to the gitlab issue when you have the occasion
to open it ?

Thanks !
Thibault


Le ven. 14 janv. 2022 à 14:37, Matthew Knepley <knepley at gmail.com> a écrit :

> On Fri, Jan 14, 2022 at 8:23 AM Thibault Bridel-Bertomeu <
> thibault.bridelbertomeu at gmail.com> wrote:
>
>> Dear all,
>>
>> I have a new question - in relation with my other ongoing thread
>> "Fluid-Structure interaction with multiple DMPlex" actually.
>> 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 ?
>>
>
> You are right. We are not doing labels. That is just an oversight. I will
> fix it.
>
>   Thanks,
>
>      Matt
>
>
>> Consider for instance the following example :
>>
>> // Standard includes
>> #include <cstdlib>
>>
>> // PETSc includes
>> #include <petscsys.h>
>> #include <petscdmplex.h>
>> #include <petscds.h>
>>
>> int main(
>> int argc, /**< Number of CLI arguments */
>> char* argv[] /**< List of CLI arguments as strings */
>> )
>> {
>> User user;
>> DM dm;
>> PetscErrorCode ierr = EXIT_SUCCESS;
>>
>> // Start-up the PETSc interface
>> ierr = PetscInitialize(&argc, &argv, (char*)0, NULL);if (ierr) return
>> ierr;
>>
>> // Allocate whatever needs to be
>> ierr = PetscNew(&user);CHKERRQ(ierr);
>>
>> // Parse the mesh given by the user
>> //+ Mesh filename
>> ierr = PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "PETSc DMPlex Coupled
>> Physics Demo Mesh Options", "");CHKERRQ(ierr);
>> {
>> ierr = PetscStrcpy(user->meshName,
>> "data/divided_square/divided_square_gmsh22ascii.msh");CHKERRQ(ierr);
>> ierr = PetscOptionsString("-meshname", "Mesh filename", "",
>> user->meshName, user->meshName, sizeof(user->meshName), NULL);CHKERRQ
>> (ierr);
>> }
>> ierr = PetscOptionsEnd();CHKERRQ(ierr);
>> //+ Read the mesh in
>> ierr = DMPlexCreateFromFile(PETSC_COMM_WORLD, user->meshName,
>> "CoupledPhysics_Plex", PETSC_TRUE, &dm);CHKERRQ(ierr);
>> ierr = DMSetFromOptions(dm);CHKERRQ(ierr);
>> ierr = DMViewFromOptions(dm, NULL, "-dm_view");CHKERRQ(ierr);
>>
>> // Extract both domains separately
>> //+ Label of the fluid domain
>> DMLabel fluidLabel;
>> ierr = DMGetLabel(dm, "Fluid", &fluidLabel);CHKERRQ(ierr);
>> //+ Sub-DM for the fluid domain
>> DM fluidDM;
>> // ierr = DMPlexFilter(dm, domainsLabel, 2, &fluidDM);CHKERRQ(ierr);
>> ierr = DMPlexFilter(dm, fluidLabel, 2, &fluidDM);CHKERRQ(ierr);
>> ierr = DMViewFromOptions(fluidDM, NULL, "-fluid_dm_view");CHKERRQ(ierr);
>> //+ Label of the solid domain
>> DMLabel solidLabel;
>> ierr = DMGetLabel(dm, "Solid", &solidLabel);CHKERRQ(ierr);
>> //+ Sub-DM for the solid domain
>> DM solidDM;
>> ierr = DMPlexFilter(dm, solidLabel, 1, &solidDM);CHKERRQ(ierr);
>> ierr = DMViewFromOptions(solidDM, NULL, "-solid_dm_view");CHKERRQ(ierr);
>>
>> // Close the PETSc interface and end the parallel communicator
>> ierr = PetscFree(user);CHKERRQ(ierr);
>> ierr = PetscFinalize();
>> return(ierr);
>> }
>>
>> 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.
>> It yields :
>>
>> DM Object: CoupledPhysics_Plex 1 MPI processes
>>   type: plex
>> CoupledPhysics_Plex in 2 dimensions:
>>   Number of 0-cells per rank: 1409
>>   Number of 1-cells per rank: 4084
>>   Number of 2-cells per rank: 2676
>> Labels:
>>   celltype: 3 strata with value/size (0 (1409), 3 (2676), 1 (4084))
>>   depth: 3 strata with value/size (0 (1409), 1 (4084), 2 (2676))
>>   Cell Sets: 2 strata with value/size (1 (924), 2 (1752))
>>   Solid: 1 strata with value/size (1 (924))
>>   Fluid: 1 strata with value/size (2 (1752))
>>   Face Sets: 5 strata with value/size (4 (60), 3 (40), 7 (20), 5 (40), 6
>> (20))
>>   Insulation: 1 strata with value/size (4 (60))
>>   Wall: 1 strata with value/size (3 (40))
>>   Outlet: 1 strata with value/size (7 (20))
>>   Freestream: 1 strata with value/size (5 (40))
>>   Inlet: 1 strata with value/size (6 (20))
>>
>> DM Object: 1 MPI processes
>>   type: plex
>> DM_0x557ff009be70_1 in 2 dimensions:
>>   Number of 0-cells per rank: 937
>>   Number of 1-cells per rank: 2688
>>   Number of 2-cells per rank: 1752
>> Labels:
>>   celltype: 3 strata with value/size (0 (937), 1 (2688), 3 (1752))
>>   depth: 3 strata with value/size (0 (937), 1 (2688), 2 (1752))
>>
>> 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.
>> 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
>> ?
>>
>> Thank you very much !!
>>
>> Thibault Bridel-Bertomeu
>>>> Eng, MSc, PhD
>> Research Engineer
>> CEA/CESTA
>> 33114 LE BARP
>> Tel.: (+33)557046924
>> Mob.: (+33)611025322
>> Mail: thibault.bridelbertomeu at gmail.com
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220114/cb950bdc/attachment-0001.html>


More information about the petsc-users mailing list