1 static char help[] = "Tests for coarsening\n\n"; 2 3 #include <petscdmplex.h> 4 5 typedef struct { 6 PetscBool uninterpolate; /* Uninterpolate the mesh at the end */ 7 } AppCtx; 8 9 PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) { 10 PetscFunctionBegin; 11 options->uninterpolate = PETSC_FALSE; 12 13 PetscOptionsBegin(comm, "", "Meshing Problem Options", "DMPLEX"); 14 PetscCall(PetscOptionsBool("-uninterpolate", "Uninterpolate the mesh at the end", "ex14.c", options->uninterpolate, &options->uninterpolate, NULL)); 15 PetscOptionsEnd(); 16 PetscFunctionReturn(0); 17 } 18 19 PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm) { 20 PetscFunctionBegin; 21 PetscCall(DMCreate(comm, dm)); 22 PetscCall(DMSetType(*dm, DMPLEX)); 23 PetscCall(DMSetFromOptions(*dm)); 24 PetscCall(DMViewFromOptions(*dm, NULL, "-orig_dm_view")); 25 if (user->uninterpolate) { 26 DM udm = NULL; 27 28 PetscCall(DMPlexUninterpolate(*dm, &udm)); 29 PetscCall(DMDestroy(dm)); 30 *dm = udm; 31 PetscCall(DMViewFromOptions(*dm, NULL, "-un_dm_view")); 32 } 33 PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view")); 34 PetscFunctionReturn(0); 35 } 36 37 int main(int argc, char **argv) { 38 DM dm; 39 AppCtx user; 40 41 PetscFunctionBeginUser; 42 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 43 PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); 44 PetscCall(CreateMesh(PETSC_COMM_WORLD, &user, &dm)); 45 PetscCall(DMDestroy(&dm)); 46 PetscCall(PetscFinalize()); 47 return 0; 48 } 49 50 /*TEST 51 test: 52 suffix: 0 53 requires: triangle 54 args: -dm_view -dm_refine 1 -dm_coarsen -dm_plex_check_symmetry -dm_plex_check_skeleton -dm_plex_check_faces 55 56 TEST*/ 57