#include <source/toolbox/restartdb/RestartManager.h>
Public Member Functions | |
virtual bool | isFromRestart () |
virtual bool | openRestartFile (const std::string &root_dirname, const int restore_num, const int num_nodes) |
virtual void | closeRestartFile () |
virtual Pointer< Database > | getRootDatabase () |
virtual void | setRootDatabase (Pointer< Database > database) |
virtual void | setDatabaseFactory (Pointer< DatabaseFactory > database_factory) |
virtual void | registerRestartItem (const std::string &name, Serializable *obj) |
virtual void | unregisterRestartItem (const std::string &name) |
virtual void | clearRestartItems () |
virtual void | writeRestartFile (const std::string &root_dirname) |
virtual void | writeRestartFile (const std::string &root_dirname, const int restore_num) |
virtual void | writeRestartToDatabase () |
Static Public Member Functions | |
static RestartManager * | getManager () |
static void | freeManager () |
Protected Member Functions | |
RestartManager () | |
virtual | ~RestartManager () |
void | registerSingletonSubclassInstance (RestartManager *subclass_instance) |
The general procedure for starting a simulation from a restart file is as follows.
It is important to note in the initialization process, some objects will need to be constructed in the "empty" state and filled in later using some sort of getFromDatabase() method.
The process for writing out state to a restart file is somewhat more complicated. The following things need to be taken care of.
SAMRAI::tbox::RestartManager::RestartManager | ( | ) | [protected] |
The constructor for RestartManager is protected. Consistent with the definition of a Singleton class, only the manager object has access to the constructor for the class.
The constructor for RestartManager initializes the root data base to a NullDatabase and sets the restart flag to false.
SAMRAI::tbox::RestartManager::~RestartManager | ( | ) | [inline, protected, virtual] |
The destructor for the restart manager is protected, since only the singleton class and subclasses may destroy the manager objects.
RestartManager * SAMRAI::tbox::RestartManager::getManager | ( | ) | [static] |
Return a pointer to the single instance of the restart manager. All access to the restart manager object is through getManager().
Note that when the manager is accessed for the first time, the Singleton instance is registered with the ShutdownRegistry class which destroys such objects at program completion. Thus, users of this class do not explicitly allocate or deallocate the Singleton instance.
void SAMRAI::tbox::RestartManager::freeManager | ( | ) | [static] |
Deallocate the restart manager instance. It is not necessary to call this routine at program termination, since it is automatically called by the ShutdownRegistry class.
bool SAMRAI::tbox::RestartManager::isFromRestart | ( | ) | [inline, virtual] |
Returns true if the run is from a restart file (i.e. a restart file has been opened from main()). Returns false otherwise.
bool SAMRAI::tbox::RestartManager::openRestartFile | ( | const std::string & | root_dirname, | |
const int | restore_num, | |||
const int | num_nodes | |||
) | [virtual] |
Attempts to mount, for reading, the restart file for the processor. If there is no error opening the file, then the restart manager mounts the restart file. Returns true if open is successful; false otherwise.
void SAMRAI::tbox::RestartManager::closeRestartFile | ( | ) | [virtual] |
Closes the restart file.
Returns a Pointer to the root of the database.
void SAMRAI::tbox::RestartManager::setRootDatabase | ( | Pointer< Database > | database | ) | [inline, virtual] |
Sets the database for restore or dumps.
void SAMRAI::tbox::RestartManager::setDatabaseFactory | ( | Pointer< DatabaseFactory > | database_factory | ) | [inline, virtual] |
Sets the database for restore or dumps.
void SAMRAI::tbox::RestartManager::registerRestartItem | ( | const std::string & | name, | |
Serializable * | obj | |||
) | [virtual] |
Registers an object for restart with the given name.
When assertion checking is active, an unrecoverable exception will result if either the string is empty or the serializable object pointer is null.
void SAMRAI::tbox::RestartManager::unregisterRestartItem | ( | const std::string & | name | ) | [virtual] |
Removes the object with the specified name from the list of restartable items.
When assertion checking is active, an unrecoverable exception will result if the string is empty.
void SAMRAI::tbox::RestartManager::clearRestartItems | ( | ) | [virtual] |
Clear all restart items managed by the restart manager.
void SAMRAI::tbox::RestartManager::writeRestartFile | ( | const std::string & | root_dirname | ) | [inline, virtual] |
Write all objects registered to as restart objects to the restart database. The string argument is the name of the root of restart directory.
Note: This method creates/uses a restart directory structure with 00000 as the restore number.
void SAMRAI::tbox::RestartManager::writeRestartFile | ( | const std::string & | root_dirname, | |
const int | restore_num | |||
) | [virtual] |
Write all objects registered to as restart objects to the restart database. The string argument is the name of the root of restart directory. The integer argument is the identification number associated with the restart files generated.
void SAMRAI::tbox::RestartManager::writeRestartToDatabase | ( | ) | [virtual] |
Write all objects registered to as restart objects to the restart database.
void SAMRAI::tbox::RestartManager::registerSingletonSubclassInstance | ( | RestartManager * | subclass_instance | ) | [protected] |
Initialize Singleton instance with instance of subclass. This function is used to make the singleton object unique when inheriting from this base class.