[petsc-users] DMPlex periodic face coordinates

Matthew Knepley knepley at gmail.com
Tue May 14 08:02:40 CDT 2024


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.

  Thanks,

     Matt

> Thanks in advance
>
> Matteo
>


-- 
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://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z9-i-9O8yBcNimBXW2alc9XHsn9MWWFwaobajlfkDcoghfrtZlVX4CRMW0BdrXaX2hOabPupZN8g9FrtoNf2$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z9-i-9O8yBcNimBXW2alc9XHsn9MWWFwaobajlfkDcoghfrtZlVX4CRMW0BdrXaX2hOabPupZN8g9HaOBe7O$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240514/6620e2f0/attachment.html>


More information about the petsc-users mailing list