GEOS
CellBlock.hpp
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 Total, S.A
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 
16 #ifndef GEOS_MESH_CELLBLOCK_HPP_
17 #define GEOS_MESH_CELLBLOCK_HPP_
18 
19 #include "dataRepository/Group.hpp"
20 #include "mesh/generators/CellBlockABC.hpp"
21 #include "mesh/ElementType.hpp"
22 
23 namespace geos
24 {
25 
30 class CellBlock : public CellBlockABC
31 {
32 public:
33 
38 
44  CellBlock( string const & name, Group * const parent );
45 
47 
52 
54 
58 
65  void setElementType( ElementType elementType );
66 
67  ElementType getElementType() const override
68  { return m_elementType; }
69 
70  localIndex numNodesPerElement() const override
71  { return m_numNodesPerElement; }
72 
73  localIndex numEdgesPerElement() const override
74  { return m_numEdgesPerElement; }
75 
76  localIndex numFacesPerElement() const override
77  { return m_numFacesPerElement; }
78 
79  localIndex numElements() const override
80  { return size(); }
81 
87  { return m_maxNodesPerFace; }
88 
100  localIndex const faceNum,
101  Span< localIndex > nodesInFace ) const;
102 
111  { return m_elementsToNodes; }
112 
118  { return m_elementsToNodes; }
119 
121  { return m_elementsToNodes; }
122 
124  { return m_elementsToEdges; }
125 
127  { return m_elementsToFaces; }
128 
134  { return m_elementsToFaces.toViewConst(); }
135 
142  void setElementToFaces( localIndex const cellIndex,
143  localIndex const faceNum,
144  localIndex const faceIndex )
145  {
146  m_elementsToFaces( cellIndex, faceNum ) = faceIndex;
147  }
148 
158  void setElementToEdges( localIndex const cellIndex,
159  localIndex const edgeNum,
160  localIndex const edgeIndex )
161  {
162  m_elementsToEdges( cellIndex, edgeNum ) = edgeIndex;
163  }
164 
172  bool hasElementToEdges( localIndex const cellIndex,
173  localIndex const edgeNum,
174  localIndex const edgeIndex ) const
175  {
176  return m_elementsToEdges( cellIndex, edgeNum ) == edgeIndex;
177  }
178 
187  { return m_localToGlobalMap; }
188 
190  { return m_localToGlobalMap; }
191 
197  { return m_localToGlobalMap.toViewConst(); }
198 
203  void resize( dataRepository::indexType const numElements ) override final;
204 
209  void resizeNumNodes ( dataRepository::indexType const numNodes );
211 
216 
218 
219 private:
220 
222  localIndex m_numNodesPerElement = -1;
223 
225  localIndex m_numEdgesPerElement = -1;
226 
228  localIndex m_numFacesPerElement = -1;
229 
231  localIndex m_maxNodesPerFace = -1;
232 
235 
237  array2d< localIndex > m_elementsToEdges;
238 
240  array2d< localIndex > m_elementsToFaces;
241 
243  array1d< globalIndex > m_localToGlobalMap;
244 
246  string_array m_externalPropertyNames;
247 
249  ElementType m_elementType;
250 
251  std::list< dataRepository::WrapperBase const * > getExternalProperties() const override
252  {
253  std::list< dataRepository::WrapperBase const * > result;
254  for( string const & externalPropertyName : m_externalPropertyNames )
255  {
256  result.push_back( &this->getWrapperBase( externalPropertyName ) );
257  }
258  return result;
259  }
260 };
261 
262 }
263 
264 #endif /* GEOS_MESH_CELLBLOCK_HPP_ */
localIndex numNodesPerElement() const override
Get the number of nodes per element.
Definition: CellBlock.hpp:70
void setElementToFaces(localIndex const cellIndex, localIndex const faceNum, localIndex const faceIndex)
Sets an entry in the element to faces mapping.
Definition: CellBlock.hpp:142
void setElementType(ElementType elementType)
Defines the underlying element type (hex, tet...)
void resize(dataRepository::indexType const numElements) override final
Resize the cell block to hold numElements.
array2d< localIndex > getElemToFaces() const override
Get the element-to-faces map.
Definition: CellBlock.hpp:126
bool hasElementToEdges(localIndex const cellIndex, localIndex const edgeNum, localIndex const edgeIndex) const
Checks if edge edgeIndex of element cellIndex has been defined.
Definition: CellBlock.hpp:172
ElementType getElementType() const override
Get the type of element in this subregion.
Definition: CellBlock.hpp:67
localIndex numFacesPerElement() const override
Get the number of faces per element.
Definition: CellBlock.hpp:76
arrayView1d< globalIndex const > localToGlobalMapConstView() const
Get local to global map, const view version.
Definition: CellBlock.hpp:196
arrayView2d< localIndex const, cells::NODE_MAP_USD > getElemToNode() const
Get the element to nodes mapping, const version.
Definition: CellBlock.hpp:117
localIndex numElements() const override
Get the number of elements.
Definition: CellBlock.hpp:79
array1d< globalIndex > localToGlobalMap() const override
Get local to global map.
Definition: CellBlock.hpp:189
localIndex getFaceNodes(localIndex const cellIndex, localIndex const faceNum, Span< localIndex > nodesInFace) const
Puts the nodes of face faceNum of element cellIndex inside vector nodesInFaces.
CellBlock(string const &name, Group *const parent)
Constructor for this class.
arrayView2d< localIndex const > getElemToFacesConstView() const
Get the element-to-faces map.
Definition: CellBlock.hpp:133
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map, non-const version.
Definition: CellBlock.hpp:186
arrayView2d< localIndex, cells::NODE_MAP_USD > getElemToNode()
Get the element to nodes mapping, non-const version.
Definition: CellBlock.hpp:110
void setElementToEdges(localIndex const cellIndex, localIndex const edgeNum, localIndex const edgeIndex)
Sets an entry in the element to edges mapping.
Definition: CellBlock.hpp:158
localIndex maxNodesPerFace() const
Get the maximum number of nodes comprising a face.
Definition: CellBlock.hpp:86
localIndex numEdgesPerElement() const override
Get the number of edges per element.
Definition: CellBlock.hpp:73
array2d< localIndex > getElemToEdges() const override
Get the element-to-edges map.
Definition: CellBlock.hpp:123
void resizeNumNodes(dataRepository::indexType const numNodes)
Resize the cell block to hold numnodes.
array2d< localIndex, cells::NODE_MAP_PERMUTATION > getElemToNodes() const override
Get the element-to-nodes map.
Definition: CellBlock.hpp:120
Lightweight non-owning wrapper over a contiguous range of elements.
Definition: Span.hpp:42
WrapperBase const & getWrapperBase(KEY const &key) const
Return a reference to a WrapperBase stored in this group.
Definition: Group.hpp:1121
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
localIndex indexType
The default index type for entries the hierarchy.
Definition: Group.hpp:58
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
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
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