xref: /petsc/src/ts/tutorials/ex28.c (revision 98d129c30f3ee9fdddc40fdbc5a989b7be64f888)
1 static char help[] = "Loads a previously saved TS.";
2 
3 /*
4    It loads a TS saved with TSView()
5 
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>
13 
14 int main(int argc, char **argv)
15 {
16   TS          ts; /* timestepping context */
17   PetscViewer viewer;
18 
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 }
35