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