GEOSX
DomainPartition.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_MESH_DOMAINPARTITION_HPP_
20 #define GEOS_MESH_DOMAINPARTITION_HPP_
21 
22 #include "common/MpiWrapper.hpp"
23 #include "constitutive/ConstitutiveManager.hpp"
24 #include "dataRepository/Group.hpp"
25 #include "discretizationMethods/NumericalMethodsManager.hpp"
26 #include "mesh/MeshBody.hpp"
27 #include "mesh/mpiCommunications/NeighborCommunicator.hpp"
28 
29 namespace geos
30 {
31 
32 class SiloFile;
33 namespace dataRepository
34 {
35 namespace keys
36 {
38 string const partitionManager( "partitionManager" );
39 }
40 }
41 
42 class ObjectManagerBase;
43 class PartitionBase;
44 
52 {
53 public:
59  DomainPartition( string const & name,
60  Group * const parent );
61 
65  ~DomainPartition() override;
66 
72  DomainPartition() = delete;
73 
74  DomainPartition( DomainPartition const & ) = delete;
75 
76  DomainPartition( DomainPartition && ) = delete;
77 
78  DomainPartition & operator=( DomainPartition const & ) = delete;
79 
80  DomainPartition & operator=( DomainPartition && ) = delete;
83 
84  void initializationOrder( string_array & order ) override final;
85 
90 
94  void setupCommunications( bool use_nonblocking );
95 
100 
115  void addNeighbors( const unsigned int idim,
116  MPI_Comm & cartcomm,
117  int * ncoords );
119 
120 
126  {
128  static constexpr char const * meshBodiesString() { return "MeshBodies"; }
130  static constexpr char const * constitutiveManagerString() { return "Constitutive"; }
131 
137  dataRepository::GroupKey communicationManager = { "communicationManager" };
138  }
141 
146  constitutive::ConstitutiveManager const & getConstitutiveManager() const
147  { return this->getGroup< constitutive::ConstitutiveManager >( groupKeys.constitutiveManager ); }
148 
153  constitutive::ConstitutiveManager & getConstitutiveManager()
154  { return this->getGroup< constitutive::ConstitutiveManager >( groupKeys.constitutiveManager ); }
155 
159  NumericalMethodsManager const & getNumericalMethodManager() const
160  { return this->getParent().getGroup< NumericalMethodsManager >( "NumericalMethods" ); }
161 
165  NumericalMethodsManager & getNumericalMethodManager()
166  { return this->getParent().getGroup< NumericalMethodsManager >( "NumericalMethods" ); }
167 
172  Group const & getMeshBodies() const
173  { return this->getGroup( groupKeys.meshBodies ); }
174 
180  { return this->getGroup( groupKeys.meshBodies ); }
181 
188  template< typename KEY_TYPE >
189  bool hasMeshBody( KEY_TYPE const & key ) const
190  { return getMeshBodies().hasGroup< MeshBody >( key ); }
191 
198  template< typename KEY_TYPE >
199 // TODO uncomment these to disallow using a non string or char const * key
200 // std::enable_if_t< std::is_same< T, string >::value ||
201 // std::is_same< T, const char * >::value, bool > = false >
202  MeshBody const & getMeshBody( KEY_TYPE const & key ) const
203  { return getMeshBodies().getGroup< MeshBody >( key ); }
204 
211  template< typename KEY_TYPE >
212 // std::enable_if_t< std::is_same< T, string >::value ||
213 // std::is_same< T, const char * >::value, bool > = false >
214  MeshBody & getMeshBody( KEY_TYPE const & key )
215  { return getMeshBodies().getGroup< MeshBody >( key ); }
216 
217 
223  template< typename FUNCTION >
224  void forMeshBodies( FUNCTION && function ) const
225  {
226  getMeshBodies().forSubGroups< MeshBody >( std::forward< FUNCTION >( function ) );
227  }
228 
232  template< typename FUNCTION >
233  void forMeshBodies( FUNCTION && function )
234  {
235  getMeshBodies().forSubGroups< MeshBody >( std::forward< FUNCTION >( function ) );
236  }
237 
241  template< typename FUNCTION >
242  void forMeshBodiesIndex( FUNCTION && function ) const
243  {
244  getMeshBodies().forSubGroupsIndex< MeshBody >( std::forward< FUNCTION >( function ) );
245  }
246 
250  template< typename FUNCTION >
251  void forMeshBodiesIndex( FUNCTION && function )
252  {
253  getMeshBodies().forSubGroupsIndex< MeshBody >( std::forward< FUNCTION >( function ) );
254  }
255 
260  std::vector< NeighborCommunicator > & getNeighbors()
261  { return m_neighbors; }
262 
267  std::vector< NeighborCommunicator > const & getNeighbors() const
268  { return m_neighbors; };
269 
270 private:
271 
275  std::vector< NeighborCommunicator > m_neighbors;
276 };
277 
278 } /* namespace geos */
279 
280 #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 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:35
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:543
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:333
Group & getParent()
Access the group's parent.
Definition: Group.hpp:1341
bool hasGroup(string const &name) const
Check whether a sub-group exists.
Definition: Group.hpp:412
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:508
Group & operator=(Group const &)=delete
Deleted copy assignment operator.
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:432
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.