20 #ifndef GEOS_MESH_OBJECTMANAGERBASE_HPP_ 
   21 #define GEOS_MESH_OBJECTMANAGERBASE_HPP_ 
   25 #include "mpiCommunications/NeighborData.hpp" 
   81                                parallelDeviceEvents & events ) 
const override;
 
   88                            parallelDeviceEvents & events ) 
const override;
 
   94                              parallelDeviceEvents & events,
 
   95                              MPI_Op op=MPI_REPLACE ) 
override;
 
  106   template< 
bool DO_PACKING >
 
  130                                          integer const recursive ) 
const;
 
  141                                      integer const recursive ) 
const;
 
  183                                        bool const overwriteUpMaps,
 
  184                                        bool const overwriteDownMaps )
 
  212     return packParentChildMapsImpl< false >( buffer, packList );
 
  224     return packParentChildMapsImpl< true >( buffer, packList );
 
  248   template< 
bool DO_PACKING >
 
  254                        parallelDeviceEvents & events ) 
const;
 
  264   template< 
bool DO_PACKING >
 
  267                                  integer const recursive ) 
const;
 
  276   template< 
bool DO_PACKING >
 
  290   void moveSets( LvArray::MemorySpace 
const targetSpace );
 
  320                                   const string & setName );
 
  329                                   const string & setName );
 
  338                                   const string & setName );
 
  373     nonLocalGhosts.clear();
 
  378       if( owningRank >= 0 )
 
  432   void eraseObject( std::set< localIndex > 
const & indicesToErase );
 
  446   template< 
typename TYPE_RELATION >
 
  449                              bool const clearIfUnmapped );
 
  458   template< 
typename TYPE_RELATION >
 
  461                              bool const clearIfUnmapped );
 
  473                              bool const clearIfUnmapped );
 
  482   static void cleanUpMap( std::set< localIndex > 
const & targetIndices,
 
  493   static void cleanUpMap( std::set< localIndex > 
const & targetIndices,
 
  504   static void cleanUpMap( std::set< localIndex > 
const & targetIndices,
 
  514   static void cleanUpMap( std::set< localIndex > 
const & targetIndices,
 
  524   static void cleanUpMap( std::set< localIndex > 
const & targetIndices,
 
  548     while( parentIndices[rval] != -1 )
 
  550       rval = parentIndices[rval];
 
  564   template< 
typename FIELD_TRAIT >
 
  573     typename FIELD_TRAIT::dataType defaultValue( FIELD_TRAIT::defaultValue() );
 
  577     return this->registerWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).
 
  578              setApplyDefaultValue( defaultValue ).
 
  579              setPlotLevel( FIELD_TRAIT::plotLevel ).
 
  581              setDescription( FIELD_TRAIT::description ).
 
  582              setRegisteringObjects( nameOfRegisteringObject );
 
  591   template< 
typename FIELD_TRAIT >
 
  597              setApplyDefaultValue( FIELD_TRAIT::defaultValue() ).
 
  598              setPlotLevel( FIELD_TRAIT::plotLevel ).
 
  600              setDescription( FIELD_TRAIT::description );
 
  615   template< 
typename FIELD_TRAIT0, 
typename FIELD_TRAIT1, 
typename ... FIELD_TRAITS >
 
  618     registerField< FIELD_TRAIT0 >( nameOfRegisteringObject );
 
  619     registerField< FIELD_TRAIT1, FIELD_TRAITS... >( nameOfRegisteringObject );
 
  628   template< 
typename FIELD_TRAIT >
 
  631     return this->getWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).reference();
 
  640   template< 
typename FIELD_TRAIT >
 
  643     return this->getWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).reference();
 
  652   template< 
typename FIELD_TRAIT >
 
  655     return this->
hasWrapper( FIELD_TRAIT::key() );
 
  718     static constexpr 
char const * 
setsString() { 
return "sets"; }
 
  888     string const & rankString = std::to_string( rank );
 
  946     GEOS_ERROR( 
"Called outputObjectConnectivity in ObjectManagerBase. Function should be implemented." );
 
  997 template< 
typename TYPE_RELATION >
 
 1004   bool allValuesMapped = 
true;
 
 1006   for( 
auto & unmappedIndex: unmappedIndices )
 
 1010     for( 
localIndex a = 0; a < globalIndices.size(); ++a )
 
 1016           relation[li][a] = globalToLocal.at( globalIndices[a] );
 
 1020           allValuesMapped = 
false;
 
 1029   GEOS_ERROR_IF( !allValuesMapped, 
"some values of unmappedIndices were not used" );
 
 1030   unmappedIndices.clear();
 
 1034 template< 
typename TYPE_RELATION >
 
 1037                                        bool const clearIfUnmapped )
 
 1043        iter != unmappedIndices.end();
 
 1047     if( clearIfUnmapped )
 
 1049       relation[li].clear();
 
 1054       for( 
auto const newGlobalIndex : globalIndices )
 
 1059         auto iterG2L = globalToLocal.find( newGlobalIndex );
 
 1060         if( iterG2L != globalToLocal.end() )
 
 1062           relation[li].insert( iterG2L->second );
 
 1067   unmappedIndices.clear();
 
 1074                                        bool const clearIfUnmapped )
 
 1079        iter != unmappedIndices.end();
 
 1083     if( clearIfUnmapped )
 
 1085       relation.clearSet( li );
 
 1090       for( 
globalIndex const newGlobalIndex : globalIndices )
 
 1095         auto iterG2L = globalToLocal.find( newGlobalIndex );
 
 1096         if( iterG2L != globalToLocal.end() )
 
 1098           relation.insertIntoSet( li, iterG2L->second );
 
 1103   unmappedIndices.clear();
 
#define GEOS_DECLTYPE_AUTO_RETURN
Doxygen can't parse a decltype( auto ) return type, using this gets around that.
 
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
 
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
 
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
 
geos::ObjectManagerBase ObjectDataStructureBaseT
Alias to ObjectManagerBase.
 
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
 
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
 
array1d< integer > const  & ghostRank()
Get the ghost information of each object.
 
array1d< integer > m_domainBoundaryIndicator
Domain boundary indicator: 1 means the "index" is on the boundary.
 
SortedArrayView< localIndex const > getSet(string const &setName) const
Get a set by name, const version.
 
array1d< integer > & getDomainBoundaryIndicator()
Get the domain boundary indicator.
 
arrayView1d< integer const > ghostRank() const
Get the ghost information of each object, const version.
 
NeighborData const  & getNeighborData(int const rank) const
Get neighbor data for given rank, const version.
 
localIndex packParentChildMapsSize(arrayView1d< localIndex const > const &packList) const
Computes the pack size of the parent/child relations in packList.
 
array1d< integer > m_isExternal
Array that holds if an object is external.
 
globalIndex m_localMaxGlobalIndex
The maximum global index of any object of all objects on this rank.
 
NeighborData & getNeighborData(int const rank)
Get neighbor data for given rank.
 
virtual viewKeyStruct & viewKeys()
Get the view keys for Group access.
 
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the specific elements in the @ packList.
 
static void cleanUpMap(std::set< localIndex > const &targetIndices, ArrayOfSetsView< localIndex > const &upmap, ArrayOfArraysView< localIndex const > const &downmap)
Removes from the list of sets of upmap all the elements for which the "mirror target array" of downma...
 
virtual localIndex packGlobalMapsSize(arrayView1d< localIndex const > const &packList, integer const recursive) const
Computes the pack size of the global maps elements in the @ packList.
 
globalIndex maxGlobalIndex() const
Get the maximum global index of all objects across all rank. See.
 
Group m_neighborGroup
Group that holds all the NeighborData objects.
 
virtual ArrayOfSets< globalIndex > extractMapFromObjectForAssignGlobalIndexNumbers(ObjectManagerBase const &nodeManager)
Extract map from object and assign global indices.
 
std::set< string > m_packingExclusionList
Names of the wrappers that should not be packed.
 
static CatalogInterface::CatalogType & getCatalog()
Acessing the unique instance of this catalog.
 
unordered_map< int, NeighborData > m_neighborData
A map from rank to the associated NeighborData object.
 
Group m_sets
Group that holds object sets.
 
GEOS_DECLTYPE_AUTO_RETURN getField() const
Get a view to the field associated with a trait from this ObjectManagerBase.
 
virtual localIndex pack(buffer_unit_type *&buffer, string_array const &wrapperNames, arrayView1d< localIndex const > const &packList, integer const recursive, bool onDevice, parallelDeviceEvents &events) const override
Pack a list of indices within a list of wrappers.
 
globalIndex m_maxGlobalIndex
The maximum global index of all objects across all rank.
 
localIndex unpackSets(buffer_unit_type const *&buffer)
Unpack the content of buffer into the sets of the instance.
 
array1d< integer > m_ghostRank
Array that holds the ghost information about each object.
 
std::set< string > m_registeredField
Field that have been registered.
 
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map.
 
unordered_map< globalIndex, localIndex > const  & globalToLocalMap() const
Get global to local map.
 
void constructSetFromSetAndMap(SortedArrayView< localIndex const > const &inputSet, const array1d< localIndex_array > &map, const string &setName)
Builds a new set on this instance given another objects set and the map between them.
 
Group const  & sets() const
Get the group holding the object sets, const version.
 
virtual localIndex unpack(buffer_unit_type const *&buffer, arrayView1d< localIndex > &packList, integer const recursive, bool onDevice, parallelDeviceEvents &events, MPI_Op op=MPI_REPLACE) override
Unpack a buffer.
 
virtual void enforceStateFieldConsistencyPostTopologyChange(std::set< localIndex > const &targetIndices)
Updates the child and target indices after a topology change.
 
void setGhostRankForSenders(int const neighborRank)
Defines neighborRank ownership for ghost objects.
 
struct geos::ObjectManagerBase::groupKeyStruct m_ObjectManagerBaseGroupKeys
groupKey struct for the ObjectManagerBase class
 
dataRepository::Wrapper< typename FIELD_TRAIT::type > & registerField(typename FIELD_TRAIT::type *newObject)
Helper function to register fields.
 
static localIndex getParentRecursive(arraySlice1d< localIndex const > const &parentIndices, localIndex const lookup)
Get the upmost parent.
 
ObjectManagerBase(string const &name, dataRepository::Group *const parent)
Constructor.
 
virtual string getCatalogName() const =0
Get the name of the catalog.
 
void constructGlobalToLocalMap()
Constructs the global to local map.
 
localIndex packParentChildMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the parent/child relations in packList.
 
virtual localIndex packGlobalMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList, integer const recursive) const
Packs the global maps elements in the @ packList.
 
Group & sets()
Get the group holding the object sets.
 
real64 m_overAllocationFactor
Factor by which to overallocate when adding objects.
 
void moveSets(LvArray::MemorySpace const targetSpace)
Manually move all sets to a memory space.
 
SortedArray< localIndex > & createSet(const string &newSetName)
Creates a new set.
 
integer splitObject(localIndex const indexToSplit, int const rank, localIndex &newIndex)
Split object to deal with topology changes.
 
localIndex globalToLocalMap(globalIndex const gid) const
Retrieves the local index for given global index.
 
void removeNeighbor(int const rank)
Remove neighbor for rank.
 
static void cleanUpMap(std::set< localIndex > const &targetIndices, ArrayOfSetsView< localIndex > const &upmap, arrayView2d< localIndex const > const &downmap)
Removes from the list of sets of upmap all the elements for which the "mirror target array" of downma...
 
virtual viewKeyStruct const  & viewKeys() const
Get the view keys for Group access, const version.
 
SortedArray< localIndex > & getSet(string const &setName)
Get a set by name.
 
static void cleanUpMap(std::set< localIndex > const &targetIndices, ArrayOfSetsView< localIndex > const &upmap, arrayView1d< arrayView1d< localIndex const > const > const &downmap)
Removes from the list of sets of upmap all the elements for which the "mirror target array" of downma...
 
virtual void setMaxGlobalIndex()
Computes the maximum global index allong all the MPI ranks.
 
virtual localIndex unpackGlobalMaps(buffer_unit_type const *&buffer, localIndex_array &packList, integer const recursive)
Unpacks the global maps from buffer.
 
localIndex resize(localIndex const newSize, const bool)
Resize the group and all contained wrappers that resize with parent.
 
localIndex unpackParentChildMaps(buffer_unit_type const *&buffer, localIndex_array &packList)
Unacks the parent/child relations in packList.
 
static void cleanUpMap(std::set< localIndex > const &targetIndices, array1d< SortedArray< localIndex > > &upmap, arrayView1d< arrayView1d< localIndex const > const > const &downmap)
Removes from the list of arrays of upmap all the elements for which the "mirror target array" of down...
 
void eraseObject(std::set< localIndex > const &indicesToErase)
Erase object from this object manager.
 
unordered_map< globalIndex, localIndex > m_globalToLocalMap
Map from object global index to the local index.
 
virtual groupKeyStruct & groupKeys()
Get the group keys for Group access.
 
virtual localIndex packSize(string_array const &wrapperNames, arrayView1d< localIndex const > const &packList, integer const recursive, bool onDevice, parallelDeviceEvents &events) const override
Get the size required to pack a list of indices within a list of wrappers.
 
virtual localIndex packUpDownMapsSize(arrayView1d< localIndex const > const &packList) const
Computes the pack size of the specific elements in the @ packList.
 
arrayView1d< globalIndex const > localToGlobalMap() const
Get local to global map, const version.
 
virtual localIndex unpackUpDownMaps(buffer_unit_type const *&buffer, array1d< localIndex > &packList, bool const overwriteUpMaps, bool const overwriteDownMaps)
Unpacks the specific elements in the @ packList.
 
array1d< integer > const  & isExternal()
Get the locality information of the objects.
 
localIndex packSets(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the elements of each set that actually are in packList.
 
virtual groupKeyStruct const  & groupKeys() const
Get the group keys for Group access, const version.
 
void inheritGhostRankFromParent(std::set< localIndex > const &indices)
sets the value of m_ghostRank to the value of the objects parent.
 
struct geos::ObjectManagerBase::viewKeyStruct m_ObjectManagerBaseViewKeys
viewKey struct for the ObjectManagerBase class
 
dataRepository::Wrapper< typename FIELD_TRAIT::type > & registerField(string const &nameOfRegisteringObject)
Register field with this ObjectManagerBase using a dataRepository::Wrapper.
 
void copyObject(localIndex const source, localIndex const destination)
Copy object from source to @ destination.
 
void excludeWrappersFromPacking(std::set< string > const &wrapperNames)
Registers wrappers that will be excluded from packing.
 
static void cleanUpMap(std::set< localIndex > const &targetIndices, array1d< SortedArray< localIndex > > &upmap, arrayView2d< localIndex const > const &downmap)
Removes from the list of arrays of upmap all the elements for which the "mirror target array" of down...
 
static void fixUpDownMaps(TYPE_RELATION &relation, map< localIndex, array1d< globalIndex > > &unmappedIndices, bool const clearIfUnmapped)
Fixing the up/down maps by mapping the unmapped indices.
 
SortedArrayView< localIndex const > externalSet() const
Get the external set, const version.
 
arrayView1d< integer const > getDomainBoundaryIndicator() const
Get the domain boundary indicator.
 
void setReceiveLists()
Clear and redefines the ghosts to receive.
 
localIndex getNumberOfGhosts() const
Get the number of ghost objects.
 
SortedArray< localIndex > & externalSet()
Get the external set.
 
~ObjectManagerBase() override
Destructor.
 
bool hasField() const
Checks if a field has been registered.
 
array1d< globalIndex > m_localToGlobalMap
Contains the global index of each object.
 
std::set< string > const  & getRegisteredFields() const
 
localIndex getNumberOfLocalIndices() const
Get the number of locally owned objects.
 
arrayView1d< integer const > isExternal() const
Get the locality information of the objects.
 
array1d< globalIndex > constructGlobalListOfBoundaryObjects() const
Computes the (global) index list that are domain boundaries.
 
void registerField(string const &nameOfRegisteringObject)
Register a collection of fields with this ObjectManagerBase using a dataRepository::Wrapper.
 
void constructSetFromSetAndMap(SortedArrayView< localIndex const > const &inputSet, ArrayOfArraysView< localIndex const > const &map, const string &setName)
Builds a new set on this instance given another objects set and the map between them.
 
virtual void outputObjectConnectivity() const
Function to output connectivity in order to assist debugging issues with object connectivity.
 
GEOS_DECLTYPE_AUTO_RETURN getField()
Get the field associated with a trait from this ObjectManagerBase.
 
globalIndex localMaxGlobalIndex() const
Get the local maximum global index on this rank.
 
void updateGlobalToLocalMap(localIndex const lid)
Updates (if needed) the global index for local index lid.
 
void constructSetFromSetAndMap(SortedArrayView< localIndex const > const &inputSet, const array2d< localIndex > &map, const string &setName)
Builds a new set on this instance given another objects set and the map between them.
 
void addNeighbor(int const rank)
Add a neighbor for rank.
 
This class provides the base class/interface for the catalog value objects.
 
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...
 
void deregisterGroup(string const &name)
Removes a child group from this group.
 
Wrapper< TBASE > & registerWrapper(string const &name, wrapperMap::KeyIndex::index_type *const rkey=nullptr)
Create and register a Wrapper around a new object.
 
bool hasWrapper(LOOKUP_TYPE const &lookup) const
Check if a wrapper exists.
 
T & registerGroup(string const &name, std::unique_ptr< T > newObject)
Register a new Group as a sub-group of current Group.
 
void setRestartFlags(RestartFlags flags)
Set flags that control restart output of this group.
 
string const  & getName() const
Get group name.
 
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
 
virtual localIndex packSize(string_array const &wrapperNames, integer const recursive, bool onDevice, parallelDeviceEvents &events) const
Get the size required to pack a list of wrappers.
 
virtual localIndex pack(buffer_unit_type *&buffer, string_array const &wrapperNames, integer const recursive, bool onDevice, parallelDeviceEvents &events) const
Pack a list of wrappers to a buffer.
 
virtual void resize(localIndex const newSize)
Resize the group and all contained wrappers that resize with parent.
 
Base template for ordered and unordered maps.
 
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
 
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
 
stdVector< string > string_array
A 1-dimensional array of geos::string types.
 
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
 
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
 
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
 
LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
 
constexpr static localIndex unmappedLocalIndexValue
A global variable for the value of a object that has not been assigned a geos::globalIndex.
 
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
 
double real64
64-bit floating point type.
 
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
 
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
 
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
 
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
 
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
 
signed char buffer_unit_type
Type stored in communication buffers.
 
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
 
int integer
Signed integer type.
 
Array< T, 1 > array1d
Alias for 1D array.
 
struct to serve as a container for group strings and keys
 
static constexpr char const  * neighborDataString()
 
static constexpr char const  * setsString()
 
dataRepository::GroupKey neighborData
View key to the Group holding the neighbor data.
 
dataRepository::GroupKey sets
View key to the Group holding the object sets.
 
struct to serve as a container for variable strings and keys
 
dataRepository::ViewKey localToGlobalMap
View key to the local->global map.
 
static constexpr char const  * domainBoundaryIndicatorString()
 
dataRepository::ViewKey ghostRank
View key to ghost ranks.
 
static constexpr char const  * ghostsToReceiveString()
 
static constexpr char const  * maxGlobalIndexString()
 
static constexpr char const  * ghostRankString()
 
static constexpr char const  * isExternalString()
 
dataRepository::ViewKey externalSet
View key to external set.
 
static constexpr char const  * localToGlobalMapString()
 
static constexpr char const  * globalToLocalMapString()
 
dataRepository::ViewKey globalToLocalMap
View key to global->local map.
 
static constexpr char const  * externalSetString()
 
static constexpr char const  * adjacencyListString()
 
static constexpr char const  * localMaxGlobalIndexString()