1 static char help[] = "Read in a mesh and test whether it is valid\n\n"; 2 3 #include <petscdmplex.h> 4 #if defined(PETSC_HAVE_CGNS) 5 #undef I /* Very old CGNS stupidly uses I as a variable, which fails when using complex. Curse you idiot package managers */ 6 #include <cgnslib.h> 7 #endif 8 #if defined(PETSC_HAVE_EXODUSII) 9 #include <exodusII.h> 10 #endif 11 12 static PetscErrorCode zero(PetscInt dim, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) 13 { 14 PetscInt i; 15 for (i = 0; i < Nc; ++i) u[i] = 0.0; 16 return 0; 17 } 18 19 static PetscErrorCode CreateMesh(MPI_Comm comm, DM *dm) 20 { 21 PetscFunctionBeginUser; 22 PetscCall(DMCreate(comm, dm)); 23 PetscCall(DMSetType(*dm, DMPLEX)); 24 PetscCall(DMSetFromOptions(*dm)); 25 PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view")); 26 PetscFunctionReturn(0); 27 } 28 29 int main(int argc, char **argv) 30 { 31 DM dm; 32 DMLabel label; 33 const PetscInt id = 1; 34 35 PetscCall(PetscInitialize(&argc, &argv, NULL,help)); 36 PetscCall(CreateMesh(PETSC_COMM_WORLD, &dm)); 37 PetscCall(DMSetNumFields(dm, 1)); 38 PetscCall(DMGetLabel(dm, "boundary", &label)); 39 PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void)) zero, NULL, NULL, NULL)); 40 PetscCall(DMDestroy(&dm)); 41 PetscCall(PetscFinalize()); 42 return 0; 43 } 44 45 /*TEST 46 47 testset: 48 args: -dm_plex_boundary_label boundary -dm_plex_check_all 49 # CGNS meshes 0-1 50 test: 51 suffix: 0 52 requires: cgns 53 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/tut21.cgns 54 test: 55 suffix: 1 56 requires: cgns 57 TODO: broken 58 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/grid_c.cgns 59 # Gmsh meshes 2-4 60 test: 61 suffix: 2 62 requires: double 63 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/doublet-tet.msh 64 test: 65 suffix: 3 66 requires: double 67 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square.msh 68 test: 69 suffix: 4 70 requires: double 71 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square_bin.msh 72 # Exodus meshes 5-9 73 test: 74 suffix: 5 75 requires: exodusii 76 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/sevenside-quad.exo 77 test: 78 suffix: 6 79 requires: exodusii 80 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/sevenside-quad-15.exo 81 test: 82 suffix: 7 83 requires: exodusii 84 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/squaremotor-30.exo 85 test: 86 suffix: 8 87 requires: exodusii 88 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/blockcylinder-50.exo 89 test: 90 suffix: 9 91 requires: exodusii 92 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/simpleblock-100.exo 93 94 TEST*/ 95