[petsc-users] storing many petsc objects in a single file

Smith, Barry F. bsmith at mcs.anl.gov
Sun Nov 26 07:49:12 CST 2017


  Storm,

   Specifically for TS there is an abstract object called TSTrajectory which is a way to store histories of simulations (it is used by TSAdjoint but also useable for other purposes). It has several ways to store histories and more can be added.

   One draw back to saving everything in PETSc binary in one file is that we don't have simple support for random access of a particular vector.

   You can also store to HDF5 format and some others that may be useful for you:


   Barry


> On Nov 26, 2017, at 2:27 AM, Jose E. Roman <jroman at dsic.upv.es> wrote:
> 
> 
> 
>> 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