GEOS
MeshBody.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_MESHBODY_HPP_
21 #define GEOS_MESH_MESHBODY_HPP_
22 
23 #include "MeshLevel.hpp"
25 
26 namespace geos
27 {
28 
29 class MeshLevel;
30 
36 {
37 public:
38 
44  MeshBody( string const & name,
45  Group * const parent );
46 
52  MeshLevel & createMeshLevel( localIndex const newLevel );
53 
59  MeshLevel & createMeshLevel( string const & name );
60 
68  MeshLevel & createMeshLevel( string const & sourceLevelName,
69  string const & newLevelName,
70  int const order );
71 
79  MeshLevel & createShallowMeshLevel( string const & sourceLevelName,
80  string const & newLevelName );
81 
86  Group & getMeshLevels() { return m_meshLevels; }
90  Group const & getMeshLevels() const { return m_meshLevels; }
91 
99  template< typename T, std::enable_if_t< std::is_same< T, string >::value ||
100  std::is_same< T, const char * >::value, bool > = false >
101  MeshLevel & getMeshLevel( T const & level ) const
102  { return m_meshLevels.getGroup< MeshLevel >( level ); }
103 
111  template< typename T, std::enable_if_t< std::is_same< T, string >::value ||
112  std::is_same< T, const char * >::value, bool > = false >
113  MeshLevel & getMeshLevel( T const & level )
114  { return m_meshLevels.getGroup< MeshLevel >( level ); }
115 
116 
122  {
124  }
125 
131  {
133  }
134 
140  template< typename FUNCTION >
141  void forMeshLevels( FUNCTION && function ) const
142  {
143  m_meshLevels.forSubGroups< MeshLevel >( std::forward< FUNCTION >( function ) );
144  }
145 
149  template< typename FUNCTION >
150  void forMeshLevels( FUNCTION && function )
151  {
152  m_meshLevels.forSubGroups< MeshLevel >( std::forward< FUNCTION >( function ) );
153  }
154 
160 
166  {
167  return m_globalLengthScale;
168  }
169 
174  bool hasParticles() const
175  {
176  return m_hasParticles;
177  }
178 
184 
190  {
191  return this->getGroup< CellBlockManagerABC >( dataRepository::keys::cellManager );
192  }
193 
198  {
199  this->deregisterGroup( dataRepository::keys::cellManager );
200  }
201 
206  {} viewKeys;
207 
212  {
214  static constexpr char const * meshLevelsString() { return "meshLevels"; }
215 
217  static constexpr char const * baseDiscretizationString() { return "Level0"; }
219 
220 
221 private:
222 
223  Group & m_meshLevels;
224 
227  real64 m_globalLengthScale { 0. };
228 
230  bool m_hasParticles;
231 
232  static string intToMeshLevelString( localIndex const meshLevel );
233 
234 };
235 
236 } /* namespace geos */
237 
238 #endif /* GEOS_MESH_MESHBODY_HPP_ */
Abstract base class for CellBlockManager.
The class is used to manage mesh body.
Definition: MeshBody.hpp:36
MeshLevel & createMeshLevel(string const &sourceLevelName, string const &newLevelName, int const order)
Create a new mesh level from a source MeshLevel.
MeshLevel const & getBaseDiscretization() const
Convenience function to access the baseDiscretization.
Definition: MeshBody.hpp:130
void setHasParticles(bool hasParticles)
Set whether meshbody has particles.
bool hasParticles() const
Get whether meshbody has particles.
Definition: MeshBody.hpp:174
struct geos::MeshBody::viewKeysStruct viewKeys
viewKeys
MeshLevel & createShallowMeshLevel(string const &sourceLevelName, string const &newLevelName)
Creates a mesh level in which the member pointers are set to the allocations from another MeshLevel.
MeshLevel & createMeshLevel(localIndex const newLevel)
Create a new mesh level.
void forMeshLevels(FUNCTION &&function) const
Apply the given functor to all meshLevels on this meshBody.
Definition: MeshBody.hpp:141
MeshLevel & getMeshLevel(T const &level) const
Get a reference to a MeshLevel.
Definition: MeshBody.hpp:101
void deregisterCellBlockManager()
De register the CellBlockManager from this meshBody.
Definition: MeshBody.hpp:197
void setGlobalLengthScale(real64 scale)
Set mesh length scale used to define an absolute length tolerance.
MeshLevel & getBaseDiscretization()
Convenience function to access the baseDiscretization.
Definition: MeshBody.hpp:121
CellBlockManagerABC const & getCellBlockManager() const
Get the Abstract representation of the CellBlockManager attached to the MeshBody.
Definition: MeshBody.hpp:189
real64 getGlobalLengthScale() const
Get mesh length scale.
Definition: MeshBody.hpp:165
void forMeshLevels(FUNCTION &&function)
Apply the given functor to all meshLevels on this meshBody.
Definition: MeshBody.hpp:150
Group & getMeshLevels()
Get the meshLevels group.
Definition: MeshBody.hpp:86
MeshBody(string const &name, Group *const parent)
Constructor for MeshBody object.
MeshLevel & createMeshLevel(string const &name)
Create a new mesh level.
Group const & getMeshLevels() const
Get the meshLevels group.
Definition: MeshBody.hpp:90
struct geos::MeshBody::groupStructKeys groupKeys
groupKeys
MeshLevel & getMeshLevel(T const &level)
Get a reference to a MeshLevel.
Definition: MeshBody.hpp:113
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
void deregisterGroup(string const &name)
Removes a child group from this group.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:518
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
static constexpr char const * meshLevelsString()
Definition: MeshBody.hpp:214
static constexpr char const * baseDiscretizationString()
Definition: MeshBody.hpp:217
Data repository keys.
Definition: MeshBody.hpp:206