GEOSX
CellBlock.hpp
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 
15 #ifndef GEOS_MESH_CELLBLOCK_HPP_
16 #define GEOS_MESH_CELLBLOCK_HPP_
17 
18 #include "dataRepository/Group.hpp"
19 #include "mesh/generators/CellBlockABC.hpp"
20 #include "mesh/ElementType.hpp"
21 
22 namespace geos
23 {
24 
29 class CellBlock : public CellBlockABC
30 {
31 public:
32 
37 
43  CellBlock( string const & name, Group * const parent );
44 
46 
51 
53 
57 
64  void setElementType( ElementType elementType );
65 
66  ElementType getElementType() const override
67  { return m_elementType; }
68 
69  localIndex numNodesPerElement() const override
70  { return m_numNodesPerElement; }
71 
72  localIndex numEdgesPerElement() const override
73  { return m_numEdgesPerElement; }
74 
75  localIndex numFacesPerElement() const override
76  { return m_numFacesPerElement; }
77 
78  localIndex numElements() const override
79  { return size(); }
80 
86  { return m_maxNodesPerFace; }
87 
99  localIndex const faceNum,
100  Span< localIndex > nodesInFace ) const;
101 
110  { return m_elementsToNodes; }
111 
117  { return m_elementsToNodes; }
118 
120  { return m_elementsToNodes; }
121 
123  { return m_elementsToEdges; }
124 
126  { return m_elementsToFaces; }
127 
133  { return m_elementsToFaces.toViewConst(); }
134 
141  void setElementToFaces( localIndex const cellIndex,
142  localIndex const faceNum,
143  localIndex const faceIndex )
144  {
145  m_elementsToFaces( cellIndex, faceNum ) = faceIndex;
146  }
147 
157  void setElementToEdges( localIndex const cellIndex,
158  localIndex const edgeNum,
159  localIndex const edgeIndex )
160  {
161  m_elementsToEdges( cellIndex, edgeNum ) = edgeIndex;
162  }
163 
171  bool hasElementToEdges( localIndex const cellIndex,
172  localIndex const edgeNum,
173  localIndex const edgeIndex ) const
174  {
175  return m_elementsToEdges( cellIndex, edgeNum ) == edgeIndex;
176  }
177 
186  { return m_localToGlobalMap; }
187 
189  { return m_localToGlobalMap; }
190 
196  { return m_localToGlobalMap.toViewConst(); }
197 
202  void resize( dataRepository::indexType const numElements ) override final;
203 
208  void resizeNumNodes ( dataRepository::indexType const numNodes );
210 
215 
217 
218 private:
219 
221  localIndex m_numNodesPerElement = -1;
222 
224  localIndex m_numEdgesPerElement = -1;
225 
227  localIndex m_numFacesPerElement = -1;
228 
230  localIndex m_maxNodesPerFace = -1;
231 
234 
236  array2d< localIndex > m_elementsToEdges;
237 
239  array2d< localIndex > m_elementsToFaces;
240 
242  array1d< globalIndex > m_localToGlobalMap;
243 
245  string_array m_externalPropertyNames;
246 
248  ElementType m_elementType;
249 
250  std::list< dataRepository::WrapperBase const * > getExternalProperties() const override
251  {
252  std::list< dataRepository::WrapperBase const * > result;
253  for( string const & externalPropertyName : m_externalPropertyNames )
254  {
255  result.push_back( &this->getWrapperBase( externalPropertyName ) );
256  }
257  return result;
258  }
259 };
260 
261 }
262 
263 #endif /* GEOS_MESH_CELLBLOCK_HPP_ */
localIndex numNodesPerElement() const override
Get the number of nodes per element.
Definition: CellBlock.hpp:69
void setElementToFaces(localIndex const cellIndex, localIndex const faceNum, localIndex const faceIndex)
Sets an entry in the element to faces mapping.
Definition: CellBlock.hpp:141
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:125
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:171
ElementType getElementType() const override
Get the type of element in this subregion.
Definition: CellBlock.hpp:66
localIndex numFacesPerElement() const override
Get the number of faces per element.
Definition: CellBlock.hpp:75
arrayView1d< globalIndex const > localToGlobalMapConstView() const
Get local to global map, const view version.
Definition: CellBlock.hpp:195
arrayView2d< localIndex const, cells::NODE_MAP_USD > getElemToNode() const
Get the element to nodes mapping, const version.
Definition: CellBlock.hpp:116
localIndex numElements() const override
Get the number of elements.
Definition: CellBlock.hpp:78
array1d< globalIndex > localToGlobalMap() const override
Get local to global map.
Definition: CellBlock.hpp:188
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:132
arrayView1d< globalIndex > localToGlobalMap()
Get local to global map, non-const version.
Definition: CellBlock.hpp:185
arrayView2d< localIndex, cells::NODE_MAP_USD > getElemToNode()
Get the element to nodes mapping, non-const version.
Definition: CellBlock.hpp:109
void setElementToEdges(localIndex const cellIndex, localIndex const edgeNum, localIndex const edgeIndex)
Sets an entry in the element to edges mapping.
Definition: CellBlock.hpp:157
localIndex maxNodesPerFace() const
Get the maximum number of nodes comprising a face.
Definition: CellBlock.hpp:85
localIndex numEdgesPerElement() const override
Get the number of edges per element.
Definition: CellBlock.hpp:72
array2d< localIndex > getElemToEdges() const override
Get the element-to-edges map.
Definition: CellBlock.hpp:122
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:119
Lightweight non-owning wrapper over a contiguous range of elements.
Definition: Span.hpp:41
WrapperBase const & getWrapperBase(KEY const &key) const
Return a reference to a WrapperBase stored in this group.
Definition: Group.hpp:1100
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1294
localIndex indexType
The default index type for entries the hierarchy.
Definition: Group.hpp:55
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
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:432
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