[petsc-users] Non-manifold dmplex

Jeremy Theler (External) jeremy.theler-ext at ansys.com
Wed Nov 1 14:49:43 CDT 2023


Hello all but especially Matt,

I am trying to build this "non-manifold" DMplex that has already been brought up in these two threads:

https://lists.mcs.anl.gov/pipermail/petsc-users/2021-December/045091.html
https://lists.mcs.anl.gov/pipermail/petsc-users/2021-October/044743.html


In this new thread I'm opening as in the two above, the background is solving elasticity with FEM using a mixture of solid, shells/plates and/or beam/truss elements.


My first attempt was to create a cube and a line connecting one of the cube's corners to a point in Gmsh (cube-line.geo and cube-line-geo.png) and then mesh this geometry so as to have a single hex8 and a single line2, both defined using 9 nodes. (cube-line.msh and cube-line-mesh.png).
But DMPlexCreateGmshFromFile() did not pick up the line2 element because there's this logic that "cell" means "element with topological dimension equal to that of the mesh", i.e. 3.

So, I then tried to create the DM from a DAG with the same information that could have been parsed from the msh file:


    PetscInt num_points[4] = {9, 1, 0, 1};
    PetscInt cone_size[11] = {8,
                              0, 0, 0, 0, 0, 0, 0, 0, 0,
                              2};
    PetscInt cones[11] = {3,4,2,1,7,5,6,8,
                          6,9};
    PetscInt cone_orientations[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    PetscReal vertex_coords[3*9] = {
      0, 0, 1,
      0, 0, 0,
      0, 1, 1,
      0, 1, 0,
      1, 0, 1,
      1, 0, 0,
      1, 1, 1,
      1, 1, 0,
      2, 0, 0
    };

    DM dm;
    PetscCall(DMCreate(PETSC_COMM_WORLD, &dm));
    PetscCall(PetscObjectSetName((PetscObject)dm, "cubeline-fromdag"));
    PetscCall(DMSetType(dm, DMPLEX));
    PetscCall(DMSetDimension(dm, 3));
    PetscCall(DMPlexCreateFromDAG(dm, 3, num_points, cone_size, cones, cone_orientations, vertex_coords));

The DM is now created successfully. With some slight modifications in DMPlexVTKGetCellType_Internal() I can even get a VTK out of the DM which shows the geometry I intended to have (cube-line-dag.vtk and cube-line-vtk.png).

However, when I want to interpolate the DM I get an error which is not the same as the one given in the existing threads:

[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Cone position 1 of point 10 is not in the valid range [0, 1)
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.20.1-96-g294d477ba62  GIT Date: 2023-10-31 00:56:56 -0500
[0]PETSC ERROR: ./main on a arch-linux-c-debug named tom by gtheler Wed Nov  1 16:17:15 2023
[0]PETSC ERROR: Configure options
[0]PETSC ERROR: #1 DMPlexInsertCone() at /home/gtheler/libs/petsc/src/dm/impls/plex/plex.c:3384
[0]PETSC ERROR: #2 DMPlexInterpolateFaces_Internal() at /home/gtheler/libs/petsc/src/dm/impls/plex/plexinterpolate.c:691
[0]PETSC ERROR: #3 DMPlexInterpolate() at /home/gtheler/libs/petsc/src/dm/impls/plex/plexinterpolate.c:1499

I tried to understand a little bit what was going on and the first thing I noticed is that the depth returned by DMPlexGetDepth() is 1 even when I created the DM with an explicit depth of 3.
Thus, I then hardcoded the depth to 3 in DMPlexInterpolateFaces_Internal() and it went a little bit further but failed during stratification:

[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: New depth 3 range [11,19) overlaps with depth 1 range [11,19)
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Development GIT revision: v3.20.1-96-g294d477ba62  GIT Date: 2023-10-31 00:56:56 -0500
[0]PETSC ERROR: ./main on a arch-linux-c-debug named tom by gtheler Wed Nov  1 16:19:40 2023
[0]PETSC ERROR: Configure options
[0]PETSC ERROR: #1 DMPlexCreateDepthStratum() at /home/gtheler/libs/petsc/src/dm/impls/plex/plex.c:4232
[0]PETSC ERROR: #2 DMPlexStratify() at /home/gtheler/libs/petsc/src/dm/impls/plex/plex.c:4356
[0]PETSC ERROR: #3 DMPlexInterpolateFaces_Internal() at /home/gtheler/libs/petsc/src/dm/impls/plex/plexinterpolate.c:711
[0]PETSC ERROR: #4 DMPlexInterpolate() at /home/gtheler/libs/petsc/src/dm/impls/plex/plexinterpolate.c:1499

Find also attached cube-line.c



I followed the old thread on the archives.
Here, Matt suggests that "if you assign cell types, you can even get Plex to automatically interpolate.":
https://lists.mcs.anl.gov/pipermail/petsc-users/2021-December/045100.html

But here he says it won't work because "We use depth in the DAG as a proxy for cell dimension, but this will no longer work if faces are not part of a volume."
https://lists.mcs.anl.gov/pipermail/petsc-users/2021-October/044785.html


Questions:

 1. Is it ok to read back a depth of 1 instead of 3 or is this something that could be fixed?
 2. Is there a way to make the interpolation algorithm able to handle this kind of DAGs?

Thanks
--
jeremy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line.geo
Type: application/octet-stream
Size: 345 bytes
Desc: cube-line.geo
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line-geo.png
Type: image/png
Size: 74330 bytes
Desc: cube-line-geo.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line.msh
Type: application/octet-stream
Size: 2354 bytes
Desc: cube-line.msh
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line-mesh.png
Type: image/png
Size: 15330 bytes
Desc: cube-line-mesh.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line-dag.vtk
Type: application/octet-stream
Size: 563 bytes
Desc: cube-line-dag.vtk
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line-vtk.png
Type: image/png
Size: 155722 bytes
Desc: cube-line-vtk.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cube-line.c
Type: text/x-csrc
Size: 1653 bytes
Desc: cube-line.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231101/721aee39/attachment-0001.bin>


More information about the petsc-users mailing list