1 static char help[] = "Tests DMPlexCreateBoxMesh().\n\n"; 2 3 #include <petscdmplex.h> 4 5 typedef struct { 6 PetscBool sparseLocalize; /* Only localize coordinates where necessary */ 7 } AppCtx; 8 9 PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) 10 { 11 PetscFunctionBegin; 12 options->sparseLocalize = PETSC_TRUE; 13 PetscOptionsBegin(comm, "", "DMPlexCreateBoxMesh() Test Options", "DMPLEX"); 14 PetscCall(PetscOptionsBool("-sparse_localize", "Only localize coordinates where necessary", "ex43.c", options->sparseLocalize, &options->sparseLocalize, NULL)); 15 PetscOptionsEnd(); 16 PetscFunctionReturn(PETSC_SUCCESS); 17 } 18 19 int main(int argc, char **argv) 20 { 21 DM dm; 22 const PetscInt faces[2] = {3, 1}; 23 DMBoundaryType periodicity[2] = {DM_BOUNDARY_PERIODIC, DM_BOUNDARY_NONE}; 24 AppCtx user; 25 26 PetscFunctionBeginUser; 27 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 28 PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); 29 PetscCall(DMPlexCreateBoxMesh(PETSC_COMM_WORLD, 2, PETSC_FALSE, faces, NULL, NULL, periodicity, PETSC_TRUE, 0, user.sparseLocalize, &dm)); 30 PetscCall(PetscObjectSetName((PetscObject)dm, "ExampleBoxMesh")); 31 PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); 32 PetscCall(DMDestroy(&dm)); 33 PetscCall(PetscFinalize()); 34 return 0; 35 } 36 37 /*TEST 38 39 test: 40 suffix: 0 41 args: -sparse_localize 0 -dm_view ascii::ascii_info_detail 42 43 test: 44 suffix: 1 45 args: -sparse_localize 1 -dm_view ascii::ascii_info_detail 46 47 TEST*/ 48