SAMRAI::tbox::RestartManager Class Reference
#include <source/toolbox/restartdb/RestartManager.h>
List of all members.
Detailed Description
Class RestartManager coordinates SAMRAI restart files (currently implemented using the HDF database class) and the objects comprising SAMRAI-based application code. The manager class orchestrates opening and closing the database, stores data to be written out for restart, and writes out the restart data to the database. Note that the restart manager is a Singleton class that acts as a single point of control for restart capabilities. As such its constructor and destructor are protected members; they are not to be called outside of this class.
The general procedure for starting a simulation from a restart file is as follows.
{enumerate}
- Open the restart file using openRestartFile("filename").
- Get root of restart database using getRootDatabase().
- Initialize simulation objects using the restart constructor for the objects.
- Close the restart file using closeRestartFile(). {enumerate}
Technically, there is no need to close the restart file because this will automatically be taken care of by the destructor for the database object.
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.
{enumerate}
- Each object that has state that needs to be saved for restart must be derived from the Serializable class (which responds to the putToDatabase() method).
- Any object that needs to save its state to the restart file must be registered with the restart manager using the registerRestartItem() method. NOTE THAT NO TWO RESTARTABLE OBJECTS ARE ALLOWED TO HAVE THE SAME NAME STRING IDENTIFIER.
- The patchdata to be written to restart need to be specified using the VariableDatabase::setPatchdataForRestart() method. This is usually taken care of by the numerical algorithm object. {enumerate}
When all these items are accounted for, writing to the restart file is accomplished using a writeRestartFile() method. There are two writeRestartFile() methods available. One takes only a restart directory name as an argument whereas the other takes both a restart directory name and a restore number for its arguments. See comments for member functions for more details.
- See also:
- tbox::Database
Constructor & Destructor Documentation
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. |
Member Function Documentation
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 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] |
|
Pointer< Database > SAMRAI::tbox::RestartManager::getRootDatabase |
( |
|
) |
[inline, virtual] |
|
|
Returns a Pointer to the root of the database. |
void SAMRAI::tbox::RestartManager::registerRestartItem |
( |
const 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 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 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 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::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. |
The documentation for this class was generated from the following files:
Generated on Fri Dec 2 11:33:34 2005 for SAMRAI by
1.4.2