Actual source code: ex9.c

petsc-3.13.6 2020-09-29
Report Typos and Errors
  1: static char help[] = "Evaluate the shape quality of a mesh\n\n";

  3:  #include <petscdmplex.h>

  5: typedef struct {
  6:   char      filename[PETSC_MAX_PATH_LEN]; /* Import mesh from file */
  7:   PetscBool report;                       /* Print a quality report */
  8:   PetscReal condLimit;                    /* Condition number limit for cell output */
  9: } AppCtx;

 11: PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
 12: {
 13:   size_t         len;

 17:   options->filename[0] = '\0';
 18:   options->report      = PETSC_FALSE;
 19:   options->condLimit   = PETSC_DETERMINE;

 21:   PetscOptionsBegin(comm, "", "Mesh Quality Evaluation Options", "DMPLEX");
 22:   PetscOptionsString("-filename", "The mesh file", "ex9.c", options->filename, options->filename, PETSC_MAX_PATH_LEN, NULL);
 23:   PetscOptionsBool("-report", "Output a mesh quality report", "ex9.c", options->report, &options->report, NULL);
 24:   PetscOptionsReal("-cond_limit", "Condition number limit for cell output", "ex9.c", options->condLimit, &options->condLimit, NULL);
 25:   PetscOptionsEnd();

 27:   PetscStrlen(options->filename, &len);
 28:   if (!len) SETERRQ(comm, PETSC_ERR_ARG_WRONG, "You must specify an input mesh using -filename");
 29:   return(0);
 30: }

 32: int main(int argc, char **argv)
 33: {
 34:   DM             dm;
 35:   AppCtx         ctx;

 38:   PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
 39:   ProcessOptions(PETSC_COMM_WORLD, &ctx);
 40:   DMPlexCreateFromFile(PETSC_COMM_WORLD, ctx.filename, PETSC_TRUE, &dm);
 41:   DMPlexCheckCellShape(dm, ctx.report, ctx.condLimit);
 42:   DMDestroy(&dm);
 43:   PetscFinalize();
 44:   return ierr;
 45: }

 47: /*TEST

 49:   test:
 50:     suffix: 0
 51:     requires: exodusii
 52:     nsize: {{1 2}}
 53:     args: -filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/blockcylinder-50.exo -report

 55:   test:
 56:     suffix: 1
 57:     args: -filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square.msh -report

 59: TEST*/