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>
5: #include <petscoptions.h>
7: int main(int argc, char **argv)
8: {
9: DM dm;
10: char typeString[256] = {'\0'};
11: PetscViewer viewer = NULL;
12: PetscBool conv = PETSC_FALSE;
14: PetscFunctionBeginUser;
15: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
16: PetscCall(DMCreate(PETSC_COMM_WORLD, &dm));
17: PetscCall(PetscStrncpy(typeString, DMFOREST, 256));
18: PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "DM Forest example options", NULL);
19: PetscCall(PetscOptionsString("-dm_type", "The type of the dm", NULL, DMFOREST, typeString, sizeof(typeString), NULL));
20: PetscCall(PetscOptionsBool("-test_convert", "Test conversion to DMPLEX", NULL, conv, &conv, NULL));
21: PetscOptionsEnd();
22: PetscCall(DMSetType(dm, (DMType)typeString));
23: PetscCall(DMSetFromOptions(dm));
24: PetscCall(DMSetUp(dm));
25: PetscCall(DMViewFromOptions(dm, NULL, "-dm_view"));
26: PetscCall(PetscViewerDestroy(&viewer));
27: if (conv) {
28: DM dmConv;
30: PetscCall(DMConvert(dm, DMPLEX, &dmConv));
31: PetscCall(DMLocalizeCoordinates(dmConv));
32: PetscCall(DMViewFromOptions(dmConv, NULL, "-dm_conv_view"));
33: PetscCall(DMPlexCheckCellShape(dmConv, PETSC_FALSE, PETSC_DETERMINE));
34: PetscCall(DMDestroy(&dmConv));
35: }
36: PetscCall(DMDestroy(&dm));
37: PetscCall(PetscFinalize());
38: return 0;
39: }
41: /*TEST
43: test:
44: output_file: output/ex1_moebius.out
45: suffix: p4est_topology_moebius
46: nsize: 3
47: args: -dm_type p4est -dm_forest_topology moebius -dm_view vtk:moebius.vtu
48: requires: p4est !complex
50: test:
51: output_file: output/ex1_moebius.out
52: suffix: p4est_topology_moebius_convert
53: nsize: 3
54: args: -dm_type p4est -dm_forest_topology moebius -test_convert -dm_conv_view vtk:moebiusconv.vtu
55: requires: p4est !complex
57: test:
58: output_file: output/ex1_shell.out
59: suffix: p4est_topology_shell
60: nsize: 3
61: args: -dm_type p8est -dm_forest_topology shell -dm_view vtk:shell.vtu
62: requires: p4est !complex
64: test:
65: TODO: broken
66: output_file: output/ex1_shell.out
67: suffix: p4est_topology_shell_convert
68: nsize: 3
69: args: -dm_type p8est -dm_forest_topology shell -test_convert -dm_conv_view vtk:shellconv.vtu
70: requires: p4est !complex
72: test:
73: TODO: broken
74: output_file: output/ex1_sphere.out
75: suffix: p4est_topology_sphere_convert
76: nsize: 3
77: 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
78: requires: p4est !complex
80: test:
81: output_file: output/ex1_brick.out
82: suffix: p4est_topology_brick
83: nsize: 3
84: args: -dm_type p8est -dm_forest_topology brick -dm_p4est_brick_size 2,3,5 -dm_view vtk:brick.vtu
85: requires: p4est !complex
87: test:
88: output_file: output/ex1_brick_periodic_glvis.out
89: suffix: p4est_topology_brick_periodic_glvis
90: 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:
91: requires: p4est
93: test:
94: output_file: output/ex1_brick.out
95: suffix: p4est_topology_brick_periodic_2d
96: nsize: 3
97: 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
98: requires: p4est
100: test:
101: output_file: output/ex1_brick.out
102: suffix: p4est_topology_brick_periodic_3d
103: nsize: 3
104: 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
105: requires: p4est
107: TEST*/