19 #ifndef GEOSX_MANAGERS_OBJECTMANAGERBASE_HPP_ 20 #define GEOSX_MANAGERS_OBJECTMANAGERBASE_HPP_ 24 #include "mpiCommunications/NeighborData.hpp" 80 bool on_device =
false )
const override;
86 bool on_device =
false )
const override;
91 bool on_device =
false )
override;
102 template<
bool DOPACK >
129 integer const recursive )
const;
140 integer const recursive )
const;
182 bool const overwriteUpMaps,
183 bool const overwriteDownMaps )
211 return PackParentChildMapsPrivate< false >( buffer, packList );
223 return PackParentChildMapsPrivate< true >( buffer, packList );
247 template<
bool DOPACK >
252 bool on_device )
const;
262 template<
bool DOPACK >
265 integer const recursive )
const;
274 template<
bool DOPACK >
366 std::vector< std::vector< globalIndex > > & map )
380 nonLocalGhosts.
clear();
385 if( owningRank >= 0 )
447 template<
typename TYPE_RELATION >
450 bool const clearIfUnmapped );
459 template<
typename TYPE_RELATION >
462 bool const clearIfUnmapped );
474 bool const clearIfUnmapped );
483 static void CleanUpMap( std::set< localIndex >
const & targetIndices,
494 static void CleanUpMap( std::set< localIndex >
const & targetIndices,
505 static void CleanUpMap( std::set< localIndex >
const & targetIndices,
515 static void CleanUpMap( std::set< localIndex >
const & targetIndices,
525 static void CleanUpMap( std::set< localIndex >
const & targetIndices,
549 while( parentIndices[rval] != -1 )
551 rval = parentIndices[rval];
566 template<
typename MESH_DATA_TRAIT >
576 typename MESH_DATA_TRAIT::dataType defaultValue( MESH_DATA_TRAIT::defaultValue );
578 return *(this->registerWrapper< typename MESH_DATA_TRAIT::type >( MESH_DATA_TRAIT::key )->
579 setApplyDefaultValue( defaultValue )->
580 setPlotLevel( MESH_DATA_TRAIT::plotLevel )->
582 setDescription( MESH_DATA_TRAIT::description )->
583 setRegisteringObjects( nameOfRegisteringObject ) );
598 template<
typename MESH_DATA_TRAIT0,
typename MESH_DATA_TRAIT1,
typename ... MESH_DATA_TRAITS >
601 registerExtrinsicData< MESH_DATA_TRAIT0 >( nameOfRegisteringObject );
612 template<
typename MESH_DATA_TRAIT >
615 return this->getWrapper< typename MESH_DATA_TRAIT::type >( MESH_DATA_TRAIT::key )->reference();
624 template<
typename MESH_DATA_TRAIT >
627 return this->getWrapper< typename MESH_DATA_TRAIT::type >( MESH_DATA_TRAIT::key )->reference();
636 template<
typename MESH_DATA_TRAIT >
642 return this->
wrappers()[MESH_DATA_TRAIT::key] !=
nullptr;
646 template<
typename MESH_DATA_TRAIT >
649 MESH_DATA_TRAIT
const & extrinisicDataTrait )
657 string const description = MESH_DATA_TRAIT::description;
660 typename MESH_DATA_TRAIT::DataType defaultValue( MESH_DATA_TRAIT::defaultValue );
662 return *(this->registerWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey )->
663 setApplyDefaultValue( defaultValue )->
664 setPlotLevel( plotLevel )->
665 setDescription( description )->
666 setRegisteringObjects( nameOfRegisteringObject ) );
669 template<
typename MESH_DATA_TRAIT0,
typename MESH_DATA_TRAIT1,
typename ... MESH_DATA_TRAITS >
671 MESH_DATA_TRAIT0
const & extrinisicDataTrait0,
672 MESH_DATA_TRAIT1
const & extrinisicDataTrait1,
673 MESH_DATA_TRAITS && ... extrinisicDataTraits )
675 registerExtrinsicData< MESH_DATA_TRAIT0 >( nameOfRegisteringObject, extrinisicDataTrait0 );
677 MESH_DATA_TRAITS... >( nameOfRegisteringObject,
678 extrinisicDataTrait1,
679 std::forward< MESH_DATA_TRAITS >( extrinisicDataTraits )... );
682 template<
typename MESH_DATA_TRAIT >
683 auto const &
getExtrinsicData( MESH_DATA_TRAIT
const & extrinisicDataTrait )
const 685 return this->getWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey )->referenceAsView();
688 template<
typename MESH_DATA_TRAIT >
691 return this->getWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey )->referenceAsView();
739 static constexpr
auto setsString =
"sets";
741 static constexpr
auto neighborDataString =
"neighborData";
888 std::string const & rankString = std::to_string( rank );
968 template<
typename TYPE_RELATION >
975 bool allValuesMapped =
true;
978 iter != unmappedIndices.end();
989 relation[li][a] = globalToLocal.at( globalIndices[a] );
993 allValuesMapped =
false;
999 GEOSX_ERROR_IF( !allValuesMapped,
"some values of unmappedIndices were not used" );
1000 unmappedIndices.clear();
1004 template<
typename TYPE_RELATION >
1007 bool const clearIfUnmapped )
1009 GEOSX_MARK_FUNCTION;
1013 iter != unmappedIndices.end();
1017 if( clearIfUnmapped )
1019 relation[li].clear();
1024 for(
auto const newGlobalIndex : globalIndices )
1029 auto iterG2L = globalToLocal.find( newGlobalIndex );
1030 if( iterG2L != globalToLocal.end() )
1032 relation[li].insert( iterG2L->second );
1037 unmappedIndices.clear();
1044 bool const clearIfUnmapped )
1046 GEOSX_MARK_FUNCTION;
1049 iter != unmappedIndices.end();
1053 if( clearIfUnmapped )
1060 for(
globalIndex const newGlobalIndex : globalIndices )
1065 auto iterG2L = globalToLocal.find( newGlobalIndex );
1066 if( iterG2L != globalToLocal.end() )
1073 unmappedIndices.clear();
localIndex UnpackSets(buffer_unit_type const *&buffer)
Unpack the content of buffer into the sets of the instance.
real64 m_overAllocationFactor
Factor by which to overallocate when adding objects.
unordered_map< int, NeighborData > m_neighborData
A map from rank to the associated NeighborData object.
static localIndex GetParentRecusive(arraySlice1d< localIndex const > const &parentIndices, localIndex const lookup)
Get the upmost parent.
array1d< integer > const & isExternal()
Get the locality information of the objects.
localIndex PackParentChildMapsSize(arrayView1d< localIndex const > const &packList) const
Computes the pack size of the parent/child relations in packList.
array1d< globalIndex > m_localToGlobalMap
Contains the global index of each object.
void clear()
Sets the size of the Array to zero and destroys all the values.
bool insertIntoSet(INDEX_TYPE const i, T const &val)
Insert a value into the given set.
localIndex globalToLocalMap(globalIndex const gid) const
Retrieves the local index for given global index.
arrayView1d< integer const > getDomainBoundaryIndicator() const
Get the domain boundary indicator.
dataRepository::Wrapper< typename MESH_DATA_TRAIT::type > & registerExtrinsicData(string const &nameOfRegisteringObject)
Register data with this ObjectManagerBase using a dataRepository::Wrapper.
dataRepository::ViewKey ghostRank
View key to ghost ranks.
struct geosx::ObjectManagerBase::viewKeyStruct m_ObjectManagerBaseViewKeys
viewKey struct for the ObjectManagerBase class
virtual localIndex UnpackUpDownMaps(buffer_unit_type const *&buffer, array1d< localIndex > &packList, bool const overwriteUpMaps, bool const overwriteDownMaps)
Unpacks the specific elements in the @ packList.
unordered_map< globalIndex, localIndex > m_globalToLocalMap
Map from object global index to the local index.
void SetMaxGlobalIndex()
Computes the maximum global index allong all the MPI ranks.
#define GEOSX_DECLTYPE_AUTO_RETURN
Doxygen can't parse a decltype( auto ) return type, using this gets around that.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
virtual localIndex PackGlobalMapsSize(arrayView1d< localIndex const > const &packList, integer const recursive) const
Computes the pack size of the global maps elements in the @ packList.
void moveSets(LvArray::MemorySpace const targetSpace)
Manually move all sets to a memory space.
struct to serve as a container for group strings and keys
localIndex UnpackParentChildMaps(buffer_unit_type const *&buffer, localIndex_array &packList)
Unacks the parent/child relations in packList.
void ConstructGlobalToLocalMap()
Constructs the global to local map.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
integer SplitObject(localIndex const indexToSplit, int const rank, localIndex &newIndex)
Split object to deal with topology changes.
~ObjectManagerBase() override
Destructor.
void ConstructSetFromSetAndMap(SortedArrayView< localIndex const > const &inputSet, const array2d< localIndex > &map, const std::string &setName)
Builds a new set on this instance given another objects set and the map between them.
GEOSX_DECLTYPE_AUTO_RETURN getExtrinsicData() const
Get a view to the data associated with a trait from this ObjectManagerBase.
INDEX_TYPE size() const noexcept
globalIndex maxGlobalIndex() const
Get the maximum global index of all objects across all rank. See.
localIndex PackSets(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the elements of each set that actually are in packList.
static constexpr auto isExternalString
String key to the 'is external' vector.
static constexpr localIndex unmappedLocalIndexValue
A global variable for the value of a object that has not been assigned a geosx::globalIndex.
Base template for ordered and unordered maps.
virtual void enforceStateFieldConsistencyPostTopologyChange(std::set< localIndex > const &targetIndices)
Updates the child and target indices after a topology change.
Group & sets()
Get the group holding the object sets.
virtual const string getCatalogName() const =0
Get the name of the catalog.
localIndex GetNumberOfLocalIndices() const
Get the number of locally owned objects.
void SetGhostRankForSenders(int const neighborRank)
Defines neighborRank ownership for ghost objects.
void inheritGhostRankFromParent(std::set< localIndex > const &indices)
sets the value of m_ghostRank to the value of the objects parent.
constexpr T const * begin() const
arrayView1d< integer const > ghostRank() const
Get the ghost information of each object, const version.
SortedArray< localIndex > & externalSet()
Get the external set.
virtual void resize(localIndex const newSize)
Resize the group and all contained wrappers that resize with parent.
virtual localIndex Pack(buffer_unit_type *&buffer, string_array const &wrapperNames, arrayView1d< localIndex const > const &packList, integer const recursive, bool on_device=false) const override
Pack a list of indices within a list of wrappers.
This class serves to provide a "view" of a multidimensional array.
arrayView1d< integer > getDomainBoundaryIndicator()
Get the domain boundary indicator.
wrapperMap const & wrappers() const
Get access to the internal wrapper storage.
void SetReceiveLists()
Clear and redefines the ghosts to receive.
static constexpr auto globalToLocalMapString
String key to global->local mao.
dataRepository::ViewKey externalSet
View key to external set.
std::enable_if_t< _NDIM==1 > emplace_back(ARGS &&... args)
Construct a value in place at the end of the array.
void CopyObject(localIndex const source, localIndex const destination)
Copy object from source to @ destination.
double real64
64-bit floating point type.
virtual viewKeyStruct const & viewKeys() const
Get the view keys for Group access, const version.
dataRepository::ViewKey globalToLocalMap
View key to global->local map.
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
virtual groupKeyStruct const & groupKeys() const
Get the group keys for Group access, const version.
static constexpr auto externalSetString
String key to external set.
array1d< integer > m_ghostRank
Array that holds the ghost information about each object.
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
bool hasExtrinsicData() const
Checks if an extrinsic data has been registered.
virtual void ViewPackingExclusionList(SortedArray< localIndex > &exclusionList) const
Inserts in exclusionList the data that shall not be packed.
virtual groupKeyStruct & groupKeys()
Get the group keys for Group access.
This class provides a view into an array of sets like object.
This class provides a view into an array of arrays like object.
static void FixUpDownMaps(TYPE_RELATION &relation, map< localIndex, array1d< globalIndex > > &unmappedIndices, bool const clearIfUnmapped)
Fixing the up/down maps by mapping the unmapped indices.
void addNeighbor(int const rank)
Add a neighbor for rank.
void registerExtrinsicData(string const &nameOfRegisteringObject)
Register a collection of data with this ObjectManagerBase using a dataRepository::Wrapper.
void clearSet(INDEX_TYPE const i)
Clear a set.
GEOSX_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
struct geosx::ObjectManagerBase::groupKeyStruct m_ObjectManagerBaseGroupKeys
groupKey struct for the ObjectManagerBase class
virtual viewKeyStruct & viewKeys()
Get the view keys for Group access.
SortedArrayView< localIndex const > externalSet() const
Get the external set, const version.
unordered_map< globalIndex, localIndex > const & globalToLocalMap() const
Get global to local map.
globalIndex m_localMaxGlobalIndex
The maximum global index of any object of all objects on this rank.
virtual void ExtractMapFromObjectForAssignGlobalIndexNumbers(ObjectManagerBase const *const obj, std::vector< std::vector< globalIndex > > &map)
Extract map from object and assign global indices.
geosx::ObjectManagerBase ObjectDataStructureBaseT
Alias to ObjectManagerBase.
virtual localIndex PackUpDownMapsSize(arrayView1d< localIndex const > const &packList) const
Computes the pack size of the specific elements in the @ packList.
signed char buffer_unit_type
Type stored in communication buffers.
static constexpr auto domainBoundaryIndicatorString
String key to domain boundary indicator.
virtual localIndex PackSize(string_array const &wrapperNames, integer const recursive, bool on_device=false) const
Get the size required to pack a list of wrappers.
virtual localIndex PackSize(string_array const &wrapperNames, arrayView1d< localIndex const > const &packList, integer const recursive, bool on_device=false) const override
Get the size required to pack a list of indices within a list of wrappers.
arrayView1d< integer const > isExternal() const
Get the locality information of the objects.
virtual localIndex PackUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the specific elements in the @ packList.
MemorySpace
An enum containing the available memory spaces.
void ConstructLocalListOfBoundaryObjects(localIndex_array &objectList) const
Computes the (local) index list that are domain boundaries.
std::int32_t integer
Signed integer type.
localIndex PackParentChildMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const
Packs the parent/child relations in packList.
This class provides the base class/interface for the catalog value objects.
constexpr T * begin() const
NeighborData & getNeighborData(int const rank)
Get neighbor data for given rank.
const string getName() const
Get group name.
This class implements an array of sets like object with contiguous storage.
void updateGlobalToLocalMap(localIndex const lid)
Updates (if needed) the global index for local index lid.
void setRestartFlags(RestartFlags flags)
Set flags that control restart output of this group.
void ConstructGlobalListOfBoundaryObjects(globalIndex_array &objectList) const
Computes the (global) index list that are domain boundaries.
#define GEOSX_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Group m_neighborGroup
Group that holds all the NeighborData objects.
void deregisterGroup(std::string const &name)
Removes a child group from this group.
Group m_sets
Group that holds object sets.
array1d< integer > m_isExternal
Array that holds if an object is external.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
static CatalogInterface::CatalogType & GetCatalog()
Acessing the unique instance of this catalog.
NeighborData const & getNeighborData(int const rank) const
Get neighbor data for given rank, const version.
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map.
dataRepository::ViewKey localToGlobalMap
View key to the local->global map.
void CreateSet(const std::string &newSetName)
Creates a new set.
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.
std::string string
String type.
static constexpr auto ghostsToReceiveString
String key to ghosts to receive.
#define GEOSX_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
static constexpr auto localToGlobalMapString
String key to the local->global map.
array1d< integer > const & ghostRank()
Get the ghost information of each object.
virtual localIndex PackGlobalMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList, integer const recursive) const
Packs the global maps elements in the @ packList.
arrayView1d< globalIndex const > localToGlobalMap() const
Get local to global map, const version.
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...
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
virtual localIndex Pack(buffer_unit_type *&buffer, string_array const &wrapperNames, integer const recursive, bool on_device=false) const
Pack a list of wrappers to a buffer.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
static constexpr auto adjacencyListString
String key to adjacency list.
virtual localIndex Unpack(buffer_unit_type const *&buffer, arrayView1d< localIndex > &packList, integer const recursive, bool on_device=false) override
Unpack a buffer.
struct to serve as a container for variable strings and keys
GEOSX_DECLTYPE_AUTO_RETURN getExtrinsicData()
Get the data associated with a trait from this ObjectManagerBase.
array1d< integer > m_domainBoundaryIndicator
Domain boundary indicator: 1 means the "index" is on the boundary.
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...
static constexpr auto ghostRankString
String key to ghost ranks.
Group const & sets() const
Get the group holding the object sets, const version.
T * RegisterGroup(std::string const &name, std::unique_ptr< T > newObject)
Register a new Group as a sub-group of current Group.
localIndex GetNumberOfGhosts() const
Get the number of ghost objects.
globalIndex m_maxGlobalIndex
The maximum global index of all objects across all rank.
void removeNeighbor(int const rank)
Remove neighbor for rank.