xref: /petsc/src/dm/tests/ex13.c (revision ffa8c5705e8ab2cf85ee1d14dbe507a6e2eb5283)
1 
2 static char help[] = "Tests loading DM vector from file.\n\n";
3 
4 /*
5     ex14.c writes out the DMDA and vector read by this program.
6 */
7 
8 #include <petscdmda.h>
9 
10 int main(int argc,char **argv)
11 {
12   PetscInt       M = PETSC_DECIDE,N = PETSC_DECIDE;
13   DM             da;
14   Vec            global;
15   PetscViewer    bviewer;
16 
17   PetscCall(PetscInitialize(&argc,&argv,(char*)0,help));
18   PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL));
19   PetscCall(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL));
20 
21   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,"daoutput",FILE_MODE_READ,&bviewer));
22   PetscCall(DMCreate(PETSC_COMM_WORLD,&da));
23 
24   PetscCall(DMLoad(da,bviewer));
25   PetscCall(DMCreateGlobalVector(da,&global));
26   PetscCall(VecLoad(global,bviewer));
27   PetscCall(PetscViewerDestroy(&bviewer));
28 
29   PetscCall(VecView(global,PETSC_VIEWER_DRAW_WORLD));
30 
31   /* Free memory */
32   PetscCall(VecDestroy(&global));
33   PetscCall(DMDestroy(&da));
34   PetscCall(PetscFinalize());
35   return 0;
36 }
37