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 CHKERRQ(DMCreate(comm, dm)); 23 CHKERRQ(DMSetType(*dm, DMPLEX)); 24 CHKERRQ(DMSetFromOptions(*dm)); 25 CHKERRQ(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 PetscErrorCode ierr; 35 36 ierr = PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr; 37 CHKERRQ(CreateMesh(PETSC_COMM_WORLD, &dm)); 38 CHKERRQ(DMSetNumFields(dm, 1)); 39 CHKERRQ(DMGetLabel(dm, "boundary", &label)); 40 CHKERRQ(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void)) zero, NULL, NULL, NULL)); 41 CHKERRQ(DMDestroy(&dm)); 42 ierr = PetscFinalize(); 43 return ierr; 44 } 45 46 /*TEST 47 48 testset: 49 args: -dm_plex_boundary_label boundary -dm_plex_check_all 50 # CGNS meshes 0-1 51 test: 52 suffix: 0 53 requires: cgns 54 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/tut21.cgns 55 test: 56 suffix: 1 57 requires: cgns 58 TODO: broken 59 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/grid_c.cgns 60 # Gmsh meshes 2-4 61 test: 62 suffix: 2 63 requires: double 64 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/doublet-tet.msh 65 test: 66 suffix: 3 67 requires: double 68 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square.msh 69 test: 70 suffix: 4 71 requires: double 72 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square_bin.msh 73 # Exodus meshes 5-9 74 test: 75 suffix: 5 76 requires: exodusii 77 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/sevenside-quad.exo 78 test: 79 suffix: 6 80 requires: exodusii 81 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/sevenside-quad-15.exo 82 test: 83 suffix: 7 84 requires: exodusii 85 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/squaremotor-30.exo 86 test: 87 suffix: 8 88 requires: exodusii 89 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/blockcylinder-50.exo 90 test: 91 suffix: 9 92 requires: exodusii 93 args: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/simpleblock-100.exo 94 95 TEST*/ 96