GEOS
ObjectManagerBase.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_MESH_OBJECTMANAGERBASE_HPP_
21 #define GEOS_MESH_OBJECTMANAGERBASE_HPP_
22 
23 #include "dataRepository/Group.hpp"
24 #include "common/TimingMacros.hpp"
25 #include "mpiCommunications/NeighborData.hpp"
26 
27 namespace geos
28 {
29 
34 {
35 public:
36  ObjectManagerBase() = delete;
37 
43  explicit ObjectManagerBase( string const & name,
44  dataRepository::Group * const parent );
45 
49  ~ObjectManagerBase() override;
50 
55 
60 
66 
71  virtual string getCatalogName() const = 0;
73 
76 
77  virtual localIndex packSize( string_array const & wrapperNames,
78  arrayView1d< localIndex const > const & packList,
79  integer const recursive,
80  bool onDevice,
81  parallelDeviceEvents & events ) const override;
82 
83  virtual localIndex pack( buffer_unit_type * & buffer,
84  string_array const & wrapperNames,
85  arrayView1d< localIndex const > const & packList,
86  integer const recursive,
87  bool onDevice,
88  parallelDeviceEvents & events ) const override;
89 
90  virtual localIndex unpack( buffer_unit_type const * & buffer,
91  arrayView1d< localIndex > & packList,
92  integer const recursive,
93  bool onDevice,
94  parallelDeviceEvents & events,
95  MPI_Op op=MPI_REPLACE ) override;
96 
106  template< bool DO_PACKING >
108  arrayView1d< localIndex const > const & packList ) const;
109 
116 
121  void excludeWrappersFromPacking( std::set< string > const & wrapperNames );
122 
130  integer const recursive ) const;
131 
140  arrayView1d< localIndex const > const & packList,
141  integer const recursive ) const;
142 
147 
154  {
155  GEOS_UNUSED_VAR( packList );
156  return 0;
157  }
158 
166  arrayView1d< localIndex const > const & packList ) const
167  {
168  GEOS_UNUSED_VAR( buffer );
169  GEOS_UNUSED_VAR( packList );
170  return 0;
171  }
172 
181  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
182  array1d< localIndex > & packList,
183  bool const overwriteUpMaps,
184  bool const overwriteDownMaps )
185  {
186  GEOS_UNUSED_VAR( buffer );
187  GEOS_UNUSED_VAR( packList );
188  GEOS_UNUSED_VAR( overwriteUpMaps );
189  GEOS_UNUSED_VAR( overwriteDownMaps );
190  return 0;
191  }
192 
200  virtual localIndex unpackGlobalMaps( buffer_unit_type const * & buffer,
201  localIndex_array & packList,
202  integer const recursive );
203 
210  {
211  buffer_unit_type * buffer = nullptr;
212  return packParentChildMapsImpl< false >( buffer, packList );
213  }
214 
222  arrayView1d< localIndex const > const & packList ) const
223  {
224  return packParentChildMapsImpl< true >( buffer, packList );
225  }
226 
234  localIndex_array & packList );
235 
236 private:
248  template< bool DO_PACKING >
249  localIndex packImpl( buffer_unit_type * & buffer,
250  string_array const & wrapperNames,
251  arrayView1d< localIndex const > const & packList,
252  integer const recursive,
253  bool onDevice,
254  parallelDeviceEvents & events ) const;
255 
264  template< bool DO_PACKING >
265  localIndex packGlobalMapsImpl( buffer_unit_type * & buffer,
266  arrayView1d< localIndex const > const & packList,
267  integer const recursive ) const;
268 
276  template< bool DO_PACKING >
277  localIndex packParentChildMapsImpl( buffer_unit_type * & buffer,
278  arrayView1d< localIndex const > const & packList ) const;
279 
280  //**********************************************************************************************************************
281  // functions for compatibility with old data structure
282  // TODO Deprecate or modernize all these suckers
283 
284 public:
285 
290  void moveSets( LvArray::MemorySpace const targetSpace );
291 
296  localIndex resize( localIndex const newSize,
297  const bool /*assignGlobals*/ )
298  {
300  return 0;
301  }
302 
304 
310  SortedArray< localIndex > & createSet( const string & newSetName );
311 
319  const array2d< localIndex > & map,
320  const string & setName );
329  const string & setName );
338  const string & setName );
339 
344 
350 
360  {
361  GEOS_UNUSED_VAR( nodeManager );
362  return {};
363  }
364 
369  void setGhostRankForSenders( int const neighborRank )
370  {
371  arrayView1d< localIndex const > const ghostsToSend = getNeighborData( neighborRank ).ghostsToSend();
372  array1d< std::pair< globalIndex, int > > & nonLocalGhosts = getNeighborData( neighborRank ).nonLocalGhosts();
373  nonLocalGhosts.clear();
374 
375  for( localIndex const index : ghostsToSend )
376  {
377  integer & owningRank = m_ghostRank[ index ];
378  if( owningRank >= 0 )
379  {
380  nonLocalGhosts.emplace_back( m_localToGlobalMap[ index ], owningRank );
381  }
382  else
383  {
384  owningRank = -1;
385  }
386  }
387  }
388 
394 
400 
408  integer splitObject( localIndex const indexToSplit,
409  int const rank,
410  localIndex & newIndex );
411 
419  void inheritGhostRankFromParent( std::set< localIndex > const & indices );
420 
426  void copyObject( localIndex const source, localIndex const destination );
427 
432  void eraseObject( std::set< localIndex > const & indicesToErase );
433 
437  virtual void setMaxGlobalIndex();
438 
446  template< typename TYPE_RELATION >
447  static void fixUpDownMaps( TYPE_RELATION & relation,
448  map< localIndex, array1d< globalIndex > > & unmappedIndices,
449  bool const clearIfUnmapped );
450 
458  template< typename TYPE_RELATION >
459  static void fixUpDownMaps( TYPE_RELATION & relation,
460  map< localIndex, SortedArray< globalIndex > > & unmappedIndices,
461  bool const clearIfUnmapped );
462 
470  static void fixUpDownMaps( ArrayOfSets< localIndex > & relation,
471  unordered_map< globalIndex, localIndex > const & globalToLocal,
472  map< localIndex, SortedArray< globalIndex > > & unmappedIndices,
473  bool const clearIfUnmapped );
474 
482  static void cleanUpMap( std::set< localIndex > const & targetIndices,
484  arrayView2d< localIndex const > const & downmap );
485 
493  static void cleanUpMap( std::set< localIndex > const & targetIndices,
494  ArrayOfSetsView< localIndex > const & upmap,
495  arrayView2d< localIndex const > const & downmap );
496 
504  static void cleanUpMap( std::set< localIndex > const & targetIndices,
506  arrayView1d< arrayView1d< localIndex const > const > const & downmap );
514  static void cleanUpMap( std::set< localIndex > const & targetIndices,
515  ArrayOfSetsView< localIndex > const & upmap,
516  arrayView1d< arrayView1d< localIndex const > const > const & downmap );
524  static void cleanUpMap( std::set< localIndex > const & targetIndices,
525  ArrayOfSetsView< localIndex > const & upmap,
526  ArrayOfArraysView< localIndex const > const & downmap );
527 
532  virtual void enforceStateFieldConsistencyPostTopologyChange( std::set< localIndex > const & targetIndices );
533 
544  localIndex const lookup )
545  {
546  localIndex rval = lookup;
547 
548  while( parentIndices[rval] != -1 )
549  {
550  rval = parentIndices[rval];
551  }
552 
553  return rval;
554  }
555 
564  template< typename FIELD_TRAIT >
566  registerField( string const & nameOfRegisteringObject )
567  {
568  // These are required to work-around the need for instantiation of
569  // the static constexpr trait components. This will not be required once
570  // we move to c++17.
571 
572  // This is required for the Tensor classes.
573  typename FIELD_TRAIT::dataType defaultValue( FIELD_TRAIT::defaultValue() );
574 
575  m_registeredField.insert( FIELD_TRAIT::key());
576 
577  return this->registerWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).
578  setApplyDefaultValue( defaultValue ).
579  setPlotLevel( FIELD_TRAIT::plotLevel ).
580  setRestartFlags( FIELD_TRAIT::restartFlag ).
581  setDescription( FIELD_TRAIT::description ).
582  setRegisteringObjects( nameOfRegisteringObject );
583  }
584 
592  template< typename FIELD_TRAIT >
594  typename FIELD_TRAIT::type * newObject )
595  {
596 
597  m_registeredField.insert( FIELD_TRAIT::key());
598 
599  return registerWrapper( fieldTrait.key(), newObject ).
600  setApplyDefaultValue( fieldTrait.defaultValue() ).
601  setPlotLevel( FIELD_TRAIT::plotLevel ).
602  setRestartFlags( FIELD_TRAIT::restartFlag ).
603  setDescription( FIELD_TRAIT::description );
604  }
605 
618  template< typename FIELD_TRAIT0, typename FIELD_TRAIT1, typename ... FIELD_TRAITS >
619  void registerField( string const & nameOfRegisteringObject )
620  {
621  registerField< FIELD_TRAIT0 >( nameOfRegisteringObject );
622  registerField< FIELD_TRAIT1, FIELD_TRAITS... >( nameOfRegisteringObject );
623  }
624 
631  template< typename FIELD_TRAIT >
633  {
634  return this->getWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).reference();
635  }
636 
643  template< typename FIELD_TRAIT >
645  {
646  return this->getWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ).reference();
647  }
648 
655  template< typename FIELD_TRAIT >
656  bool hasField() const
657  {
658  return this->hasWrapper( FIELD_TRAIT::key() );
659  }
660 
661  //**********************************************************************************************************************
662 
668  {
670  static constexpr char const * adjacencyListString() { return "adjacencyList"; }
671 
673  static constexpr char const * domainBoundaryIndicatorString() { return "domainBoundaryIndicator"; }
674 
676  static constexpr char const * externalSetString() { return "externalSet"; }
677 
679  static constexpr char const * ghostRankString() { return "ghostRank"; }
680 
682  static constexpr char const * ghostsToReceiveString() { return "ghostsToReceive"; }
683 
685  static constexpr char const * globalToLocalMapString() { return "globalToLocalMap"; }
686 
688  static constexpr char const * isExternalString() { return "isExternal"; }
689 
691  static constexpr char const * localToGlobalMapString() { return "localToGlobalMap"; }
692 
694  static constexpr char const * localMaxGlobalIndexString() { return "localMaxGlobalIndex"; }
695 
697  static constexpr char const * maxGlobalIndexString() { return "maxGlobalIndex"; }
698 
701 
704 
707 
710  }
713 
719  {
721  static constexpr char const * setsString() { return "sets"; }
722 
724  static constexpr char const * neighborDataString() { return "neighborData"; }
725 
728 
731  }
734 
740 
745  virtual viewKeyStruct const & viewKeys() const { return m_ObjectManagerBaseViewKeys; }
755  virtual groupKeyStruct const & groupKeys() const { return m_ObjectManagerBaseGroupKeys; }
756 
762  { return m_sets; }
763 
768  Group const & sets() const
769  { return m_sets; }
770 
776  SortedArray< localIndex > & getSet( string const & setName )
777  { return m_sets.getReference< SortedArray< localIndex > >( setName ); }
778 
784  SortedArrayView< localIndex const > getSet( string const & setName ) const
785  { return m_sets.getReference< SortedArray< localIndex > >( setName ).toViewConst(); }
786 
793 
800 
806  {
807  globalIndex const gid = m_localToGlobalMap[ lid ];
808  m_localMaxGlobalIndex = std::max( m_localMaxGlobalIndex, gid );
809  m_globalToLocalMap[ gid ] = lid;
810  }
811 
817  { return m_localToGlobalMap; }
818 
824  { return m_localToGlobalMap; }
825 
831  { return m_globalToLocalMap; }
832 
839  { return m_globalToLocalMap.at( gid ); }
840 
846  { return this->m_isExternal; }
847 
853  { return this->m_isExternal; }
854 
860  { return this->m_ghostRank; }
861 
867  { return this->m_ghostRank; }
868 
874  NeighborData & getNeighborData( int const rank )
875  { return m_neighborData.at( rank ); }
876 
882  NeighborData const & getNeighborData( int const rank ) const
883  { return m_neighborData.at( rank ); }
884 
889  void addNeighbor( int const rank )
890  {
891  string const & rankString = std::to_string( rank );
892  m_neighborData.emplace( std::piecewise_construct, std::make_tuple( rank ), std::make_tuple( rankString, &m_neighborGroup ) );
893  m_neighborGroup.registerGroup( rankString, &getNeighborData( rank ) );
894  }
895 
900  void removeNeighbor( int const rank )
901  {
903  m_neighborData.erase( rank );
904  }
905 
911  { return m_localMaxGlobalIndex; }
912 
918  { return m_maxGlobalIndex; }
919 
923  std::set< string > const & getRegisteredFields() const { return m_registeredField; }
924 
925 
933  {
935  }
936 
939  {
940  return m_domainBoundaryIndicator.toViewConst();
941  }
942 
947  virtual void outputObjectConnectivity() const
948  {
949  GEOS_ERROR( "Called outputObjectConnectivity in ObjectManagerBase. Function should be implemented." );
950  }
951 
952 protected:
955 
957  std::set< string > m_packingExclusionList;
958 
961 
964 
967 
970 
973 
982 
985 
988 
991 
994 
996  std::set< string > m_registeredField = {};
997 };
998 
999 
1000 template< typename TYPE_RELATION >
1001 void ObjectManagerBase::fixUpDownMaps( TYPE_RELATION & relation,
1002  map< localIndex, array1d< globalIndex > > & unmappedIndices,
1003  bool const )
1004 {
1006 
1007  bool allValuesMapped = true;
1008  unordered_map< globalIndex, localIndex > const & globalToLocal = relation.relatedObjectGlobalToLocal();
1009  for( auto & unmappedIndex: unmappedIndices )
1010  {
1011  localIndex const li = unmappedIndex.first;
1012  array1d< globalIndex > const & globalIndices = unmappedIndex.second;
1013  for( localIndex a = 0; a < globalIndices.size(); ++a )
1014  {
1015  if( globalIndices[a] != unmappedLocalIndexValue )
1016  {
1017  if( relation[li][a] == unmappedLocalIndexValue )
1018  {
1019  relation[li][a] = globalToLocal.at( globalIndices[a] );
1020  }
1021  else
1022  {
1023  allValuesMapped = false;
1024  }
1025  }
1026  // temporarily disabled this check to allow for the case where the index is not set
1027  // this entire fixUpDownMaps will be removed in a future PR as the unpacking is modified
1028  // s.t. there are no invalid unpacked values that are not expected.
1029  //GEOS_ERROR_IF( relation[li][a] == unmappedLocalIndexValue, "Index not set" );
1030  }
1031  }
1032  GEOS_ERROR_IF( !allValuesMapped, "some values of unmappedIndices were not used" );
1033  unmappedIndices.clear();
1034 }
1035 
1036 
1037 template< typename TYPE_RELATION >
1038 void ObjectManagerBase::fixUpDownMaps( TYPE_RELATION & relation,
1039  map< localIndex, SortedArray< globalIndex > > & unmappedIndices,
1040  bool const clearIfUnmapped )
1041 {
1043 
1044  unordered_map< globalIndex, localIndex > const & globalToLocal = relation.RelatedObjectGlobalToLocal();
1045  for( map< localIndex, SortedArray< globalIndex > >::iterator iter = unmappedIndices.begin();
1046  iter != unmappedIndices.end();
1047  ++iter )
1048  {
1049  localIndex const li = iter->first;
1050  if( clearIfUnmapped )
1051  {
1052  relation[li].clear();
1053  }
1054  else
1055  {
1056  SortedArray< globalIndex > const & globalIndices = iter->second;
1057  for( auto const newGlobalIndex : globalIndices )
1058  {
1059  // NOTE: This simply ignores if newGlobalIndex is not found. This is OK if this function is
1060  // used for an upmap and the object shouldn't exist on this rank. There should be a better
1061  // way to check this.
1062  auto iterG2L = globalToLocal.find( newGlobalIndex );
1063  if( iterG2L != globalToLocal.end() )
1064  {
1065  relation[li].insert( iterG2L->second );
1066  }
1067  }
1068  }
1069  }
1070  unmappedIndices.clear();
1071 }
1072 
1073 inline
1075  unordered_map< globalIndex, localIndex > const & globalToLocal,
1076  map< localIndex, SortedArray< globalIndex > > & unmappedIndices,
1077  bool const clearIfUnmapped )
1078 {
1080 
1081  for( map< localIndex, SortedArray< globalIndex > >::iterator iter = unmappedIndices.begin();
1082  iter != unmappedIndices.end();
1083  ++iter )
1084  {
1085  localIndex const li = iter->first;
1086  if( clearIfUnmapped )
1087  {
1088  relation.clearSet( li );
1089  }
1090  else
1091  {
1092  SortedArray< globalIndex > const & globalIndices = iter->second;
1093  for( globalIndex const newGlobalIndex : globalIndices )
1094  {
1095  // NOTE: This simply ignores if newGlobalIndex is not found. This is OK if this function is
1096  // used for an upmap and the object shouldn't exist on this rank. There should be a better
1097  // way to check this.
1098  auto iterG2L = globalToLocal.find( newGlobalIndex );
1099  if( iterG2L != globalToLocal.end() )
1100  {
1101  relation.insertIntoSet( li, iterG2L->second );
1102  }
1103  }
1104  }
1105  }
1106  unmappedIndices.clear();
1107 }
1108 
1109 } /* namespace geos */
1110 
1111 
1116 
1117 #endif /* GEOS_MESH_OBJECTMANAGERBASE_HPP_ */
#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.
Definition: GeosxMacros.hpp:84
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:157
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:142
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
static localIndex getParentRecursive(arraySlice1d< localIndex const > const &parentIndices, localIndex const lookup)
Get the upmost parent.
dataRepository::Wrapper< typename FIELD_TRAIT::type > & registerField(FIELD_TRAIT const &fieldTrait, typename FIELD_TRAIT::type *newObject)
Helper function to register fields.
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.
Definition: Group.hpp:1204
T & registerGroup(string const &name, std::unique_ptr< T > newObject)
Register a new Group as a sub-group of current Group.
Definition: Group.hpp:200
void setRestartFlags(RestartFlags flags)
Set flags that control restart output of this group.
Definition: Group.hpp:1426
string const & getName() const
Get group name.
Definition: Group.hpp:1331
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1275
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.
Definition: DataTypes.hpp:337
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1664
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:188
stdVector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:401
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:407
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:200
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
Definition: DataTypes.hpp:302
constexpr static localIndex unmappedLocalIndexValue
A global variable for the value of a object that has not been assigned a geos::globalIndex.
Definition: DataTypes.hpp:469
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
Definition: DataTypes.hpp:294
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:192
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:81
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:275
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Definition: DataTypes.hpp:298
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:279
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:117
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:204
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:184
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()