[petsc-users] DMPlex periodic face coordinates

Matteo Semplice matteo.semplice at uninsubria.it
Wed May 15 11:07:26 CDT 2024


Il 14/05/24 15:02, Matthew Knepley ha scritto:
> On Tue, May 14, 2024 at 12:14 AM Matteo Semplice 
> <matteo.semplice at uninsubria.it> wrote:
>
>     Dear petsc-users, I am playing with DMPlexGetCellCoordinates and
>     observing that it returns correct periodic coordinates for cells,
>     but not for faces. More precisely, adding
>     PetscCall(DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd)); for
>     ZjQcmQRYFpfptBannerStart
>     This Message Is From an External Sender
>     This message came from outside your organization.
>     ZjQcmQRYFpfptBannerEnd
>
>     Dear petsc-users,
>
>         I am playing with DMPlexGetCellCoordinates and observing that
>     it returns correct periodic coordinates for cells, but not for faces.
>
>     More precisely, adding
>
>     PetscCall(DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd));
>         for (f = fStart; f < fEnd; ++f) {
>           const PetscScalar *array;
>           PetscScalar       *x = NULL;
>           PetscInt           ndof;
>           PetscBool          isDG;
>
>           PetscCall(DMPlexGetCellCoordinates(dm, f, &isDG, &ndof,
>     &array, &x));
>           PetscCheck(ndof % cdim == 0, PETSC_COMM_SELF,
>     PETSC_ERR_ARG_INCOMP, "ndof not divisible by cdim");
>           PetscCall(PetscPrintf(PETSC_COMM_SELF, "Face #%"
>     PetscInt_FMT " coordinates\n", f - fStart));
>           for (PetscInt i = 0; i < ndof; i += cdim)
>     PetscCall(PetscScalarView(cdim, &x[i], PETSC_VIEWER_STDOUT_SELF));
>           PetscCall(DMPlexRestoreCellCoordinates(dm, f, &isDG, &ndof,
>     &array, &x));
>         }
>
>     to src/dm/impls/plex/tutorials/ex8.c, I get
>
>     $ ./ex8 -dm_plex_dim 2 -petscspace_degree 1 -dm_plex_simplex 0
>     -dm_plex_box_faces 3,2 -dm_plex_box_bd periodic,none -dm_view
>     -view_coord
>     DM Object: box 1 MPI process
>       type: plex
>     box in 2 dimensions:
>       Number of 0-cells per rank: 9
>       Number of 1-cells per rank: 15
>       Number of 2-cells per rank: 6
>     Periodic mesh (PERIODIC, NONE) coordinates localized
>
>     [...]
>
>     Element #2 coordinates
>      0:   6.6667e-01   0.0000e+00
>      0:   1.0000e+00   0.0000e+00 <<<----- correct
>      0:   1.0000e+00   5.0000e-01
>      0:   6.6667e-01   5.0000e-01
>     [...]
>
>     Face #0 coordinates
>      0:   0.0000e+00   0.0000e+00
>      0:   3.3333e-01   0.0000e+00
>     Face #1 coordinates
>      0:   3.3333e-01   0.0000e+00
>      0:   6.6667e-01   0.0000e+00
>     Face #2 coordinates
>      0:   6.6667e-01   0.0000e+00
>      0:   0.0000e+00   0.0000e+00  <<<---- should be (0.66,0.00) and
>     (1.00,0.00)
>
>     Is there a way to recover correct periodic coordinates in the case
>     of periodic DMPLex?
>
> The way that periodic coordinates work is that it stores a DG 
> coordinate field by cell. Faces default back to the vertices. You 
> could think about  also putting DG coordinates on faces, but no one 
> had asked, and it is potentially expensive.
>
> If you really need them to keep going, face coordinates can be 
> extracted from cell coordinates. Otherwise, I can do it after the 
> PETSc Meeting. Or, we are happy to take contributions adding this.

Hi.

I mainly wanted to check that this was expected and not a result of a 
setup of my DM. No need to change Petsc now except maybe issuing a 
warning if the fallback to continuous coordinates will give wrong 
results. As for my code, I think I can extract the info from the cell 
coordinates in a pre-processing phase and if this crazy FV methods I am 
implementing will survive for long enough, I'll think about contributing.

Just to double-check, can I assume that the order in which 
DMPlexGetCellCoordinates returns the coordinates matches the ordering of 
vertices in DMPlexGetCone for the uninterpolated DM, right?

Best

     Matteo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240515/d54b9a7f/attachment-0001.html>


More information about the petsc-users mailing list