1 static const char help[] = "Tests for regular refinement"; 2 3 /* TODO 4 - Add in simplex-to-hex tests 5 */ 6 7 #include <petscdmplex.h> 8 #include <petscsf.h> 9 10 #include <petsc/private/dmpleximpl.h> 11 12 typedef struct { 13 DMPolytopeType refCell; /* Use the reference cell */ 14 PetscInt dim; /* The topological dimension */ 15 PetscBool simplex; /* Flag for simplices */ 16 } AppCtx; 17 18 static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) 19 { 20 PetscErrorCode ierr; 21 22 PetscFunctionBeginUser; 23 options->refCell = DM_POLYTOPE_UNKNOWN; 24 options->dim = 2; 25 options->simplex = PETSC_TRUE; 26 27 ierr = PetscOptionsBegin(comm, "", "Parallel Mesh Orientation Options", "DMPLEX");CHKERRQ(ierr); 28 ierr = PetscOptionsInt("-dim", "The topological dimension", "ex40.c", options->dim, &options->dim, NULL);CHKERRQ(ierr); 29 ierr = PetscOptionsEnum("-ref_cell", "Use the reference cell", "ex40.c", DMPolytopeTypes, (PetscEnum) options->refCell, (PetscEnum *) &options->refCell, NULL);CHKERRQ(ierr); 30 ierr = PetscOptionsBool("-simplex", "Flag for simplices", "ex40.c", options->simplex, &options->simplex, NULL);CHKERRQ(ierr); 31 ierr = PetscOptionsEnd(); 32 PetscFunctionReturn(0); 33 } 34 35 static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *ctx, DM *dm) 36 { 37 PetscErrorCode ierr; 38 39 PetscFunctionBegin; 40 if (ctx->refCell != DM_POLYTOPE_UNKNOWN) { 41 ierr = DMPlexCreateReferenceCellByType(comm, ctx->refCell, dm);CHKERRQ(ierr); 42 } else { 43 ierr = DMPlexCreateBoxMesh(comm, ctx->dim, ctx->simplex, NULL, NULL, NULL, NULL, PETSC_TRUE, dm);CHKERRQ(ierr); 44 } 45 ierr = DMSetFromOptions(*dm);CHKERRQ(ierr); 46 ierr = DMViewFromOptions(*dm, NULL, "-dm_view");CHKERRQ(ierr); 47 PetscFunctionReturn(0); 48 } 49 50 int main(int argc, char **argv) 51 { 52 DM dm; 53 AppCtx ctx; 54 PetscErrorCode ierr; 55 56 ierr = PetscInitialize(&argc, &argv, NULL, help); if (ierr) return ierr; 57 ierr = ProcessOptions(PETSC_COMM_WORLD, &ctx);CHKERRQ(ierr); 58 ierr = CreateMesh(PETSC_COMM_WORLD, &ctx, &dm);CHKERRQ(ierr); 59 ierr = DMDestroy(&dm);CHKERRQ(ierr); 60 ierr = PetscFinalize(); 61 return ierr; 62 } 63 64 /*TEST 65 test: 66 suffix: ref_tri 67 args: -ref_cell triangle -dm_refine 2 -dm_plex_check_all 68 69 test: 70 suffix: box_tri 71 nsize: {{1 3 5}} 72 args: -dm_plex_box_faces 3,3 -dm_refine 2 -dm_plex_check_all 73 74 test: 75 suffix: ref_quad 76 args: -ref_cell quadrilateral -dm_refine 2 -dm_plex_check_all 77 78 test: 79 suffix: box_quad 80 nsize: {{1 3 5}} 81 args: -dm_plex_box_faces 3,3 -simplex 0 -dm_refine 2 -dm_plex_check_all 82 83 test: 84 suffix: ref_tet 85 args: -ref_cell tetrahedron -dm_refine 2 -dm_plex_check_all 86 87 test: 88 suffix: box_tet 89 nsize: {{1 3 5}} 90 args: -dim 3 -dm_plex_box_faces 3,3,3 -dm_refine 2 -dm_plex_check_all 91 92 test: 93 suffix: ref_hex 94 args: -ref_cell hexahedron -simplex 0 -dm_refine 2 -dm_plex_check_all 95 96 test: 97 suffix: box_hex 98 nsize: {{1 3 5}} 99 args: -dim 3 -dm_plex_box_faces 3,3,3 -simplex 0 -dm_refine 2 -dm_plex_check_all 100 101 test: 102 suffix: ref_trip 103 args: -ref_cell "triangular prism" -dm_refine 2 -dm_plex_check_all 104 105 test: 106 suffix: ref_tquad 107 args: -ref_cell "tensor quad" -dm_refine 2 -dm_plex_check_all 108 109 test: 110 suffix: ref_ttrip 111 args: -ref_cell "tensor triangular prism" -dm_refine 2 -dm_plex_check_all 112 113 test: 114 suffix: ref_tquadp 115 args: -ref_cell "tensor quadrilateral prism" -dm_refine 2 -dm_plex_check_all 116 117 test: 118 suffix: ref_tri_tohex 119 args: -ref_cell triangle -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 120 121 test: 122 suffix: box_tri_tohex 123 nsize: {{1 3 5}} 124 args: -dm_plex_box_faces 3,3 -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 125 126 test: 127 suffix: ref_tet_tohex 128 args: -ref_cell tetrahedron -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 129 130 test: 131 suffix: box_tet_tohex 132 nsize: {{1 3 5}} 133 args: -dim 3 -dm_plex_box_faces 3,3,3 -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 134 135 test: 136 suffix: ref_trip_tohex 137 args: -ref_cell "triangular prism" -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 138 139 test: 140 suffix: ref_ttrip_tohex 141 args: -ref_cell "tensor triangular prism" -dm_plex_cell_refiner tohex -dm_refine 2 -dm_plex_check_all 142 143 TEST*/ 144