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

Class PatchDescriptor<DIM> maintains a collection of patch data factories and associated names that describes how patch data entries are constructed on each patch in an AMR hierarchy. The factory mechanism is used to create new instances of concrete patch data objects without knowing their actual types. See the Design Patterns book by Gamma {et al.} for more details about the Abstract Factory pattern. Generally, a PatchDescriptor object is intended to be shared among all patches (which are distributed across processors) so that they store patch data objects in the same way. More...

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

List of all members.

Public Member Functions

 PatchDescriptor ()
virtual ~PatchDescriptor ()
int definePatchDataComponent (const std::string &name, tbox::Pointer< PatchDataFactory< DIM > > factory)
void removePatchDataComponent (int id)
tbox::Pointer< PatchDataFactory<
DIM > > 
getPatchDataFactory (int id) const
tbox::Pointer< PatchDataFactory<
DIM > > 
getPatchDataFactory (const std::string &name) const
int getMaxNumberRegisteredComponents () const
int mapNameToIndex (const std::string &name) const
const std::string & mapIndexToName (const int id) const
IntVector< DIM > getMaxGhostWidth () const
virtual void printClassData (std::ostream &stream=tbox::plog) const


Detailed Description

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

Class PatchDescriptor<DIM> maintains a collection of patch data factories and associated names that describes how patch data entries are constructed on each patch in an AMR hierarchy. The factory mechanism is used to create new instances of concrete patch data objects without knowing their actual types. See the Design Patterns book by Gamma {et al.} for more details about the Abstract Factory pattern. Generally, a PatchDescriptor object is intended to be shared among all patches (which are distributed across processors) so that they store patch data objects in the same way.

Patch data factory objects (and associated names) are explicitly added to the PatchDescriptor using the definePatchDataComponent() member function. This function returns an integer index that can be used to identify the corresponding patch data on a a patch. Factories can be removed from the PatchDescriptor using the removePatchDataComponent() member function, which returns the integer index associated with the removed factory to a "free list" so that it can be used again. At any time, the valid range of indices is >= 0 and < getMaxNumberRegisteredComponents().

Note that the SAMRAIManager utility establishes a maximum number of patch data object that may live on a Patch object which, for consistency, must be the same as the number of patch data factories a PatchDescriptor will hold. See the documentation of the SAMRAIManager utility for information about changing this maximum value.

See also:
tbox::SAMRAIManager

hier::PatchDataFactory

hier::PatchDataData

hier::Patch


Constructor & Destructor Documentation

template<int DIM>
SAMRAI::hier::PatchDescriptor< DIM >::PatchDescriptor (  ) 

The default constructor for a patch descriptor initializes the descriptor to hold zero patch data factory entries.

template<int DIM>
SAMRAI::hier::PatchDescriptor< DIM >::~PatchDescriptor (  )  [virtual]

The virtual destructor for a patch descriptor deallocates the internal data structures.


Member Function Documentation

template<int DIM>
int SAMRAI::hier::PatchDescriptor< DIM >::definePatchDataComponent ( const std::string &  name,
tbox::Pointer< PatchDataFactory< DIM > >  factory 
)

Add a new patch data factory and name string identifier to the patch descriptor. The factory will be given the specified name which must be unique for the mapNameToIndex() function to execute as expected. However, there is no internal checking done to ensure that names are unique.

Returns:
int index assigned to given patch data factory in patch descriptor.
Parameters:
name string name to be associated in name list with given factory, which must be non-empty when assertion checking is active.
factory pointer to factory to add to patch descriptor, which must be non-null when assertion checking is active.

template<int DIM>
void SAMRAI::hier::PatchDescriptor< DIM >::removePatchDataComponent ( int  id  ) 

Deallocate the patch data factory in the patch descriptor identified by the given index. The index may be assigned to another factory in the future. However, index will be invalid as a patch data index until it is re-allocated by the definePatchDataComponent() member function. An invalid id value passed to this function is silently ignored.

Parameters:
id int index of factory to remove from patch descriptor.

template<int DIM>
tbox::Pointer< PatchDataFactory< DIM > > SAMRAI::hier::PatchDescriptor< DIM >::getPatchDataFactory ( int  id  )  const [inline]

Retrieve a patch data factory by integer index identifier. The identifier is the one previously returned by definePatchDataComponent(). Note that the factory pointer will be null if the index is is not currently assigned.

Returns:
pointer to patch data factory assigned to given index.
Parameters:
id int index of factory to return, which must be >= 0 and < the return value of getMaxNumberRegisteredComponents();

template<int DIM>
tbox::Pointer< PatchDataFactory< DIM > > SAMRAI::hier::PatchDescriptor< DIM >::getPatchDataFactory ( const std::string &  name  )  const

Retrieve a patch data factory by name string identifier. Recall that uniqueness of names is not strictly enforced. So if more than one factory matches the given name, then only one of them is returned. If no matching factory is found, then a null pointer is returned.

Returns:
pointer to patch data factory assigned to given name.
Parameters:
name string name of factory.

template<int DIM>
int SAMRAI::hier::PatchDescriptor< DIM >::getMaxNumberRegisteredComponents (  )  const [inline]

Get the maximum number of components currently known to the patch descriptor. That is, this number indicates the largest number of components that have been registered with the descriptor via the definePatchDataComponent() function, which is equal to the largest known patch data component index + 1. Note that the total number of registered components is reduced by calls to removePatchDataComponent(), but the max number remains the same when components are removed. In that case, the corresponding indices are placed on a list of "free" values to be re-used in subsequent calls to definePatchDataComponent().

Returns:
largest index assigned to this point.

template<int DIM>
int SAMRAI::hier::PatchDescriptor< DIM >::mapNameToIndex ( const std::string &  name  )  const

Lookup a factory by string name and return its integer index identifier. Note that more than one factory may have the same name. In this case, the identifier of one of the factories is chosen. If no matching factory is found, then an invalid negative index is returned.

template<int DIM>
const std::string & SAMRAI::hier::PatchDescriptor< DIM >::mapIndexToName ( const int  id  )  const [inline]

Lookup a factory by identifier and return its name.

template<int DIM>
IntVector< DIM > SAMRAI::hier::PatchDescriptor< DIM >::getMaxGhostWidth (  )  const

Return the IntVector indicating the maximum ghost cell width of all registered patch data components.

template<int DIM>
void SAMRAI::hier::PatchDescriptor< DIM >::printClassData ( std::ostream &  stream = tbox::plog  )  const [virtual]

Print patch descriptor data to given output stream (plog by default).


The documentation for this class was generated from the following files:
Generated on Thu Jun 18 11:28:30 2009 for SAMRAI by  doxygen 1.5.1