GEOS
DomainPartition.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 Total, S.A
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_DOMAINPARTITION_HPP_
21 #define GEOS_MESH_DOMAINPARTITION_HPP_
22 
23 #include "common/MpiWrapper.hpp"
24 #include "constitutive/ConstitutiveManager.hpp"
25 #include "dataRepository/Group.hpp"
27 #include "mesh/MeshBody.hpp"
28 #include "mesh/mpiCommunications/NeighborCommunicator.hpp"
29 
30 namespace geos
31 {
32 
33 class SiloFile;
34 namespace dataRepository
35 {
36 namespace keys
37 {
39 string const partitionManager( "partitionManager" );
40 }
41 }
42 
43 class ObjectManagerBase;
44 class PartitionBase;
45 
53 {
54 public:
60  DomainPartition( string const & name,
61  Group * const parent );
62 
66  ~DomainPartition() override;
67 
73  DomainPartition() = delete;
74 
75  DomainPartition( DomainPartition const & ) = delete;
76 
77  DomainPartition( DomainPartition && ) = delete;
78 
79  DomainPartition & operator=( DomainPartition const & ) = delete;
80 
81  DomainPartition & operator=( DomainPartition && ) = delete;
84 
85  void initializationOrder( string_array & order ) override final;
86 
91 
95  void setupCommunications( bool use_nonblocking );
96 
101 
116  void addNeighbors( const unsigned int idim,
117  MPI_Comm & cartcomm,
118  int * ncoords );
119 
124 
126 
127 
133  {
135  static constexpr char const * meshBodiesString() { return "MeshBodies"; }
137  static constexpr char const * constitutiveManagerString() { return "Constitutive"; }
138 
144  dataRepository::GroupKey communicationManager = { "communicationManager" };
145  }
148 
153  constitutive::ConstitutiveManager const & getConstitutiveManager() const
154  { return this->getGroup< constitutive::ConstitutiveManager >( groupKeys.constitutiveManager ); }
155 
160  constitutive::ConstitutiveManager & getConstitutiveManager()
161  { return this->getGroup< constitutive::ConstitutiveManager >( groupKeys.constitutiveManager ); }
162 
167  { return this->getParent().getGroup< NumericalMethodsManager >( "NumericalMethods" ); }
168 
173  { return this->getParent().getGroup< NumericalMethodsManager >( "NumericalMethods" ); }
174 
179  Group const & getMeshBodies() const
180  { return this->getGroup( groupKeys.meshBodies ); }
181 
187  { return this->getGroup( groupKeys.meshBodies ); }
188 
195  template< typename KEY_TYPE >
196  bool hasMeshBody( KEY_TYPE const & key ) const
197  { return getMeshBodies().hasGroup< MeshBody >( key ); }
198 
205  template< typename KEY_TYPE >
206 // TODO uncomment these to disallow using a non string or char const * key
207 // std::enable_if_t< std::is_same< T, string >::value ||
208 // std::is_same< T, const char * >::value, bool > = false >
209  MeshBody const & getMeshBody( KEY_TYPE const & key ) const
210  { return getMeshBodies().getGroup< MeshBody >( key ); }
211 
218  template< typename KEY_TYPE >
219 // std::enable_if_t< std::is_same< T, string >::value ||
220 // std::is_same< T, const char * >::value, bool > = false >
221  MeshBody & getMeshBody( KEY_TYPE const & key )
222  { return getMeshBodies().getGroup< MeshBody >( key ); }
223 
224 
230  template< typename FUNCTION >
231  void forMeshBodies( FUNCTION && function ) const
232  {
233  getMeshBodies().forSubGroups< MeshBody >( std::forward< FUNCTION >( function ) );
234  }
235 
239  template< typename FUNCTION >
240  void forMeshBodies( FUNCTION && function )
241  {
242  getMeshBodies().forSubGroups< MeshBody >( std::forward< FUNCTION >( function ) );
243  }
244 
248  template< typename FUNCTION >
249  void forMeshBodiesIndex( FUNCTION && function ) const
250  {
251  getMeshBodies().forSubGroupsIndex< MeshBody >( std::forward< FUNCTION >( function ) );
252  }
253 
257  template< typename FUNCTION >
258  void forMeshBodiesIndex( FUNCTION && function )
259  {
260  getMeshBodies().forSubGroupsIndex< MeshBody >( std::forward< FUNCTION >( function ) );
261  }
262 
267  std::vector< NeighborCommunicator > & getNeighbors()
268  { return m_neighbors; }
269 
274  std::vector< NeighborCommunicator > const & getNeighbors() const
275  { return m_neighbors; };
276 
277 private:
278 
282  std::vector< NeighborCommunicator > m_neighbors;
283 };
284 
285 } /* namespace geos */
286 
287 #endif /* GEOS_MESH_DOMAINPARTITION_HPP_ */
string const partitionManager("partitionManager")
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
struct geos::DomainPartition::groupKeysStruct groupKeys
groupKey struct for the DomainPartition class
void forMeshBodies(FUNCTION &&function)
Apply the given functor to all meshBodies.
void initializationOrder(string_array &order) override final
Sets the initialization order for sub-Groups.
MeshBody const & getMeshBody(KEY_TYPE const &key) const
Get a MeshBody by name, const version.
void forMeshBodiesIndex(FUNCTION &&function)
Apply the given functor to all meshBodies.
void setupBaseLevelMeshGlobalInfo()
Constructs the global information of this DomainPartition, needed to set up ghosting.
constitutive::ConstitutiveManager & getConstitutiveManager()
Get the constitutive manager.
Group const & getMeshBodies() const
Get the mesh bodies, const version.
NumericalMethodsManager & getNumericalMethodManager()
std::vector< NeighborCommunicator > & getNeighbors()
Get the neighbor communicators.
void addNeighbors(const unsigned int idim, MPI_Comm &cartcomm, int *ncoords)
Recursively builds neighbors if an MPI cartesian topology is used (i.e. not metis).
bool hasMeshBody(KEY_TYPE const &key) const
Check if a MeshBody is present given a name.
~DomainPartition() override
Destructor.
void outputPartitionInformation() const
Outputs information about the partitioning of the domain.
void forMeshBodies(FUNCTION &&function) const
Apply the given functor to all meshBodies.
constitutive::ConstitutiveManager const & getConstitutiveManager() const
Get the constitutive manager, const version.
NumericalMethodsManager const & getNumericalMethodManager() const
DomainPartition(string const &name, Group *const parent)
Constructor.
void setupCommunications(bool use_nonblocking)
Constructs the communications between this DomainPartition and its neighbors.
Group & getMeshBodies()
Get the mesh bodies.
std::vector< NeighborCommunicator > const & getNeighbors() const
Get the neighbor communicators, const version.
MeshBody & getMeshBody(KEY_TYPE const &key)
Get a MeshBody by name.
void forMeshBodiesIndex(FUNCTION &&function) const
Apply the given functor to all meshBodies.
The class is used to manage mesh body.
Definition: MeshBody.hpp:36
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
void forSubGroupsIndex(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:553
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
Group & getParent()
Access the group's parent.
Definition: Group.hpp:1362
bool hasGroup(string const &name) const
Check whether a sub-group exists.
Definition: Group.hpp:423
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:518
Group & operator=(Group const &)=delete
Deleted copy assignment operator.
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
struct to serve as a container for group strings and keys
dataRepository::GroupKey constitutiveManager
View key to the Group holding the ConstitutiveManager.
static constexpr char const * constitutiveManagerString()
dataRepository::GroupKey meshBodies
View key to the Group holding the MeshBodies.
static constexpr char const * meshBodiesString()
dataRepository::GroupKey communicationManager
View key to the Group holding the CommunicationManager.