GEOS
ElementSubRegionBase.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_ELEMENTSUBREGIONBASE_HPP_
21 #define GEOS_MESH_ELEMENTSUBREGIONBASE_HPP_
22 
23 #include "mesh/ElementType.hpp"
25 #include "LvArray/src/tensorOps.hpp"
26 
27 namespace geos
28 {
29 
30 class NodeManager;
31 class FaceManager;
32 class MeshLevel;
33 
34 namespace constitutive
35 {
36 class ConstitutiveBase;
37 }
38 
47 {
48 public:
49 
54 
60  ElementSubRegionBase( string const & name, dataRepository::Group * const parent );
61 
66 
68 
73 
80  virtual void calculateElementGeometricQuantities( NodeManager const & nodeManager,
81  FaceManager const & faceManager ) = 0;
82 
91  virtual void setupRelatedObjectsInRelations( MeshLevel const & mesh ) = 0;
92 
98  virtual void fixUpDownMaps( bool const clearIfUnmapped ) { GEOS_UNUSED_VAR( clearIfUnmapped ); }
99 
100 
110 
112 
117 
123 
130 
136 
142 
148  { return m_elementCenter; }
149 
154  { return m_elementCenter; }
155 
161  { return m_elementVolume; }
162 
168  { return m_constitutiveModels; }
169 
174  { return m_constitutiveModels; }
175 
182  template< typename T = constitutive::ConstitutiveBase >
183  T const & getConstitutiveModel( string const & name ) const
184  { return m_constitutiveModels.getGroup< T >( name ); }
185 
189  template< typename T = constitutive::ConstitutiveBase >
190  T & getConstitutiveModel( string const & name )
191  { return m_constitutiveModels.getGroup< T >( name ); }
192 
198  { return m_elementType; }
199 
204  void setElementType( ElementType const elemType )
205  { m_elementType = elemType; }
206 
207 
209 
215  {
217  static constexpr char const * numNodesPerElementString() { return "numNodesPerElement"; }
219  static constexpr char const * nodeListString() { return "nodeList"; }
221  static constexpr char const * numEdgesPerElementString() { return "numEdgesPerElement"; }
223  static constexpr char const * edgeListString() { return "edgeList"; }
225  static constexpr char const * numFacesPerElementString() { return "numFacesPerElement"; }
227  static constexpr char const * faceListString() { return "faceList"; }
229  static constexpr char const * elementCenterString() { return "elementCenter"; }
231  static constexpr char const * elementVolumeString() { return "elementVolume"; }
232  };
233 
239  {
241  static constexpr auto constitutiveModelsString() { return "ConstitutiveModels"; }
242  };
243 
244 private:
246  dataRepository::Group m_constitutiveModels;
247 
248 protected:
251 
254 
257 
260 
263 
266 
273  template< class NODE_MAP >
274  void calculateElementCenters( NODE_MAP const & toNodesRelation,
276  {
277  arrayView2d< real64 > const & elementCenters = m_elementCenter;
278  auto const e2n = toNodesRelation.toViewConst();
279 
280  forAll< parallelHostPolicy >( size(), [=]( localIndex const k )
281  {
282  LvArray::tensorOps::copy< 3 >( elementCenters[k], X[e2n( k, 0 )] );
283  localIndex const numNodes = this->numNodesPerElement( k );
284  for( localIndex a = 1; a < numNodes; ++a )
285  {
286  LvArray::tensorOps::add< 3 >( elementCenters[k], X[e2n( k, a )] );
287  }
288 
289  LvArray::tensorOps::scale< 3 >( elementCenters[k], 1.0 / numNodes );
290  } );
291  }
292 };
293 
294 } /* namespace geos */
295 
296 #endif /* GEOS_MESH_ELEMENTSUBREGIONBASE_HPP_ */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
T const & getConstitutiveModel(string const &name) const
Get a pointer to the constitutive model.
localIndex const & numEdgesPerElement() const
Gets the number of edges per element.
void setElementType(ElementType const elemType)
Setter for m_elementType.
localIndex const & numFacesPerElement() const
Get the number of faces per element.
virtual void setupRelatedObjectsInRelations(MeshLevel const &mesh)=0
Link the connectivity maps of the subregion to the managers storing the mesh information.
virtual void fixUpDownMaps(bool const clearIfUnmapped)
Call ObjectManagerBase::fixUpDownMaps for the connectivity maps needed by the derived class (i....
ElementType m_elementType
Type of element in this subregion.
virtual void calculateElementGeometricQuantities(NodeManager const &nodeManager, FaceManager const &faceManager)=0
Calculate the geometric quantities for each element in the subregion.
arrayView2d< real64 const > getElementCenter() const
Get the center of each element in this subregion.
localIndex m_numNodesPerElement
Number of nodes per element in this subregion.
dataRepository::Group & getConstitutiveModels()
Get the group in which the constitutive models of this subregion are registered.
array2d< real64 > & getElementCenter()
Get the center of each element in this subregion.
localIndex m_numFacesPerElement
Number of faces per element in this subregion.
localIndex const & numNodesPerElement() const
Get the number of nodes per element.
virtual localIndex numNodesPerElement(localIndex const k) const
Get the number of nodes per element.
dataRepository::Group const & getConstitutiveModels() const
Get the group in which the constitutive models of this subregion are registered.
~ElementSubRegionBase()
Destructor.
ElementSubRegionBase(string const &name, dataRepository::Group *const parent)
Constructor for this class.
array1d< real64 > m_elementVolume
Member level field for the element volume.
array2d< real64 > m_elementCenter
Member level field for the element center.
T & getConstitutiveModel(string const &name)
Get a pointer to the constitutive model.
void calculateElementCenters(NODE_MAP const &toNodesRelation, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X) const
Compute the center of each element in the subregion.
localIndex m_numEdgesPerElement
Number of edges per element in this subregion.
arrayView1d< real64 const > getElementVolume() const
Get the volume of each element in this subregion.
virtual void resizePerElementValues(localIndex const numNodesPerElement, localIndex const numEdgesPerElement, localIndex const numFacesPerElement)
Set all "perElement" values for this subregion.
ElementType getElementType() const
Get the type of element in this subregion.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:192
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
ElementType
Denotes type of cell/element shape.
Definition: ElementType.hpp:32
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
struct to serve as a container for group strings and keys
A struct to serve as a container for variable strings and keys.
static constexpr char const * nodeListString()
static constexpr char const * numFacesPerElementString()
static constexpr char const * numEdgesPerElementString()
static constexpr char const * edgeListString()
static constexpr char const * elementVolumeString()
static constexpr char const * numNodesPerElementString()
static constexpr char const * elementCenterString()
static constexpr char const * faceListString()
struct to serve as a container for group strings and keys
struct to serve as a container for variable strings and keys