xref: /petsc/src/dm/tests/ex13.c (revision ebead697dbf761eb322f829370bbe90b3bd93fa3)
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   PetscFunctionBeginUser;
18   PetscCall(PetscInitialize(&argc,&argv,(char*)0,help));
19   PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL));
20   PetscCall(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL));
21 
22   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,"daoutput",FILE_MODE_READ,&bviewer));
23   PetscCall(DMCreate(PETSC_COMM_WORLD,&da));
24 
25   PetscCall(DMLoad(da,bviewer));
26   PetscCall(DMCreateGlobalVector(da,&global));
27   PetscCall(VecLoad(global,bviewer));
28   PetscCall(PetscViewerDestroy(&bviewer));
29 
30   PetscCall(VecView(global,PETSC_VIEWER_DRAW_WORLD));
31 
32   /* Free memory */
33   PetscCall(VecDestroy(&global));
34   PetscCall(DMDestroy(&da));
35   PetscCall(PetscFinalize());
36   return 0;
37 }
38