Actual source code: ex2.c

  1: static char help[] = "Read in a mesh and test whether it is valid\n\n";

  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

 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: }

 19: static PetscErrorCode CreateMesh(MPI_Comm comm, DM *dm)
 20: {

 24:   DMCreate(comm, dm);
 25:   DMSetType(*dm, DMPLEX);
 26:   DMSetFromOptions(*dm);
 27:   DMViewFromOptions(*dm, NULL, "-dm_view");
 28:   return(0);
 29: }

 31: int main(int argc, char **argv)
 32: {
 33:   DM             dm;
 34:   DMLabel        label;
 35:   const PetscInt id = 1;

 38:   PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
 39:   CreateMesh(PETSC_COMM_WORLD, &dm);
 40:   DMSetNumFields(dm, 1);
 41:   DMGetLabel(dm, "boundary", &label);
 42:   DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void)) zero, NULL, NULL, NULL);
 43:   DMDestroy(&dm);
 44:   PetscFinalize();
 45:   return ierr;
 46: }

 48: /*TEST

 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

 97: TEST*/