Actual source code: ex13.c

  1: static char help[] = "Tests loading DM vector from file.\n\n";

  3: /*
  4:     ex14.c writes out the DMDA and vector read by this program.
  5: */

  7: #include <petscdmda.h>

  9: int main(int argc, char **argv)
 10: {
 11:   PetscInt    M = PETSC_DECIDE, N = PETSC_DECIDE;
 12:   DM          da;
 13:   Vec         global;
 14:   PetscViewer bviewer;

 16:   PetscFunctionBeginUser;
 17:   PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
 18:   PetscCall(PetscOptionsGetInt(NULL, NULL, "-M", &M, NULL));
 19:   PetscCall(PetscOptionsGetInt(NULL, NULL, "-N", &N, NULL));

 21:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, "daoutput", FILE_MODE_READ, &bviewer));
 22:   PetscCall(DMCreate(PETSC_COMM_WORLD, &da));

 24:   PetscCall(DMLoad(da, bviewer));
 25:   PetscCall(DMCreateGlobalVector(da, &global));
 26:   PetscCall(VecLoad(global, bviewer));
 27:   PetscCall(PetscViewerDestroy(&bviewer));

 29:   PetscCall(VecView(global, PETSC_VIEWER_DRAW_WORLD));

 31:   /* Free memory */
 32:   PetscCall(VecDestroy(&global));
 33:   PetscCall(DMDestroy(&da));
 34:   PetscCall(PetscFinalize());
 35:   return 0;
 36: }