#include <source/hierarchy/variables/LocallyActiveVariableDatabase.h>
This class uses the VariableDatabase directly and provides most of the operations available in that class through the interface declared here. However, support for locally-active data is more limited than in the standard case. For example, this class does not support registration of locally-active variables with VariableContexts and each variable can be associated with only one patch data index. That is, there is a one-to-one mapping between variables and patch data indices and associating multiple VariableContexts with a variable is not allowed. To make usage of this class reasonably transparent, all member functions are similar to the analogous operations in the VariableDatabase.
To avoid potentially improper, or unexpected, behavior, all locally-active variables should be registered with and managed using operations provided by this class. Standard variable registration and variable management operations should use the VariableDatabase class.
This class provides "manager" objects to define which patches are active on each level for each locally-active variable; see the declaration of LocallyActiveDataPatchLevelManager below.
SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::LocallyActiveVariableDatabase | ( | ) | [protected] |
The constructor for LocallyActiveVariableDatabase<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.
SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::~LocallyActiveVariableDatabase | ( | ) | [protected, virtual] |
The destructor for LocallyActiveVariableDatabase<DIM> is protected. See the comments for the constructor.
The destructor deallocates database contents.
LocallyActiveVariableDatabase< DIM > * SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getDatabase | ( | ) | [static] |
Return a pointer to the singleton instance of this locally-active variable database. All access to the LocallyActiveVariableDatabase<DIM> object is through the getDatabase() function. For example, to access the variable with string name "my_variable", use the following call: LocallyActiveVariableDatabase<DIM>::getVariable()->getVariable("my_variable").
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.
void SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::freeDatabase | ( | ) | [static] |
Deallocate the LocallyActiveVariableDatabase<DIM> instance. It is not necessary to call this function at program termination, since it is automatically called by the ShutdownRegistry class.
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getNumberOfRegisteredVariables | ( | ) | const [virtual] |
Return number of variables registered with the locally-active variable database.
tbox::Pointer< PatchDescriptor< DIM > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getPatchDescriptor | ( | ) | const |
Return pointer to the patch descriptor managed by the database (and shared by all patches in an SAMR hierarchy).
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::registerVariable | ( | const tbox::Pointer< hier::Variable< DIM > > | variable, | |
const hier::IntVector< DIM > & | ghosts | |||
) |
Rgister the given variable and ghost cell width with the database of locally-active variables. This function is similar to the variable registration member functions in the VariableDatabase<DIM> class, but is more restrictive here since each variable can be registered with only one patch data index. This function imposes the same restrictions on uniqueness of variable names as the VariableDatabase<DIM> base class.
Typically, this function will generate a new patch descriptor index for the variable and ghost cell width and add the variable-ghost cell width pair and index to the database. If the variable-ghost cell width pair is already mapped to some patch data identifier in the database, then that index will be returned and the function will do nothing. However, if the variable-ghost cell width pair is already mapped to some patch data identifier with a different ghost cell width, the program will abort with a descriptive error message.
variable | const pointer to variable to add to database. | |
ghosts | const reference to IntVector indicating ghost cell width of variable patch data. |
tbox::Pointer< hier::Variable< DIM > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getVariable | ( | const std::string & | name | ) | const |
Get variable in locally-active database with given name string identifier.
name | Const reference to name string identifying the variable. |
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariableExists | ( | const std::string & | name | ) | const |
Check if variable with given name has been registered with the locally-active variable database.
name | string name of variable to retrieve. |
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariableExists | ( | const tbox::Pointer< hier::Variable< DIM > > | variable | ) | const |
Check if given variable has been registered with the locally-active variable database.
variable | smart pointer to variable to check whether it is in database. When assertion checking is active, an assertion will result when the variable pointer is null. |
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariablePatchDataIndex | ( | const tbox::Pointer< Variable< DIM > > | variable, | |
int | data_id | |||
) | const |
Check whether the given variable matches the patch data index in the locally-active variable database.
variable | tbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion will result if the variable pointer is null. | |
data_id | Integer patch data identifier. When assertion checking is active, an unrecoverable assertion will result if the value is an invalid identifier (either < 0 or larger than the maximum allowed patch data id). |
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariablePatchDataIndexType | ( | const tbox::Pointer< hier::Variable< DIM > > | variable, | |
int | data_id | |||
) | const [virtual] |
Check whether the given variable matches the patch data type associated with the given patch data index in the locally-active variable database.
variable | tbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion will result if the variable pointer is null. | |
data_id | Integer patch data index. When assertion checking is active, an unrecoverable assertion will result the value is an invalid identifier (either < 0 or larger than the maximum allowed patch data id). |
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::mapVariableToIndex | ( | const tbox::Pointer< hier::Variable< DIM > > | variable | ) | const |
Map variable in locally-active variable database to patch data index.
variable | tbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion results if the variable pointer is null. |
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::mapIndexToVariable | ( | int | data_id, | |
tbox::Pointer< hier::Variable< DIM > > & | variable | |||
) | const |
Map patch data index to variable, if index is associated with a variable registered with the locally-active variable database.
data_id | Integer patch data identifier. When assertion checking is active, an unrecoverable assertion will if the index is invalid (i.e., < 0). | |
variable | tbox::Pointer to variable that maps to patch data index in database. If there is no patch data index in the database matching the index input value, then the variable pointer is set to null. |
tbox::Pointer< hier::LocallyActiveDataPatchLevelManager< DIM > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getLocallyActiveDataPatchLevelManager | ( | const tbox::Pointer< hier::PatchLevel< DIM > > | level | ) |
Return level manager in the database that maintains active patch data information for the input level, if possible. Note that this database class only maintains level manager objects corresponding to patch levels that live in a patch hierarchy. Also, the number of the patch level for each corresponding manager must be unique. Thus, the following results are possible when this method is called:
level | const patch level pointer. |
void SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::resetLocallyActiveDataPatchLevelManager | ( | const tbox::Pointer< hier::PatchLevel< DIM > > | level | ) |
Reset the level manager in the database that maintains active patch data information for the given level, if possible. Note that this database class only maintains level manager objects corresponding to patch levels that live in a patch hierarchy. Thus, if the input level does not live in a hierarchy, this method does nothing. Also, the number of the patch level for each corresponding manager must be unique. Thus, if the database owns a level manager associated with a patch level whose number matches the input level, the existing manager is removed from the database and is replaced with a new manager object for the given level. However, if one has a smart pointer to the pre-existing level manager, one can maintain that while resetting the one in the database as long as the pointer reference count remains greater than zero.
level | const patch level pointer. |
void SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::printClassData | ( | std::ostream & | os = tbox::plog |
) | const [virtual] |
Print all variable, context, and patch descriptor information contained in the database to the specified output stream. Active patch information for the patch hierarchy is also printed by dumping the contents of the locally-active patch data level manager objects.
os | Optional output stream. If not given, tbox::plog is used. |
friend class LocallyActiveDataPatchLevelIterator< DIM > [friend] |