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