Il 07/08/26 16:16, Matthew Knepley ha scritto:
On Fri, Jul 31, 2026 at 6:28 AM Matteo Semplice via petsc-users
<[email protected]> wrote:
Dear PETSc,
I do not understand the behaviour of DMPlexGetCellCoordinates
on a
Plex generated to a periodic MSH mesh.
I have in the code
DM dmMesh;
PetscCall( DMCreate(MPI_COMM_WORLD, &dmMesh) );
PetscCall( DMSetType(dmMesh, DMPLEX) );
PetscCall( DMSetFromOptions(dmMesh) );
and pass the option
-dm_plex_filename periodiccube.msh
to load a periodic mesh of tetrahedra for the unit cube.
When calling DMPlexGetCellCoordinates on 3d elements (cells), I
get DG
coordinates (independently on passing or not -dm_localize)
But when calling DMPlexGetCellCoordinates on 1d or 2d elements (edges
and faces), I DO NOT get DG coordinates (independently on passing
or not
-dm_localize).
I can work around this, but is there a way to have DG coordinates
also
for intermediate elements in the Plex? I see an option in
DMCreateBoxMesh, but no options for loaded meshes.
The intention is for -dm_localize_height to work. Does that work for you?
I finally got round to testing this properly.
First, yes, passing -dm_localize_height 2 does indeed localize edges in
3d and getting the endpoint coordinates from GetCellCoordinates(edge)
fixes some issues in my code.
Nevertheless, there is still something I do not understand on this
point. It appears that the cells containing a given edge with a vertex
on the periodic boundary might be "localized" in different ways: as a
result if I try instead to extract the edge coordinates from the
GetCellCoordinates(cell), I get strange results.
Here below is the output of my demo code for edge 335 of my periodic
mesh on the unit cube. The first output is from getting coordinates from
the edge, the rest is from the localized coordinates of the various
cells having edge 335 in their closure:
$ ./testPeriodic -dm_plex_filename ../mesh/cuboperiodic.msh -show 335
-dm_localize -dm_localize_height 2
Authorization required, but no authorization protocol specified
Mesh with 100 cells
Plex point 335 has 2 vertices and has DG coordinates:
( 0.476, 0.495, 0.524 )
( 0.375, 0, 0.625 )
and has tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 7, goes from ( 0.476, 0.495,
0.524) to ( 0.375, 0.000, 0.625), has tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 8, goes from ( 0.375, 0.000,
0.625)to ( 0.476, 0.495, 0.524), has flipped tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 19, goes from ( 0.476, 0.495,
0.524) to ( 0.375, 0.000, 0.625), has tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 20, goes from *( 0.375, 1.000,
0.625)*to ( 0.476, 0.495, 0.524), has flipped tg *(-0.192, 0.963, 0.192*)
Edge 335, from CellCoordinates of cell 23, goes from ( 0.375, 0.000,
0.625)to ( 0.476, 0.495, 0.524), has flipped tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 34, goes from *( 0.375, 1.000,
0.625)*to ( 0.476, 0.495, 0.524), has flipped tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 35, goes from *( 0.375, 1.000,
0.625) *to ( 0.476, 0.495, 0.524), has flipped tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 37, goes from ( 0.476, 0.495,
0.524) to *( 0.375, 1.000, 0.625)*, has tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 38, goes from ( 0.375, 0.000,
0.625)to ( 0.476, 0.495, 0.524), has flipped tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 42, goes from ( 0.476, 0.495,
0.524) to *( 0.375, 1.000, 0.625)*, has tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 43, goes from ( 0.476, 0.495,
0.524) to *( 0.375, 1.000, 0.625)*, has tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 46, goes from ( 0.476, 0.495,
0.524) to *( 0.375, 1.000, 0.625)*, has tg *(-0.192, 0.963, 0.192)*
Edge 335, from CellCoordinates of cell 48, goes from ( 0.476, 0.495,
0.524) to ( 0.375, 0.000, 0.625), has tg (-0.195,-0.961, 0.195)
Edge 335, from CellCoordinates of cell 56, goes from ( 0.476, 0.495,
0.524) to( 0.375, 0.000, 0.625), has tg (-0.195,-0.961, 0.195)
I would expect that if edge 335 is localized with an endpoint on y=0,
then all cells having edge 335 in their closure localize their
coordinates in such a way that that vertex is always on y=0.
However, in my output above, the endpoint of the cell edge corresponding
to 335 is sometimes on y=0 and some other times on y=1.
Is this the intended/expected behaviour?
(If I remember correctly I cannot attach files here, so I will post code
and mesh on petsc-maint)
Best
Matteo