[petsc-users] storing many petsc objects in a single file
Jose E. Roman
jroman at dsic.upv.es
Sun Nov 26 02:27:45 CST 2017
> El 26 nov 2017, a las 2:25, Storm Weiner <stormweiner at berkeley.edu> escribió:
>
> Hey there,
>
> For simulations, its useful to store the history as a series of state vectors. For simulations with many time-steps it can get annoying to store each state vector as a separate file. It would be useful if there were some way to manage a database of petsc vectors. To save the current time-step, append the state vector to the database. To restart a simulation, load the corresponding state vector out of the database.
>
> Is there a standard way to do this in PETSc?
>
> Thanks,
> Storm
In the command line, you can use the “append” option for the viewer. For instance in the MFN solver in SLEPc you can do this:
$ ./ex23 -mfn_view_solution binary:vectors.bin::append
It will save one vector in each call to MFNSolve(), and all vectors will be stored in the same file ‘vectors.bin’.
Alternatively, in the source code you can use PetscViewerBinaryOpen() to open the viewer, then save as many vectors as you want with VecView(), and finally close the file with PetscViewerDestroy(). Use VecLoad() to load the vectors.
Jose
More information about the petsc-users
mailing list