IBAMR  IBAMR version 0.19.
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SAMRAI::tbox::RestartManager Class Reference

#include <tbox/RestartManager.h>

Classes

struct  RestartItem
 

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< DatabasegetRootDatabase ()
 
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 RestartManagergetManager ()
 
static void freeManager ()
 

Protected Member Functions

 RestartManager ()
 
virtual ~RestartManager ()
 
void registerSingletonSubclassInstance (RestartManager *subclass_instance)
 

Private Member Functions

virtual void writeRestartFile (Pointer< Database > database)
 
std::string createDirs (const std::string &root_dirname, int restore_num)
 

Private Attributes

List< RestartManager::RestartItemd_restart_items_list
 
Pointer< Databased_database_root
 
Pointer< DatabaseFactoryd_database_factory
 
bool d_is_from_restart
 

Static Private Attributes

static RestartManagers_manager_instance
 
static bool s_registered_callback
 

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.

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.

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

◆ RestartManager()

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.

◆ ~RestartManager()

virtual SAMRAI::tbox::RestartManager::~RestartManager ( )
protectedvirtual

The destructor for the restart manager is protected, since only the singleton class and subclasses may destroy the manager objects.

Member Function Documentation

◆ getManager()

static 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.

◆ freeManager()

static 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.

◆ isFromRestart()

virtual bool SAMRAI::tbox::RestartManager::isFromRestart ( )
virtual

Returns true if the run is from a restart file (i.e. a restart file has been opened from main()). Returns false otherwise.

◆ openRestartFile()

virtual 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.

◆ closeRestartFile()

virtual void SAMRAI::tbox::RestartManager::closeRestartFile ( )
virtual

Closes the restart file.

◆ getRootDatabase()

virtual Pointer<Database> SAMRAI::tbox::RestartManager::getRootDatabase ( )
virtual

Returns a Pointer to the root of the database.

◆ setRootDatabase()

virtual void SAMRAI::tbox::RestartManager::setRootDatabase ( Pointer< Database database)
virtual

Sets the database for restore or dumps.

◆ setDatabaseFactory()

virtual void SAMRAI::tbox::RestartManager::setDatabaseFactory ( Pointer< DatabaseFactory database_factory)
virtual

Sets the database for restore or dumps.

◆ registerRestartItem()

virtual 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.

◆ unregisterRestartItem()

virtual 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.

◆ clearRestartItems()

virtual void SAMRAI::tbox::RestartManager::clearRestartItems ( )
virtual

Clear all restart items managed by the restart manager.

◆ writeRestartFile() [1/3]

virtual void SAMRAI::tbox::RestartManager::writeRestartFile ( const std::string &  root_dirname)
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.

◆ writeRestartFile() [2/3]

virtual 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.

◆ writeRestartToDatabase()

virtual void SAMRAI::tbox::RestartManager::writeRestartToDatabase ( )
virtual

Write all objects registered to as restart objects to the restart database.

◆ registerSingletonSubclassInstance()

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.

◆ writeRestartFile() [3/3]

virtual void SAMRAI::tbox::RestartManager::writeRestartFile ( Pointer< Database database)
privatevirtual

Write all objects registered to as restart objects to the restart database.

◆ createDirs()

std::string SAMRAI::tbox::RestartManager::createDirs ( const std::string &  root_dirname,
int  restore_num 
)
private

Member Data Documentation

◆ s_manager_instance

RestartManager* SAMRAI::tbox::RestartManager::s_manager_instance
staticprivate

◆ s_registered_callback

bool SAMRAI::tbox::RestartManager::s_registered_callback
staticprivate

◆ d_restart_items_list

List< RestartManager::RestartItem > SAMRAI::tbox::RestartManager::d_restart_items_list
private

◆ d_database_root

Pointer<Database> SAMRAI::tbox::RestartManager::d_database_root
private

◆ d_database_factory

Pointer<DatabaseFactory> SAMRAI::tbox::RestartManager::d_database_factory
private

◆ d_is_from_restart

bool SAMRAI::tbox::RestartManager::d_is_from_restart
private

The documentation for this class was generated from the following file: