1c4762a1bSJed Brown static char help[] = "Create and view a forest mesh\n\n";
2c4762a1bSJed Brown
3c4762a1bSJed Brown #include <petscdmforest.h>
4c4762a1bSJed Brown #include <petscdmplex.h>
5c4762a1bSJed Brown #include <petscoptions.h>
6c4762a1bSJed Brown
main(int argc,char ** argv)7d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv)
8d71ae5a4SJacob Faibussowitsch {
9c4762a1bSJed Brown DM dm;
10c4762a1bSJed Brown char typeString[256] = {'\0'};
11c4762a1bSJed Brown PetscViewer viewer = NULL;
12c4762a1bSJed Brown PetscBool conv = PETSC_FALSE;
13c4762a1bSJed Brown
14327415f7SBarry Smith PetscFunctionBeginUser;
159566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc, &argv, NULL, help));
169566063dSJacob Faibussowitsch PetscCall(DMCreate(PETSC_COMM_WORLD, &dm));
179566063dSJacob Faibussowitsch PetscCall(PetscStrncpy(typeString, DMFOREST, 256));
18d0609cedSBarry Smith PetscOptionsBegin(PETSC_COMM_WORLD, NULL, "DM Forest example options", NULL);
199566063dSJacob Faibussowitsch PetscCall(PetscOptionsString("-dm_type", "The type of the dm", NULL, DMFOREST, typeString, sizeof(typeString), NULL));
209566063dSJacob Faibussowitsch PetscCall(PetscOptionsBool("-test_convert", "Test conversion to DMPLEX", NULL, conv, &conv, NULL));
21d0609cedSBarry Smith PetscOptionsEnd();
229566063dSJacob Faibussowitsch PetscCall(DMSetType(dm, (DMType)typeString));
239566063dSJacob Faibussowitsch PetscCall(DMSetFromOptions(dm));
249566063dSJacob Faibussowitsch PetscCall(DMSetUp(dm));
259566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(dm, NULL, "-dm_view"));
269566063dSJacob Faibussowitsch PetscCall(PetscViewerDestroy(&viewer));
27c4762a1bSJed Brown if (conv) {
28c4762a1bSJed Brown DM dmConv;
29c4762a1bSJed Brown
309566063dSJacob Faibussowitsch PetscCall(DMConvert(dm, DMPLEX, &dmConv));
319566063dSJacob Faibussowitsch PetscCall(DMLocalizeCoordinates(dmConv));
329566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(dmConv, NULL, "-dm_conv_view"));
339566063dSJacob Faibussowitsch PetscCall(DMPlexCheckCellShape(dmConv, PETSC_FALSE, PETSC_DETERMINE));
349566063dSJacob Faibussowitsch PetscCall(DMDestroy(&dmConv));
35c4762a1bSJed Brown }
369566063dSJacob Faibussowitsch PetscCall(DMDestroy(&dm));
379566063dSJacob Faibussowitsch PetscCall(PetscFinalize());
38b122ec5aSJacob Faibussowitsch return 0;
39c4762a1bSJed Brown }
40c4762a1bSJed Brown
41c4762a1bSJed Brown /*TEST
42c4762a1bSJed Brown
43c4762a1bSJed Brown test:
44*3886731fSPierre Jolivet output_file: output/empty.out
45c4762a1bSJed Brown suffix: p4est_topology_moebius
46c4762a1bSJed Brown nsize: 3
47c4762a1bSJed Brown args: -dm_type p4est -dm_forest_topology moebius -dm_view vtk:moebius.vtu
48c4762a1bSJed Brown requires: p4est !complex
49c4762a1bSJed Brown
50c4762a1bSJed Brown test:
51*3886731fSPierre Jolivet output_file: output/empty.out
52c4762a1bSJed Brown suffix: p4est_topology_moebius_convert
53c4762a1bSJed Brown nsize: 3
54c4762a1bSJed Brown args: -dm_type p4est -dm_forest_topology moebius -test_convert -dm_conv_view vtk:moebiusconv.vtu
55c4762a1bSJed Brown requires: p4est !complex
56c4762a1bSJed Brown
57c4762a1bSJed Brown test:
58*3886731fSPierre Jolivet output_file: output/empty.out
59c4762a1bSJed Brown suffix: p4est_topology_shell
60c4762a1bSJed Brown nsize: 3
61c4762a1bSJed Brown args: -dm_type p8est -dm_forest_topology shell -dm_view vtk:shell.vtu
62c4762a1bSJed Brown requires: p4est !complex
63c4762a1bSJed Brown
64c4762a1bSJed Brown test:
65c4762a1bSJed Brown TODO: broken
66*3886731fSPierre Jolivet output_file: output/empty.out
67c4762a1bSJed Brown suffix: p4est_topology_shell_convert
68c4762a1bSJed Brown nsize: 3
69c4762a1bSJed Brown args: -dm_type p8est -dm_forest_topology shell -test_convert -dm_conv_view vtk:shellconv.vtu
70c4762a1bSJed Brown requires: p4est !complex
71c4762a1bSJed Brown
72c4762a1bSJed Brown test:
73c4762a1bSJed Brown TODO: broken
74*3886731fSPierre Jolivet output_file: output/empty.out
75c4762a1bSJed Brown suffix: p4est_topology_sphere_convert
76c4762a1bSJed Brown nsize: 3
77c4762a1bSJed Brown 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
78c4762a1bSJed Brown requires: p4est !complex
79c4762a1bSJed Brown
80c4762a1bSJed Brown test:
81*3886731fSPierre Jolivet output_file: output/empty.out
82c4762a1bSJed Brown suffix: p4est_topology_brick
83c4762a1bSJed Brown nsize: 3
84c4762a1bSJed Brown args: -dm_type p8est -dm_forest_topology brick -dm_p4est_brick_size 2,3,5 -dm_view vtk:brick.vtu
85c4762a1bSJed Brown requires: p4est !complex
86c4762a1bSJed Brown
87c4762a1bSJed Brown test:
88c4762a1bSJed Brown output_file: output/ex1_brick_periodic_glvis.out
89c4762a1bSJed Brown suffix: p4est_topology_brick_periodic_glvis
90c4762a1bSJed Brown 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:
91c4762a1bSJed Brown requires: p4est
92c4762a1bSJed Brown
93c4762a1bSJed Brown test:
94*3886731fSPierre Jolivet output_file: output/empty.out
95c4762a1bSJed Brown suffix: p4est_topology_brick_periodic_2d
96c4762a1bSJed Brown nsize: 3
97c4762a1bSJed Brown 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
98c4762a1bSJed Brown requires: p4est
99c4762a1bSJed Brown
100c4762a1bSJed Brown test:
101*3886731fSPierre Jolivet output_file: output/empty.out
102c4762a1bSJed Brown suffix: p4est_topology_brick_periodic_3d
103c4762a1bSJed Brown nsize: 3
104c4762a1bSJed Brown 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
105c4762a1bSJed Brown requires: p4est
106c4762a1bSJed Brown
107c4762a1bSJed Brown TEST*/
108