#include <source/hierarchy/variables/VariableDatabase.h>
Inheritance diagram for SAMRAI::hier::VariableDatabase< DIM >:
Public Member Functions | |
virtual tbox::Pointer< hier::PatchDescriptor< DIM > > | getPatchDescriptor () const |
virtual tbox::Pointer< hier::VariableContext > | getContext (const string &name) |
virtual bool | checkContextExists (const string &name) const |
virtual void | addVariable (const tbox::Pointer< hier::Variable< DIM > > variable) |
virtual tbox::Pointer< hier::Variable< DIM > > | getVariable (const string &name) const |
virtual bool | checkVariableExists (const string &name) const |
virtual int | registerClonedPatchDataIndex (const tbox::Pointer< hier::Variable< DIM > > variable, int old_id) |
virtual int | registerPatchDataIndex (const tbox::Pointer< hier::Variable< DIM > > variable, int data_id=-1) |
virtual void | removePatchDataIndex (int data_id) |
virtual bool | checkVariablePatchDataIndex (const tbox::Pointer< hier::Variable< DIM > > variable, int data_id) |
virtual int | registerVariableAndContext (const tbox::Pointer< hier::Variable< DIM > > variable, const tbox::Pointer< hier::VariableContext > context, const hier::IntVector< DIM > &ghosts=hier::IntVector< DIM >(0)) |
virtual int | mapVariableAndContextToIndex (const tbox::Pointer< hier::Variable< DIM > > variable, const tbox::Pointer< hier::VariableContext > context) const |
virtual bool | mapIndexToVariable (const int index, tbox::Pointer< hier::Variable< DIM > > &variable) const |
virtual bool | mapIndexToVariableAndContext (const int index, tbox::Pointer< hier::Variable< DIM > > &variable, tbox::Pointer< hier::VariableContext > &context) const |
virtual hier::ComponentSelector | getPatchDataRestartTable () |
virtual bool | isPatchDataRegisteredForRestart (int index) |
virtual void | registerPatchDataForRestart (int index) |
virtual void | unregisterPatchDataForRestart (int index) |
void | printClassData (ostream &os=tbox::plog, bool print_only_user_defined_variables=true) const |
virtual int | makeInternalSAMRAIWorkVariablePatchDataIndex (const tbox::Pointer< hier::Variable< DIM > > variable, const hier::IntVector< DIM > &ghosts) |
virtual void | removeInternalSAMRAIWorkVariablePatchDataIndex (int data_id) |
Static Public Member Functions | |
static VariableDatabase< DIM > * | getDatabase () |
static void | freeDatabase () |
Protected Member Functions | |
VariableDatabase () | |
virtual | ~VariableDatabase () |
int | idUndefined () const |
int | getVariableId (const string &name) const |
void | registerSingletonSubclassInstance (hier::VariableDatabase< DIM > *subclass_instance) |
Since the database is a Singleton class, it serves as a globally accessible container for bookkeeping information related to variable storage on an SAMR patch hierarchy. For example, a time-dependent problem may require distinct "OLD" and "NEW" storage for some quantities. A context is a name describing some storage for a collection of variables in a given problem. Each variable and context pair maps to a unique integer patch data index. This integer indices are the same for every patch in the hierarchy and so data objects are accessed identically for all patches.
Typically, classes that contains numerical routines for patches access the appropriate data in terms of variables. Classes that provide solution algorithms manage variable storage in terms of storage "contexts", such as "OLD" and "NEW". Typical usage of the database for managing variable storage bookkeeping in this way is as follows:
Alternatively, the database can be used to maintain a map between a single patch data index and a variable that created the patch data factory at that index. Such a mapping can be constructed using the functions registerVariablePatchDataIndex() and registerClonedVariablePatchDataIndex(). These operations may be helpful when managing variables and contexts is inconvenient. However, in contrast to the functions above, these functions do not allow using a single variable to define multiple patch data indices. One may use this functionality as follows:
Note that the database can be used to allocate and free patch data indices using the registerClonedVariablePatchDataIndex() and removeVariablePatchDataIndex() functions. The registerVariableAndContext() function will also create a new patch data index when needed. In general, variables and contexts persist once create and cannot be removed from the database.
Finally, this database is used in SAMRAI to manage the reading/writing of patch data objects from/to restart files.
* Important notes: * * (1) Having two different variables or two different contexts in * the database with the same name string identifier is not allowed. * This eliminates the need to resolve ambiguities when querying the * database for variables or contexts based on string identifiers. * The error checking in this class implementation will catch * any attempt to improperly register variables and contexts and * report a descriptive log message. * * (2) It is STRONGLY recommended that variable contexts be generated by * using the getContext() function in this class. While contexts * may be created by other means and passed into the member functions * of this database class, doing so may produce unexpected results * due to potentially non-unique integer and name string context * identifiers. * *
|
The constructor for VariableDatabase<DIM> is protected. Consistent with the definition of a Singleton class, only the database object has access to the constructor for the class. The constructor initializes the state of database contents. |
|
The destructor for VariableDatabase<DIM> is protected. See the comments for the constructor. The destructor deallocates database contents. |
|
Return a pointer to the singleton instance of the variable database. All access to the VariableDatabase<DIM> object is through the getDatabase() function. For example, to access the context with string name "my_context", use the following call: VariableDatabase<DIM>::getDatabase()->getContext("my_context"). Note that when the database 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.
Reimplemented in SAMRAI::hier::LocallyActiveVariableDatabase< DIM >. |
|
Deallocate the VariableDatabase<DIM> instance. It is not necessary to call this function at program termination, since it is automatically called by the ShutdownRegistry class. |
|
Return pointer to the patch descriptor managed by the database (and shared by all patches in an SAMR hierarchy).
Reimplemented in SAMRAI::hier::LocallyActiveVariableDatabase< DIM >. |
|
Return a variable context object with the given name string identifier. If a context whose name matches the argument string exists in the database, it is returned. Otherwise, a new context is created and returned. Note that it is impossible to add two distinct variable context objects to the database with the same name. If the string identifier is empty, the context pointer return value will be null. Thus, you cannot create a variable context with an empty string identifier using this function.
|
|
Check whether context with given name exists in the database.
|
|
Add the given variable to the database. This function checks whether the variable already exists in the database, or whether a different variable exists with the same name string identifier. If the variable does not already exist in the database and its name string is distinct from all variables in the database, the variable is added to the database. Having two different variables in the database with the same name is not allowed. If this is attempted, an error message will be logged and the program will abort. If the variable already exists in the database, the routine essentially does nothing.
|
|
Get variable in database with given name string identifier.
Reimplemented in SAMRAI::hier::LocallyActiveVariableDatabase< DIM >. |
|
Check whether variable with given name exists in the database.
Reimplemented in SAMRAI::hier::LocallyActiveVariableDatabase< DIM >. |
|
Create a new patch data index by cloning the data factory for the given variable at the given index and return the patch data index of the new data location. The new index and variable pair is added to the variable database. A variable-patch data index pair generated using this function cannot be looked up using a VariableContext. Note that this function does not deallocate any patch data storage associated with the new patch data index.
|
|
Add given patch data index and variable pair to the database if not already there. If the index is unspecified (default case), the default variable factory is cloned and the variable and new index are added to the database; in this case, the patch data will have the default number of ghost cells associated with the given variable (defined by the patch data factory it generates). A variable-patch data index pair generated using this function cannot be looked up using a VariableContext. Note that this function does not allocate any patch data storage associated with the integer index.
|
|
Remove the given patch index from the variable database if it exists in the database. Also, remove the given index from the patch descriptor and remove any mapping between the index and a variable from the variable database. Note that this function does not deallocate any patch data storage associated with the integer index.
|
|
Check whether the given variable matches the type of the patch data at the given patch data index. Note this check can be performed regardless of whether the variable and data index are in the variable database and so this function does not provide information about the contents of the database.
|
|
Register variable and context pair along with the number of ghost cells required for storage with the variable database. Typically, this function will generate a new patch data index for the variable and ghost cell width and add the variable-context pair and index to the database. If the variable-context pair is already mapped to some patch data index in the database, then that index will be returned and the function will do nothing. However, if the variable-context pair is already mapped to some patch data index with a different ghost cell width, the program will abort with a descriptive error message. When the number of ghost cells is not provided (default case), a default value of zero ghosts will be used. If either the variable or the context is unknown to the database prior to calling this routine, both items will be added to the database, if possible. The constraints for the getContext() and addVariable() routines apply.
|
|
Map variable-context pair in database to patch data index. If there is no such pair in the database (either the variable does not exist, the context does not exist, or the pair has not been registered), then an invalid patch data index (i.e., < 0) is returned. Note that for this function to operate as expected, the database mapping information must have been generated using the registerVariableAndContext() function.
|
|
Map patch data index to variable associated with the data, if possible, and set the variable pointer to the variable in the database. Note that for this function to operate as expected, the database mapping information must have been generated using the registerPatchDataIndex() function, the registerClonedPatchDataIndex() function, or the makeInternalSAMRAIWorkVariablePatchDataIndex() function.
Reimplemented in SAMRAI::hier::LocallyActiveVariableDatabase< DIM >. |
|
Map patch data index to variable-context pair associated with the data, if possible, and set the variable and context pointers to the corresponding database entries. Note that for this function to operate as expected, the database mapping information must have been generated using the registerVariableAndContext() function.
|
|
Return copy of component selector that holds information about which patch data entries are written to restart.
|
|
Check whether given patch data index is registered with the database for restart.
|
|
Register the given patch data index for restart.
|
|
Unregister the given patch data index for restart.
|
|
Print variable, context, and patch descriptor information contained in the database to the specified output stream.
|
|
Register internal SAMRAI work variable and number of ghost cells with the variable database, generate and return new patch data index. Note that this routine is intended for managing internal SAMRAI work variables that are unseen by users. It should not be called by users for registering variables, or within SAMRAI for registering any user-defined variables with the variable database. This function will generate a new patch data index for the variable and ghost cell width regardless of whether the variable is already mapped to some patch data index with the given ghost cell width in the database. If the variable is unknown to the database prior to calling this routine, it will be added to the database. Note that this function does not enforce the same constrants on variable registration that are applied for registering user-defined variables. For example, this function allows duplicate variable name strings. Thus, it is the responsibility of SAMRAI developers to maintain consistency of internal work variables.
|
|
Remove the given index from the variable database if it exists in the database and is associated with an internal SAMRAI work variable registered with the function getInternalSAMRAIWorkVariablePatchDataIndex(). Also, remove the given index from the patch descriptor and remove any mapping between the index and a variable from the variable database. Note that this function does not deallocate any patch data storage associated with the integer index. Note that the given index will not be removed if is not associated with an internal SAMRAI work variable in the variable database.
|
|
Return integer value used to indicate undefined variable or context identifier. This routine is protected to allow subclasses to be consistent with this database class. |
|
Return integer identifier for first variable found matching given string name identifier, or return an undefined integer id if no such variable exists in the database. |
|
Initialize Singleton instance with instance of subclass. This function is used to make the singleton object unique when inheriting from this base class. |