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 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_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  {
161  m_globalLengthScale = scale;
162  }
163 
169  {
170  return m_globalLengthScale;
171  }
172 
177  bool hasParticles() const
178  {
179  return m_hasParticles;
180  }
181 
187 
193  {
194  return this->getGroup< CellBlockManagerABC >( dataRepository::keys::cellManager );
195  }
196 
201  {
202  this->deregisterGroup( dataRepository::keys::cellManager );
203  }
204 
209  {} viewKeys;
210 
215  {
217  static constexpr char const * meshLevelsString() { return "meshLevels"; }
218 
220  static constexpr char const * baseDiscretizationString() { return "Level0"; }
222 
223 
224 private:
225 
226  Group & m_meshLevels;
227 
230  real64 m_globalLengthScale { 0. };
231 
233  bool m_hasParticles;
234 
235  static string intToMeshLevelString( localIndex const meshLevel );
236 
237 };
238 
239 } /* namespace geos */
240 
241 #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:177
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:200
void setGlobalLengthScale(real64 scale)
Set mesh length scale used to define an absolute length tolerance.
Definition: MeshBody.hpp:159
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:192
real64 getGlobalLengthScale() const
Get mesh length scale.
Definition: MeshBody.hpp:168
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:318
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:500
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
static constexpr char const * meshLevelsString()
Definition: MeshBody.hpp:217
static constexpr char const * baseDiscretizationString()
Definition: MeshBody.hpp:220
Data repository keys.
Definition: MeshBody.hpp:209