Actual source code: ex1.c
petsc-3.8.4 2018-03-24
1: static char help[] = "Create and view a forest mesh\n\n";
3: #include <petscdmforest.h>
4: #include <petscoptions.h>
6: int main(int argc, char **argv)
7: {
8: DM dm;
9: char typeString[256] = {'\0'};
10: PetscViewer viewer = NULL;
11: PetscBool flg;
14: PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
15: DMCreate(PETSC_COMM_WORLD, &dm);
16: PetscStrncpy(typeString,DMFOREST,256);
17: PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"DM Forest example options",NULL);
18: PetscOptionsString("-dm_type","The type of the dm",NULL,DMFOREST,typeString,sizeof(typeString),NULL);
19: PetscOptionsEnd();
20: DMSetType(dm,(DMType) typeString);
21: DMSetFromOptions(dm);
22: DMSetUp(dm);
23: PetscOptionsGetViewer(PETSC_COMM_WORLD,NULL,"-dm_view",&viewer,NULL,&flg);
24: if (flg) {
25: DMView(dm,viewer);
26: }
27: PetscViewerDestroy(&viewer);
28: DMDestroy(&dm);
29: PetscFinalize();
30: return ierr;
31: }