GEOSX
MeshBody.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_MESHBODY_HPP_
20 #define GEOS_MESH_MESHBODY_HPP_
21 
22 #include "MeshLevel.hpp"
24 
25 namespace geos
26 {
27 
28 class MeshLevel;
29 
35 {
36 public:
37 
43  MeshBody( string const & name,
44  Group * const parent );
45 
51  MeshLevel & createMeshLevel( localIndex const newLevel );
52 
58  MeshLevel & createMeshLevel( string const & name );
59 
67  MeshLevel & createMeshLevel( string const & sourceLevelName,
68  string const & newLevelName,
69  int const order );
70 
78  MeshLevel & createShallowMeshLevel( string const & sourceLevelName,
79  string const & newLevelName );
80 
85  Group & getMeshLevels() { return m_meshLevels; }
89  Group const & getMeshLevels() const { return m_meshLevels; }
90 
98  template< typename T, std::enable_if_t< std::is_same< T, string >::value ||
99  std::is_same< T, const char * >::value, bool > = false >
100  MeshLevel & getMeshLevel( T const & level ) const
101  { return m_meshLevels.getGroup< MeshLevel >( level ); }
102 
110  template< typename T, std::enable_if_t< std::is_same< T, string >::value ||
111  std::is_same< T, const char * >::value, bool > = false >
112  MeshLevel & getMeshLevel( T const & level )
113  { return m_meshLevels.getGroup< MeshLevel >( level ); }
114 
115 
121  {
123  }
124 
130  {
132  }
133 
139  template< typename FUNCTION >
140  void forMeshLevels( FUNCTION && function ) const
141  {
142  m_meshLevels.forSubGroups< MeshLevel >( std::forward< FUNCTION >( function ) );
143  }
144 
148  template< typename FUNCTION >
149  void forMeshLevels( FUNCTION && function )
150  {
151  m_meshLevels.forSubGroups< MeshLevel >( std::forward< FUNCTION >( function ) );
152  }
153 
159 
165  {
166  return m_globalLengthScale;
167  }
168 
173  bool hasParticles() const
174  {
175  return m_hasParticles;
176  }
177 
183 
189  {
190  return this->getGroup< CellBlockManagerABC >( dataRepository::keys::cellManager );
191  }
192 
197  {
198  this->deregisterGroup( dataRepository::keys::cellManager );
199  }
200 
205  {} viewKeys;
206 
211  {
213  static constexpr char const * meshLevelsString() { return "meshLevels"; }
214 
216  static constexpr char const * baseDiscretizationString() { return "Level0"; }
218 
219 
220 private:
221 
222  Group & m_meshLevels;
223 
226  real64 m_globalLengthScale { 0. };
227 
229  bool m_hasParticles;
230 
231  static string intToMeshLevelString( localIndex const meshLevel );
232 
233 };
234 
235 } /* namespace geos */
236 
237 #endif /* GEOS_MESH_MESHBODY_HPP_ */
Abstract base class for CellBlockManager.
The class is used to manage mesh body.
Definition: MeshBody.hpp:35
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:129
void setHasParticles(bool hasParticles)
Set whether meshbody has particles.
bool hasParticles() const
Get whether meshbody has particles.
Definition: MeshBody.hpp:173
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:140
MeshLevel & getMeshLevel(T const &level) const
Get a reference to a MeshLevel.
Definition: MeshBody.hpp:100
void deregisterCellBlockManager()
De register the CellBlockManager from this meshBody.
Definition: MeshBody.hpp:196
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:120
CellBlockManagerABC const & getCellBlockManager() const
Get the Abstract representation of the CellBlockManager attached to the MeshBody.
Definition: MeshBody.hpp:188
real64 getGlobalLengthScale() const
Get mesh length scale.
Definition: MeshBody.hpp:164
void forMeshLevels(FUNCTION &&function)
Apply the given functor to all meshLevels on this meshBody.
Definition: MeshBody.hpp:149
Group & getMeshLevels()
Get the meshLevels group.
Definition: MeshBody.hpp:85
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:89
struct geos::MeshBody::groupStructKeys groupKeys
groupKeys
MeshLevel & getMeshLevel(T const &level)
Get a reference to a MeshLevel.
Definition: MeshBody.hpp:112
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:41
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:333
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:508
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
static constexpr char const * meshLevelsString()
Definition: MeshBody.hpp:213
static constexpr char const * baseDiscretizationString()
Definition: MeshBody.hpp:216
Data repository keys.
Definition: MeshBody.hpp:205