Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SAMRAI::hier::LocallyActiveVariableDatabase< DIM > Class Template Reference

Class LocallyActiveVariableDatabase is a Singleton class for managing variables and data that live on different sets of patches in an AMR patch hierarchy; i.e., they are "locally-active". Although this class is derived from the VariableDatabase class, this class does not extend the full range of functionality provided by the VariableDatabase base class. Instead, this class uses some of the functionality of the VariableDatabase base class so that it is not replicated here. For example, this class assumes that each variable is associated with only one patch data index and all variables registered with this class share the same variable context. However, the usage of this class is similar to the VariableDatabase class. To make usage of this class reasonably transparent all functions defined in the base class that make sense for this class are redeclared here. More...

#include <source/hierarchy/variables/LocallyActiveVariableDatabase.h>

Inheritance diagram for SAMRAI::hier::LocallyActiveVariableDatabase< DIM >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

tbox::Pointer< hier::PatchDescriptor<
DIM > > 
getPatchDescriptor () const
tbox::Pointer< hier::VariableContextgetSharedContext () const
int registerVariable (const tbox::Pointer< hier::Variable< DIM > > variable, const hier::IntVector< DIM > &ghosts)
tbox::Pointer< hier::Variable<
DIM > > 
getVariable (const string &name) const
bool checkVariableExists (const string &name) const
bool checkVariableExists (const tbox::Pointer< hier::Variable< DIM > > variable) const
bool checkVariablePatchDataIndex (const tbox::Pointer< Variable< DIM > > variable, int data_id)
int mapVariableToIndex (const tbox::Pointer< hier::Variable< DIM > > variable) const
bool mapIndexToVariable (const int index, 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)
void printClassData (ostream &os=tbox::plog) const

Static Public Member Functions

static LocallyActiveVariableDatabase<
DIM > * 
getDatabase ()

Protected Member Functions

 LocallyActiveVariableDatabase ()
virtual ~LocallyActiveVariableDatabase ()

Friends

class LocallyActiveDataPatchLevelIterator< DIM >

Detailed Description

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

Class LocallyActiveVariableDatabase is a Singleton class for managing variables and data that live on different sets of patches in an AMR patch hierarchy; i.e., they are "locally-active". Although this class is derived from the VariableDatabase class, this class does not extend the full range of functionality provided by the VariableDatabase base class. Instead, this class uses some of the functionality of the VariableDatabase base class so that it is not replicated here. For example, this class assumes that each variable is associated with only one patch data index and all variables registered with this class share the same variable context. However, the usage of this class is similar to the VariableDatabase class. To make usage of this class reasonably transparent all functions defined in the base class that make sense for this class are redeclared here.

See also:
hier::VariableContext

hier::VariableDatabase

hier::PatchDescriptor

hier::LocallyActiveDataPatchLevelManager


Constructor & Destructor Documentation

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

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


Member Function Documentation

template<int DIM>
LocallyActiveVariableDatabase< DIM > * SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getDatabase  )  [static]
 

Return a pointer to the singleton instance of the 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 there is no freeDatabase() static member function as one might expect for a Singleton class. This is unnecessary since the deallocation at program termination is handled by the VariableDatabase base class through the virtual destructor.

Reimplemented from SAMRAI::hier::VariableDatabase< DIM >.

template<int DIM>
tbox::Pointer< PatchDescriptor< DIM > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getPatchDescriptor  )  const [inline, virtual]
 

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.

Reimplemented from SAMRAI::hier::VariableDatabase< DIM >.

template<int DIM>
tbox::Pointer< hier::VariableContext > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getSharedContext  )  const [inline]
 

Return pointer to variable context shared by all locally-active variables registered with this database.

template<int DIM>
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::registerVariable const tbox::Pointer< hier::Variable< DIM > >  variable,
const hier::IntVector< DIM > &  ghosts
 

Add the given variable and ghost cell width to 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:
variable const pointer to variable to add to database.
ghosts const 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.

template<int DIM>
tbox::Pointer< hier::Variable< DIM > > SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::getVariable const string &  name  )  const [virtual]
 

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.
Parameters:
name Const reference to name string identifying the variable.

Reimplemented from SAMRAI::hier::VariableDatabase< DIM >.

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariableExists const string &  name  )  const [virtual]
 

Check if variable with given name exists in the locally-active database.

Returns:
boolean true if a variable whose name matches the argument string exists in the database; otherwise, return false.
Parameters:
name string name of variable to retrieve.

Reimplemented from SAMRAI::hier::VariableDatabase< DIM >.

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariableExists const tbox::Pointer< hier::Variable< DIM > >  variable  )  const [inline]
 

Check if given variable exists in the locally-active database.

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

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::checkVariablePatchDataIndex const tbox::Pointer< Variable< DIM > >  variable,
int  data_id
 

Check whether the given variable matches the type of the patch data at the given descriptor 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.

Returns:
Boolean true if the type of the variable matches the type of the patch data at the given descriptor index; false otherwise.
Parameters:
variable tbox::Pointer to variable. When assertion checking is active, an unrecoverable exception will result if the variable pointer is null.
data_id Integer patch data identifier. When assertion checking is active, an unrecoverable exception will result if the value is an invalid identifier (< 0).

template<int DIM>
int SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::mapVariableToIndex const tbox::Pointer< hier::Variable< DIM > >  variable  )  const [inline]
 

Map variable in database to patch data identifier. If variable is not in the database (i.e., it has not been added), then an invalid descriptor index (i.e., < 0) is returned.

Returns:
Integer patch data identifier for variable in database.
Parameters:
variable tbox::Pointer to variable. When assertion checking is active, an unrecoverable exception will result if the variable pointer is null.

template<int DIM>
bool SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::mapIndexToVariable const int  index,
tbox::Pointer< hier::Variable< DIM > > &  variable
const [inline, virtual]
 

Map patch data identifier to variable associated with the data, if possible, and set the variable pointer to the variable in the database.

Returns:
Boolean true if patch data identifier maps to variable in the database; otherwise false.
Parameters:
index Integer patch data identifier. When assertion checking is active, an unrecoverable exception will if the index is invalid (i.e., < 0).
variable tbox::Pointer to variable that maps to patch data identifier in database. If there is no identifier in the database matching the index input value, then the variable pointer is set to null.

Reimplemented from SAMRAI::hier::VariableDatabase< DIM >.

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.

  1. 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:
level const patch level pointer.

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:
level const patch level pointer.

template<int DIM>
void SAMRAI::hier::LocallyActiveVariableDatabase< DIM >::printClassData ostream &  os = tbox::plog  )  const
 

Print all variable, context, and patch descriptor information contained in the database to the specified output stream.

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


Friends And Related Function Documentation

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


The documentation for this class was generated from the following files:
Generated on Fri Dec 2 11:24:42 2005 for SAMRAI by  doxygen 1.4.2