IBAMR  IBAMR version 0.19.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SAMRAI::hier::LocallyActiveVariableDatabase< DIM > Class Template Reference

Class LocallyActiveVariableDatabase is a Singleton class that provides functionality for using the VariableDatabase to manage variables and data that live on different sets of patches in an AMR patch hierarchy, so-called "locally-active" data, can be managed.
More...

#include <VariableDatabase.h>

Public Member Functions

virtual int getNumberOfRegisteredVariables () const
 
tbox::Pointer< hier::PatchDescriptor< DIM > > getPatchDescriptor () const
 
int registerVariable (const tbox::Pointer< hier::Variable< DIM > > variable, const hier::IntVector< DIM > &ghosts)
 
tbox::Pointer< hier::Variable< DIM > > getVariable (const std::string &name) const
 
bool checkVariableExists (const std::string &name) const
 
bool checkVariableExists (const tbox::Pointer< hier::Variable< DIM > > variable) const
 
bool checkVariablePatchDataIndex (const tbox::Pointer< Variable< DIM > > variable, int data_id) const
 
virtual bool checkVariablePatchDataIndexType (const tbox::Pointer< hier::Variable< DIM > > variable, int data_id) const
 
int mapVariableToIndex (const tbox::Pointer< hier::Variable< DIM > > variable) const
 
bool mapIndexToVariable (int data_id, tbox::Pointer< hier::Variable< DIM > > &variable) const
 
tbox::Pointer< hier::LocallyActiveDataPatchLevelManager< DIM > > getLocallyActiveDataPatchLevelManager (const tbox::Pointer< hier::PatchLevel< DIM > > level)
 
void resetLocallyActiveDataPatchLevelManager (const tbox::Pointer< hier::PatchLevel< DIM > > level)
 
virtual void printClassData (std::ostream &os=tbox::plog) const
 

Static Public Member Functions

static LocallyActiveVariableDatabase< DIM > * getDatabase ()
 
static void freeDatabase ()
 

Protected Member Functions

 LocallyActiveVariableDatabase ()
 
virtual ~LocallyActiveVariableDatabase ()
 

Private Member Functions

bool validLevel (const tbox::Pointer< hier::PatchLevel< DIM > > level) const
 
const hier::LocallyActiveDataPatchLevelManager< DIM > * getLevelManager (const hier::PatchLevel< DIM > &pl) const
 
const hier::LocallyActiveDataPatchLevelManager< DIM > * getLevelManager (const hier::PatchLevel< DIM > *pl) const
 

Private Attributes

hier::VariableDatabase< DIM > * d_variable_database
 
int d_num_registered_variables
 
tbox::Pointer< hier::VariableContextd_locally_active_context
 
hier::ComponentSelector d_locally_active_patch_data_ids
 
tbox::Array< tbox::Pointer< hier::LocallyActiveDataPatchLevelManager< DIM > > > d_patch_level_active_data_manager
 

Static Private Attributes

static LocallyActiveVariableDatabase< DIM > * s_locally_active_variable_database_instance
 
static bool s_registered_callback
 
static int s_patchlevel_array_alloc_size
 

Friends

class LocallyActiveDataPatchLevelIterator< DIM >
 

Detailed Description

template<int DIM>
class SAMRAI::hier::LocallyActiveVariableDatabase< DIM >

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.

See also
hier::VariableDatabase
hier::PatchDescriptor
hier::LocallyActiveDataPatchLevelManager

Constructor & Destructor Documentation

◆ LocallyActiveVariableDatabase()

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.

◆ ~LocallyActiveVariableDatabase()

template<int DIM>
virtual SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::~LocallyActiveVariableDatabase ( )
protectedvirtual

The destructor for LocallyActiveVariableDatabase<DIM> is protected. See the comments for the constructor.

The destructor deallocates database contents.

Member Function Documentation

◆ getDatabase()

template<int DIM>
static 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.

Returns
Bare pointer to variable database instance.

◆ freeDatabase()

template<int DIM>
static 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.

◆ getNumberOfRegisteredVariables()

template<int DIM>
virtual int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getNumberOfRegisteredVariables ( ) const
virtual

Return number of variables registered with the locally-active variable database.

◆ getPatchDescriptor()

template<int DIM>
tbox::Pointer< hier::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).

Returns
tbox::Pointer to patch descriptor instance.

◆ registerVariable()

template<int DIM>
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.

Returns
integer patch descriptor index corresponding to storage for variable.
Parameters
variableconst pointer to variable to add to database.
ghostsconst reference to IntVector indicating ghost cell width of variable patch data.

When assertion checking is active, an assertion will result when the variable pointer is null, or if the ghost width vector has a negative entry.

◆ getVariable()

template<int DIM>
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.

Returns
tbox::Pointer to variable in database with given name. If no such variable exists, a null pointer is returned. In particular, if the variable exists in the VariableDatabase instance, but is not registered as locally-active, then a null pointer is returned.
Parameters
nameConst reference to name string identifying the variable.

◆ checkVariableExists() [1/2]

template<int DIM>
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.

Returns
boolean true if a variable whose name matches the argument string exists in the database; otherwise, return false. In particular, if the variable exists in the VariableDatabase instance, but is not registered as locally-active, then a value of false is returned.
Parameters
namestring name of variable to retrieve.

◆ checkVariableExists() [2/2]

template<int DIM>
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.

Returns
boolean true if argument variable exists in the database; otherwise, return false.
Parameters
variablesmart 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.

◆ checkVariablePatchDataIndex()

template<int DIM>
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.

Returns
Boolean true if the variable/patch data index pair reside in the locally-active variable database; false otherwise.
Parameters
variabletbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion will result if the variable pointer is null.
data_idInteger 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).

◆ checkVariablePatchDataIndexType()

template<int DIM>
virtual 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.

Returns
Boolean true if the type of the variable matches the type of the patch data at the given patch data index; false otherwise.
Parameters
variabletbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion will result if the variable pointer is null.
data_idInteger 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).

◆ mapVariableToIndex()

template<int DIM>
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.

Returns
Integer patch data identifier for variable in database. If variable is not in the database (i.e., it has not been registered), then an invalid patch data index (i.e., < 0) is returned.
Parameters
variabletbox::Pointer to variable. When assertion checking is active, an unrecoverable assertion results if the variable pointer is null.

◆ mapIndexToVariable()

template<int DIM>
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.

Returns
Boolean true if patch data index maps to variable in the locally-active database; otherwise false.
Parameters
data_idInteger patch data identifier. When assertion checking is active, an unrecoverable assertion will if the index is invalid (i.e., < 0).
variabletbox::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.

◆ getLocallyActiveDataPatchLevelManager()

template<int DIM>
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:

  1. The given patch level is not in a patch hierarchy or does not have a valid patch hierarchy level number (i.e., it is < 0). In this case, an null level manager pointer is returned.
  2. The input patch level has a valid hierarchy level number and is in a patch hierarchy. If the database does not own a patch level manager corresponding to the level number of the input level, a new patch level manager corresponding to the input level number is added to the database and a pointer to it is returned. If the database owns a patch level manager and its level matches the input level, that manager is returned. If the database owns a patch level manager corresponding to the level number of the input level, but its level does not match the input level, then an unrecoverable error results.
Returns
pointer to hier::LocallyActiveDataPatchLevelManager<DIM> object for given patch level.
Parameters
levelconst patch level pointer.

◆ resetLocallyActiveDataPatchLevelManager()

template<int DIM>
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.

Parameters
levelconst patch level pointer.

◆ printClassData()

template<int DIM>
virtual 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.

Parameters
osOptional output stream. If not given, tbox::plog is used.

◆ validLevel()

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::validLevel ( const tbox::Pointer< hier::PatchLevel< DIM > >  level) const
private

◆ getLevelManager() [1/2]

template<int DIM>
const hier::LocallyActiveDataPatchLevelManager<DIM>* SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getLevelManager ( const hier::PatchLevel< DIM > &  pl) const
private

◆ getLevelManager() [2/2]

template<int DIM>
const hier::LocallyActiveDataPatchLevelManager<DIM>* SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getLevelManager ( const hier::PatchLevel< DIM > *  pl) const
private

Friends And Related Function Documentation

◆ LocallyActiveDataPatchLevelIterator< DIM >

template<int DIM>
friend class LocallyActiveDataPatchLevelIterator< DIM >
friend

Member Data Documentation

◆ s_locally_active_variable_database_instance

template<int DIM>
LocallyActiveVariableDatabase<DIM>* SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::s_locally_active_variable_database_instance
staticprivate

◆ s_registered_callback

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::s_registered_callback
staticprivate

◆ s_patchlevel_array_alloc_size

template<int DIM>
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::s_patchlevel_array_alloc_size
staticprivate

◆ d_variable_database

template<int DIM>
hier::VariableDatabase<DIM>* SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::d_variable_database
private

◆ d_num_registered_variables

template<int DIM>
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::d_num_registered_variables
private

◆ d_locally_active_context

template<int DIM>
tbox::Pointer<hier::VariableContext> SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::d_locally_active_context
private

◆ d_locally_active_patch_data_ids

template<int DIM>
hier::ComponentSelector SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::d_locally_active_patch_data_ids
private

◆ d_patch_level_active_data_manager

template<int DIM>
tbox::Array< tbox::Pointer< hier::LocallyActiveDataPatchLevelManager<DIM> > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::d_patch_level_active_data_manager
private

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