GEOSX
ElementSubRegionBase.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_ELEMENTSUBREGIONBASE_HPP_
20 #define GEOS_MESH_ELEMENTSUBREGIONBASE_HPP_
21 
22 #include "mesh/ElementType.hpp"
24 #include "LvArray/src/tensorOps.hpp"
25 
26 namespace geos
27 {
28 
29 class NodeManager;
30 class FaceManager;
31 class MeshLevel;
32 
33 namespace constitutive
34 {
35 class ConstitutiveBase;
36 }
37 
46 {
47 public:
48 
53 
59  ElementSubRegionBase( string const & name, dataRepository::Group * const parent );
60 
65 
67 
72 
79  virtual void calculateElementGeometricQuantities( NodeManager const & nodeManager,
80  FaceManager const & faceManager ) = 0;
81 
90  virtual void setupRelatedObjectsInRelations( MeshLevel const & mesh ) = 0;
91 
97  virtual void fixUpDownMaps( bool const clearIfUnmapped ) { GEOS_UNUSED_VAR( clearIfUnmapped ); }
98 
99 
109 
111 
116 
122 
129 
135 
141 
147  { return m_elementCenter; }
148 
153  { return m_elementCenter; }
154 
160  { return m_elementVolume; }
161 
167  { return m_constitutiveModels; }
168 
173  { return m_constitutiveModels; }
174 
181  template< typename T = constitutive::ConstitutiveBase >
182  T const & getConstitutiveModel( string const & name ) const
183  { return m_constitutiveModels.getGroup< T >( name ); }
184 
188  template< typename T = constitutive::ConstitutiveBase >
189  T & getConstitutiveModel( string const & name )
190  { return m_constitutiveModels.getGroup< T >( name ); }
191 
197  { return m_elementType; }
198 
203  void setElementType( ElementType const elemType )
204  { m_elementType = elemType; }
205 
206 
208 
214  {
216  static constexpr char const * numNodesPerElementString() { return "numNodesPerElement"; }
218  static constexpr char const * nodeListString() { return "nodeList"; }
220  static constexpr char const * numEdgesPerElementString() { return "numEdgesPerElement"; }
222  static constexpr char const * edgeListString() { return "edgeList"; }
224  static constexpr char const * numFacesPerElementString() { return "numFacesPerElement"; }
226  static constexpr char const * faceListString() { return "faceList"; }
228  static constexpr char const * elementCenterString() { return "elementCenter"; }
230  static constexpr char const * elementVolumeString() { return "elementVolume"; }
231  };
232 
238  {
240  static constexpr auto constitutiveModelsString() { return "ConstitutiveModels"; }
241  };
242 
243 private:
245  dataRepository::Group m_constitutiveModels;
246 
247 protected:
250 
253 
256 
259 
262 
265 
272  template< class NODE_MAP >
273  void calculateElementCenters( NODE_MAP const & toNodesRelation,
275  {
276  arrayView2d< real64 > const & elementCenters = m_elementCenter;
277  auto const e2n = toNodesRelation.toViewConst();
278 
279  forAll< parallelHostPolicy >( size(), [=]( localIndex const k )
280  {
281  LvArray::tensorOps::copy< 3 >( elementCenters[k], X[e2n( k, 0 )] );
282  localIndex const numNodes = this->numNodesPerElement( k );
283  for( localIndex a = 1; a < numNodes; ++a )
284  {
285  LvArray::tensorOps::add< 3 >( elementCenters[k], X[e2n( k, a )] );
286  }
287 
288  LvArray::tensorOps::scale< 3 >( elementCenters[k], 1.0 / numNodes );
289  } );
290  }
291 };
292 
293 } /* namespace geos */
294 
295 #endif /* GEOS_MESH_ELEMENTSUBREGIONBASE_HPP_ */
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:83
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:43
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:41
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
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:333
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1294
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:232
ElementType
Denotes type of cell/element shape.
Definition: ElementType.hpp:31
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:236
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
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