DUNE-FEM (unstable)

Checkpointing

Classes

class  Dune::Fem::CheckPointer< GridImp >
 Implementation of the IOInterface. This class manages checkpointing. More...
 
class  Dune::Fem::PersistentObject
 base class for persistent objects More...
 
class  Dune::Fem::PersistenceManager
 class with singleton instance managing all persistent objects More...
 
class  Dune::Fem::AutoPersistentObject
 base class for auto persistent objects More...
 

Detailed Description

The Dune::Fem::PersistenceManager manages a list of persistent object the state should be recovered during a restart process. The singleton instance is available using persistenceManager.

Variables of any type can be added to the manager using operator<< and removed through operator>>. For general types the state is written to an ascii file persistentobjects through the call to PersistenceManager::backup(path).

Finer control is available for user defined classes by deriving these from the Dune::PersistentObject class and implementing the virtual functions backup and restore. Values can then either be written to the ascii file persistentobjects using the method Dune::Fem::PersistenceManager::backupValue giving a token and the value to store (a structure simular to the Dune::Parameter files is used). If data is to be written to a different stream a unique filename can be obtained from the Dune::PersistenceManager using the uniqueFileName method.

If a class is derived from Dune::AutoPersistenceObject then instances of this class are automatically added to the PersistenceManager on construction and removed on destruction; again the virtual methods backup/restore must be provided.

The restart process is activated through the method restore. Note that care must be taken to add the objects in exactly the same order when using the PersistenceManager for creating the backup file as when used to restore the saved states.

The Dune::Fem::Parameter class is automatically backuped and restored. For the restore process the saved parameter file is read first and existing values for parameters are replaced by these values. Therefore it is possible to reread the state of a variable orignally defined through a run time parameter using the Parameter class:

class A : public Dune::AutoPersistentObject {
int var_,b_;
ComplexType U_;
A() : var_(Dune::Parameter::getValue("token",0,var_) {}
virtual backup() const {
// note var_ is saved in the parameter file
// write b to ascii file
PersistenceManager::backupValue("b",b);
// write U to stream
ofstream out((PersistenceManager::uniqueFileName()+"classA").c_str());
U.write(out);
}
virtual restore() {
// set var_ through parameter file
var_= Dune::Parameter::getValue<int>("token",var_);
// read b from ascii file
PersistenceManager::restoreValue("b",b);
// read U from stream
ifstream in((PersistenceManager::uniqueFileName()+"classA").c_str());
U.read(in);
}
};
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 20, 23:30, 2024)