1 static char help[] = "Create and view a forest mesh\n\n"; 2 3 #include <petscdmforest.h> 4 #include <petscdmplex.h> 5 #include <petscoptions.h> 6 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; 13 PetscErrorCode ierr; 14 15 ierr = PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr; 16 ierr = DMCreate(PETSC_COMM_WORLD, &dm);CHKERRQ(ierr); 17 ierr = PetscStrncpy(typeString,DMFOREST,256);CHKERRQ(ierr); 18 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"DM Forest example options",NULL);CHKERRQ(ierr); 19 ierr = PetscOptionsString("-dm_type","The type of the dm",NULL,DMFOREST,typeString,sizeof(typeString),NULL);CHKERRQ(ierr); 20 ierr = PetscOptionsBool("-test_convert","Test conversion to DMPLEX",NULL,conv,&conv,NULL);CHKERRQ(ierr); 21 ierr = PetscOptionsEnd();CHKERRQ(ierr); 22 ierr = DMSetType(dm,(DMType) typeString);CHKERRQ(ierr); 23 ierr = DMSetFromOptions(dm);CHKERRQ(ierr); 24 ierr = DMSetUp(dm);CHKERRQ(ierr); 25 ierr = DMViewFromOptions(dm,NULL,"-dm_view");CHKERRQ(ierr); 26 ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 27 if (conv) { 28 DM dmConv; 29 30 ierr = DMConvert(dm,DMPLEX,&dmConv);CHKERRQ(ierr); 31 ierr = DMLocalizeCoordinates(dmConv);CHKERRQ(ierr); 32 ierr = DMViewFromOptions(dmConv,NULL,"-dm_conv_view");CHKERRQ(ierr); 33 ierr = DMPlexCheckCellShape(dmConv,PETSC_FALSE,PETSC_DETERMINE);CHKERRQ(ierr); 34 ierr = DMDestroy(&dmConv);CHKERRQ(ierr); 35 } 36 ierr = DMDestroy(&dm);CHKERRQ(ierr); 37 ierr = PetscFinalize(); 38 return ierr; 39 } 40 41 /*TEST 42 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 49 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 56 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 63 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 71 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 79 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 86 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 92 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 99 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 106 107 TEST*/ 108