Actual source code: ex28.c

  1: static char help[] = "Loads a previously saved TS.";

  3: /*
  4:    It loads a TS saved with TSView()

  6: */
  7: /*
  8:     Include "petscts.h" to use the PETSc timestepping routines. Note that
  9:     this file automatically includes "petscsys.h" and other lower-level
 10:     PETSc include files.
 11: */
 12: #include <petscts.h>

 14: int main(int argc, char **argv)
 15: {
 16:   TS          ts; /* timestepping context */
 17:   PetscViewer viewer;

 19:   PetscFunctionBeginUser;
 20:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 21:   PetscCall(PetscDLLibraryAppend(PETSC_COMM_WORLD, &PetscDLLibrariesLoaded, "advection-diffusion-reaction/ex1"));
 22:   PetscCall(TSCreate(PETSC_COMM_WORLD, &ts));
 23:   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, "advection-diffusion-reaction/binaryoutput", FILE_MODE_READ, &viewer));
 24:   PetscCall(TSLoad(ts, viewer));
 25:   PetscCall(PetscViewerDestroy(&viewer));
 26:   /* PetscCall(PetscFPTView(0)); */
 27:   PetscCall(TSSetFromOptions(ts));
 28:   PetscCall(TSSetUp(ts));
 29:   PetscCall(TSView(ts, PETSC_VIEWER_STDOUT_WORLD));
 30:   PetscCall(TSSolve(ts, NULL));
 31:   PetscCall(TSDestroy(&ts));
 32:   PetscCall(PetscFinalize());
 33:   return 0;
 34: }