GEOSX
CellBlock.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 Total, S.A
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 GEOSX_MESH_CELLBLOCK_HPP_
20 #define GEOSX_MESH_CELLBLOCK_HPP_
21 
22 #include "ElementSubRegionBase.hpp"
23 #include "FaceManager.hpp"
25 #include "rajaInterface/GEOS_RAJA_Interface.hpp"
26 
27 
28 class StableTimeStep;
29 
30 namespace geosx
31 {
32 
41 {
42 public:
43 
50 
54 
60  static const string CatalogName()
61  { return "CellBlock"; }
62 
66  virtual const string getCatalogName() const override final
67  { return CellBlock::CatalogName(); }
68 
70 
74 
79  CellBlock() = delete;
80 
86  CellBlock( string const & name, Group * const parent );
87 
92  CellBlock( const CellBlock & init ) = delete;
93 
97  virtual ~CellBlock() override;
98 
100 
104 
106  virtual void CalculateElementGeometricQuantities( NodeManager const & nodeManager,
107  FaceManager const & facemanager ) override;
108 
109  virtual void setupRelatedObjectsInRelations( MeshLevel const * const mesh ) override;
110 
116  {
117  arrayView2d< real64 > const & elementCenters = m_elementCenter;
118  localIndex nNodes = numNodesPerElement();
119 
120  forAll< parallelHostPolicy >( size(), [=]( localIndex const k )
121  {
122  LvArray::tensorOps::copy< 3 >( elementCenters[ k ], X[ m_toNodesRelation( k, 0 ) ] );
123  for( localIndex a = 1; a < nNodes; ++a )
124  {
125  LvArray::tensorOps::add< 3 >( elementCenters[ k ], X[ m_toNodesRelation( k, a ) ] );
126  }
127 
128  LvArray::tensorOps::scale< 3 >( elementCenters[ k ], 1.0 / nNodes );
129  } );
130  }
131 
139  {
140  LvArray::tensorOps::fill< 3 >( m_elementCenter[ k ], 0 );
141 
142  real64 Xlocal[10][3];
143 
144  for( localIndex a = 0; a < m_numNodesPerElement; ++a )
145  {
146  LvArray::tensorOps::copy< 3 >( Xlocal[ a ], X[ m_toNodesRelation( k, a ) ] );
147  LvArray::tensorOps::add< 3 >( m_elementCenter[ k ], X[ m_toNodesRelation( k, a ) ] );
148  }
149  LvArray::tensorOps::scale< 3 >( m_elementCenter[ k ], 1.0 / m_numNodesPerElement );
150 
151  if( m_numNodesPerElement == 8 )
152  {
153  m_elementVolume[k] = computationalGeometry::HexVolume( Xlocal );
154  }
155  else if( m_numNodesPerElement == 4 )
156  {
157  m_elementVolume[k] = computationalGeometry::TetVolume( Xlocal );
158  }
159  else if( m_numNodesPerElement == 6 )
160  {
161  m_elementVolume[k] = computationalGeometry::WedgeVolume( Xlocal );
162  }
163  else if( m_numNodesPerElement == 5 )
164  {
165  m_elementVolume[k] = computationalGeometry::PyramidVolume( Xlocal );
166  }
167  else
168  {
169  GEOSX_ERROR( "GEOX does not support cells with " << m_numNodesPerElement << " nodes" );
170  }
171  }
172 
174 
178 
180  virtual void SetElementType( string const & elementType ) override;
181 
188  localIndex GetNumFaceNodes( localIndex const elementIndex,
189  localIndex const localFaceIndex ) const;
190 
198  localIndex GetFaceNodes( localIndex const elementIndex,
199  localIndex const localFaceIndex,
200  localIndex * const nodeIndices ) const;
201 
202 
209  void GetFaceNodes( localIndex const elementIndex,
210  localIndex const localFaceIndex,
211  localIndex_array & nodeIndices ) const;
212 
213 
219 
223  NodeMapType const & nodeList() const { return m_toNodesRelation; }
224 
231  localIndex & nodeList( localIndex const k, localIndex a ) { return m_toNodesRelation( k, a ); }
232 
236  localIndex const & nodeList( localIndex const k, localIndex a ) const { return m_toNodesRelation( k, a ); }
237 
243 
248 
254 
259 
261 
265 
273  template< typename T >
274  T & AddProperty( string const & propertyName )
275  {
276  m_externalPropertyNames.emplace_back( propertyName );
277  return this->registerWrapper< T >( propertyName )->reference();
278  }
279 
285  template< typename LAMBDA >
286  void forExternalProperties( LAMBDA && lambda )
287  {
288  for( auto & externalPropertyName : m_externalPropertyNames )
289  {
290  dataRepository::WrapperBase * const wrapper = this->getWrapperBase( externalPropertyName );
291  lambda( wrapper );
292  }
293  }
294 
296 
297 protected:
298 
301 
304 
307 
308 private:
310  string_array m_externalPropertyNames;
311 
312 };
313 
314 }
315 
316 #endif /* GEOSX_MESH_CELLBLOCK_HPP_ */
FaceMapType m_toFacesRelation
Element-to-face relation.
Definition: CellBlock.hpp:306
FixedOneToManyRelation & edgeList()
Get the element-to-edge map.
Definition: CellBlock.hpp:242
localIndex GetFaceNodes(localIndex const elementIndex, localIndex const localFaceIndex, localIndex *const nodeIndices) const
Get the local indices of the nodes in a face of the element.
CellBlock()=delete
Deleted default constructor.
localIndex m_numNodesPerElement
Number of nodes per element in this subregion.
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...
T & AddProperty(string const &propertyName)
Add a property to the CellBlock.
Definition: CellBlock.hpp:274
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:38
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data...
Definition: NodeManager.hpp:47
localIndex GetNumFaceNodes(localIndex const elementIndex, localIndex const localFaceIndex) const
Get the number of the nodes in a face of the element.
void calculateElementCenters(arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X) const
Compute the center of each element in the subregion.
Definition: CellBlock.hpp:115
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
void forExternalProperties(LAMBDA &&lambda)
Helper function to apply a lambda function over all the external properties of the subregion...
Definition: CellBlock.hpp:286
std::enable_if_t< _NDIM==1 > emplace_back(ARGS &&... args)
Construct a value in place at the end of the array.
Definition: Array.hpp:461
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
virtual void SetElementType(string const &elementType) override
Set the type of element in this subregion.
virtual void CalculateElementGeometricQuantities(NodeManager const &nodeManager, FaceManager const &facemanager) override
Calculate the geometric quantities for each element in the subregion.
EdgeMapType m_toEdgesRelation
Element-to-edge relation.
Definition: CellBlock.hpp:303
NodeMapType m_toNodesRelation
Element-to-node relation.
Definition: CellBlock.hpp:300
virtual ~CellBlock() override
Destructor.
Base class for all wrappers containing common operations.
Definition: WrapperBase.hpp:48
localIndex & nodeList(localIndex const k, localIndex a)
Get the local index of the a-th node of the k-th element.
Definition: CellBlock.hpp:231
NodeMapType & nodeList()
Get the element-to-node map.
Definition: CellBlock.hpp:218
array2d< real64 > m_elementCenter
Member level field for the element center.
localIndex const & numNodesPerElement() const
Get the number of nodes per element.
FixedOneToManyRelation const & faceList() const
Get the element-to-face map.
Definition: CellBlock.hpp:258
void CalculateCellVolumesKernel(localIndex const k, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X) const
Compute the volume of the k-th element in the subregion.
Definition: CellBlock.hpp:137
#define GEOSX_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:110
virtual void setupRelatedObjectsInRelations(MeshLevel const *const mesh) override
Link the connectivity maps of the subregion to the managers storing the mesh information.
localIndex const & nodeList(localIndex const k, localIndex a) const
Get the local index of the a-th node of the k-th element.
Definition: CellBlock.hpp:236
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers...
Definition: Group.hpp:1301
static const string CatalogName()
Const getter for the catalog name.
Definition: CellBlock.hpp:60
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
array1d< real64 > m_elementVolume
Member level field for the element volume.
FixedOneToManyRelation const & edgeList() const
Get the element-to-edge map.
Definition: CellBlock.hpp:247
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data...
Definition: FaceManager.hpp:40
NodeMapType const & nodeList() const
Get the element-to-node map.
Definition: CellBlock.hpp:223
WrapperBase const * getWrapperBase(indexType const index) const
Retrieve a WrapperBase stored in this group.
Definition: Group.hpp:1058
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
FixedOneToManyRelation & faceList()
Get the element-to-face map.
Definition: CellBlock.hpp:253
virtual const string getCatalogName() const override final
Const getter for the catalog name.
Definition: CellBlock.hpp:66