Actual source code: ex13.c

  1: static char help[] = "Create a Plex Schwarz P surface with quads\n\n";

  3: #include <petscdmplex.h>

  5: int main(int argc, char **argv)
  6: {
  7:   DM             dm;
  8:   PetscInt       extent[3] = {1, 1, 1}, refine = 0, layers = 0, three;
  9:   PetscReal      thickness   = 0.;
 10:   PetscBool      distribute  = PETSC_TRUE;
 11:   DMBoundaryType periodic[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
 12:   DMPlexTPSType  tps_type    = DMPLEX_TPS_SCHWARZ_P;

 14:   PetscFunctionBeginUser;
 15:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 16:   PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "Schwarz P Example", NULL);
 17:   PetscCall(PetscOptionsIntArray("-extent", "Number of replicas for each of three dimensions", NULL, extent, (three = 3, &three), NULL));
 18:   PetscCall(PetscOptionsInt("-refine", "Number of refinements", NULL, refine, &refine, NULL));
 19:   PetscCall(PetscOptionsEnumArray("-periodic", "Periodicity in each of three dimensions", NULL, DMBoundaryTypes, (PetscEnum *)periodic, (three = 3, &three), NULL));
 20:   PetscCall(PetscOptionsBool("-distribute", "Distribute TPS manifold prior to refinement and extrusion", NULL, distribute, &distribute, NULL));
 21:   PetscCall(PetscOptionsInt("-layers", "Number of layers in volumetric extrusion (or zero to not extrude)", NULL, layers, &layers, NULL));
 22:   PetscCall(PetscOptionsReal("-thickness", "Thickness of volumetric extrusion", NULL, thickness, &thickness, NULL));
 23:   PetscCall(PetscOptionsEnum("-tps_type", "Type of triply-periodic surface", NULL, DMPlexTPSTypes, (PetscEnum)tps_type, (PetscEnum *)&tps_type, NULL));
 24:   PetscOptionsEnd();
 25:   PetscCall(DMPlexCreateTPSMesh(PETSC_COMM_WORLD, tps_type, extent, periodic, distribute, refine, layers, thickness, &dm));
 26:   PetscCall(PetscObjectSetName((PetscObject)dm, "TPS"));
 27:   PetscCall(DMViewFromOptions(dm, NULL, "-dm_view"));
 28:   PetscCall(DMDestroy(&dm));
 29:   PetscCall(PetscFinalize());
 30:   return 0;
 31: }

 33: /*TEST

 35:   test:
 36:     suffix: 0
 37:     args: -extent 1,2,3 -dm_view -refine 0
 38:   test:
 39:     suffix: 1
 40:     args: -extent 2,3,1 -dm_view -refine 1

 42:   test:
 43:     suffix: gyroid_0
 44:     args: -extent 1,2,3 -dm_view -refine 0 -tps_type gyroid
 45:   test:
 46:     suffix: gyroid_1
 47:     args: -extent 2,3,1 -dm_view -refine 1 -tps_type gyroid
 48:   test:
 49:     suffix: extrude_0
 50:     args: -extent 2,3,1 -dm_view -refine 0 -layers 3 -thickness .2
 51:   test:
 52:     suffix: extrude_1_dist
 53:     nsize: 2
 54:     args: -extent 2,1,1 -dm_view -refine 1 -layers 3 -thickness .2

 56: TEST*/