Actual source code: ex1.c

  1: static char help[] = "Create and view a forest mesh\n\n";

  3: #include <petscdmforest.h>
  4: #include <petscdmplex.h>

  6: int main(int argc, char **argv)
  7: {
  8:   DM          dm;
  9:   char        typeString[256] = {'\0'};
 10:   PetscViewer viewer          = NULL;
 11:   PetscBool   conv            = PETSC_FALSE;

 13:   PetscFunctionBeginUser;
 14:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 15:   PetscCall(DMCreate(PETSC_COMM_WORLD, &dm));
 16:   PetscCall(PetscStrncpy(typeString, DMFOREST, 256));
 17:   PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "DM Forest example options", NULL);
 18:   PetscCall(PetscOptionsString("-dm_type", "The type of the dm", NULL, DMFOREST, typeString, sizeof(typeString), NULL));
 19:   PetscCall(PetscOptionsBool("-test_convert", "Test conversion to DMPLEX", NULL, conv, &conv, NULL));
 20:   PetscOptionsEnd();
 21:   PetscCall(DMSetType(dm, (DMType)typeString));
 22:   PetscCall(DMSetFromOptions(dm));
 23:   PetscCall(DMSetUp(dm));
 24:   PetscCall(DMViewFromOptions(dm, NULL, "-dm_view"));
 25:   PetscCall(PetscViewerDestroy(&viewer));
 26:   if (conv) {
 27:     DM dmConv;

 29:     PetscCall(DMConvert(dm, DMPLEX, &dmConv));
 30:     PetscCall(DMLocalizeCoordinates(dmConv));
 31:     PetscCall(DMViewFromOptions(dmConv, NULL, "-dm_conv_view"));
 32:     PetscCall(DMPlexCheckCellShape(dmConv, PETSC_FALSE, PETSC_DETERMINE));
 33:     PetscCall(DMDestroy(&dmConv));
 34:   }
 35:   PetscCall(DMDestroy(&dm));
 36:   PetscCall(PetscFinalize());
 37:   return 0;
 38: }

 40: /*TEST

 42:       test:
 43:         output_file: output/empty.out
 44:         suffix: p4est_topology_moebius
 45:         nsize: 3
 46:         args: -dm_type p4est -dm_forest_topology moebius -dm_view vtk:moebius.vtu
 47:         requires: p4est !complex

 49:       test:
 50:         output_file: output/empty.out
 51:         suffix: p4est_topology_moebius_convert
 52:         nsize: 3
 53:         args: -dm_type p4est -dm_forest_topology moebius -test_convert -dm_conv_view vtk:moebiusconv.vtu
 54:         requires: p4est !complex

 56:       test:
 57:         output_file: output/empty.out
 58:         suffix: p4est_topology_shell
 59:         nsize: 3
 60:         args: -dm_type p8est -dm_forest_topology shell -dm_view vtk:shell.vtu
 61:         requires: p4est !complex

 63:       test:
 64:         TODO: broken
 65:         output_file: output/empty.out
 66:         suffix: p4est_topology_shell_convert
 67:         nsize: 3
 68:         args: -dm_type p8est -dm_forest_topology shell -test_convert -dm_conv_view vtk:shellconv.vtu
 69:         requires: p4est !complex

 71:       test:
 72:         TODO: broken
 73:         output_file: output/empty.out
 74:         suffix: p4est_topology_sphere_convert
 75:         nsize: 3
 76:         args: -dm_type p8est -dm_forest_topology sphere -dm_view vtk:sphere.vtu -dm_forest_initial_refinement 1 -dm_forest_maximum_refinement 1 -test_convert -dm_conv_view vtk:sphereconv.vtu
 77:         requires: p4est !complex

 79:       test:
 80:         output_file: output/empty.out
 81:         suffix: p4est_topology_brick
 82:         nsize: 3
 83:         args: -dm_type p8est -dm_forest_topology brick -dm_p4est_brick_size 2,3,5 -dm_view vtk:brick.vtu
 84:         requires: p4est !complex

 86:       test:
 87:         output_file: output/ex1_brick_periodic_glvis.out
 88:         suffix: p4est_topology_brick_periodic_glvis
 89:         args: -dm_type p8est -dm_forest_topology brick -dm_p4est_brick_size 3,4,5 -dm_p4est_brick_periodicity 0,1,0 -test_convert -dm_conv_view glvis:
 90:         requires: p4est

 92:       test:
 93:         output_file: output/empty.out
 94:         suffix: p4est_topology_brick_periodic_2d
 95:         nsize: 3
 96:         args: -dm_type p4est -dm_forest_topology brick -dm_p4est_brick_size 5,6 -dm_p4est_brick_periodicity 1,0 -test_convert -dm_forest_initial_refinement 0 -dm_forest_maximum_refinement 2 -dm_p4est_refine_pattern hash
 97:         requires: p4est

 99:       test:
100:         output_file: output/empty.out
101:         suffix: p4est_topology_brick_periodic_3d
102:         nsize: 3
103:         args: -dm_type p8est -dm_forest_topology brick -dm_p4est_brick_size 5,6,1 -dm_p4est_brick_periodicity 0,1,0 -test_convert -dm_forest_initial_refinement 0 -dm_forest_maximum_refinement 2 -dm_p4est_refine_pattern hash
104:         requires: p4est

106: TEST*/