Actual source code: plexcoarsen.c
1: #include <petsc/private/dmpleximpl.h>
3: PetscErrorCode DMCoarsen_Plex(DM dm, MPI_Comm comm, DM *dmCoarsened)
4: {
5: if (!dm->coarseMesh) DMPlexCoarsen_Internal(dm, NULL, NULL, NULL, &dm->coarseMesh);
6: PetscObjectReference((PetscObject) dm->coarseMesh);
7: *dmCoarsened = dm->coarseMesh;
8: return 0;
9: }
11: PetscErrorCode DMCoarsenHierarchy_Plex(DM dm, PetscInt nlevels, DM dmCoarsened[])
12: {
13: DM rdm = dm;
14: PetscInt c;
15: PetscBool localized;
17: DMGetCoordinatesLocalized(dm, &localized);
18: for (c = nlevels-1; c >= 0; --c) {
19: DMCoarsen(rdm, PetscObjectComm((PetscObject) dm), &dmCoarsened[c]);
20: DMCopyDisc(rdm, dmCoarsened[c]);
21: if (localized) DMLocalizeCoordinates(dmCoarsened[c]);
22: DMSetCoarseDM(rdm, dmCoarsened[c]);
23: rdm = dmCoarsened[c];
24: }
25: return 0;
26: }