IBAMR  IBAMR version 0.19.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 <PatchDescriptor.h>

Inheritance diagram for SAMRAI::hier::PatchDescriptor< DIM >:
Inheritance graph
[legend]

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
 

Private Member Functions

 PatchDescriptor (const PatchDescriptor< DIM > &)
 
void operator= (const PatchDescriptor< DIM > &)
 

Private Attributes

int d_max_number_registered_components
 
tbox::Array< std::string > d_names
 
tbox::Array< tbox::Pointer< PatchDataFactory< DIM > > > d_factories
 
tbox::List< intd_free_indices
 

Detailed Description

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

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

◆ PatchDescriptor() [1/2]

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.

◆ ~PatchDescriptor()

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

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

◆ PatchDescriptor() [2/2]

template<int DIM>
SAMRAI::hier::PatchDescriptor< DIM >::PatchDescriptor ( const PatchDescriptor< DIM > &  )
private

Member Function Documentation

◆ definePatchDataComponent()

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
namestring name to be associated in name list with given factory, which must be non-empty when assertion checking is active.
factorypointer to factory to add to patch descriptor, which must be non-null when assertion checking is active.

◆ removePatchDataComponent()

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
idint index of factory to remove from patch descriptor.

◆ getPatchDataFactory() [1/2]

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

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
idint index of factory to return, which must be >= 0 and < the return value of getMaxNumberRegisteredComponents();

◆ getPatchDataFactory() [2/2]

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
namestring name of factory.

◆ getMaxNumberRegisteredComponents()

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

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.

◆ mapNameToIndex()

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.

◆ mapIndexToName()

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

Lookup a factory by identifier and return its name.

◆ getMaxGhostWidth()

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.

◆ printClassData()

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

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

◆ operator=()

template<int DIM>
void SAMRAI::hier::PatchDescriptor< DIM >::operator= ( const PatchDescriptor< DIM > &  )
private

Member Data Documentation

◆ d_max_number_registered_components

template<int DIM>
int SAMRAI::hier::PatchDescriptor< DIM >::d_max_number_registered_components
private

◆ d_names

template<int DIM>
tbox::Array<std::string> SAMRAI::hier::PatchDescriptor< DIM >::d_names
private

◆ d_factories

template<int DIM>
tbox::Array< tbox::Pointer< PatchDataFactory<DIM> > > SAMRAI::hier::PatchDescriptor< DIM >::d_factories
private

◆ d_free_indices

template<int DIM>
tbox::List<int> SAMRAI::hier::PatchDescriptor< DIM >::d_free_indices
private

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