GEOS
CellBlockManager.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_CELLBLOCKMANAGER_H_
21 #define GEOS_MESH_CELLBLOCKMANAGER_H_
22 
23 #include "mesh/generators/CellBlock.hpp"
24 #include "mesh/generators/FaceBlock.hpp"
25 #include "mesh/generators/InternalWellGenerator.hpp"
26 #include "mesh/generators/LineBlock.hpp"
27 #include "mesh/generators/LineBlockABC.hpp"
28 #include "mesh/generators/CellBlockManagerABC.hpp"
30 
31 namespace geos
32 {
33 
39 {
40 public:
41 
47  CellBlockManager( string const & name, Group * const parent );
48 
49  virtual Group * createChild( string const & childKey, string const & childName ) override;
50 
55  static constexpr int maxNodesPerFace()
56  { return 64; }
57 
59 
67 
69 
71 
73 
75 
77 
79 
81 
83 
85 
93 
94  std::map< string, SortedArray< localIndex > > const & getNodeSets() const override;
95 
104  std::map< string, SortedArray< localIndex > > & getNodeSets();
105 
114 
116  globalIndex const maxVertexGlobalID,
117  globalIndex const maxEdgeGlobalID,
118  globalIndex const maxFaceGlobalID,
119  arrayView1d< globalIndex const > const edgeLocalToGlobal,
120  arrayView1d< globalIndex const > const faceLocalToGlobal ) override;
121 
122  localIndex numNodes() const override;
123 
124  localIndex numEdges() const override;
125 
126  localIndex numFaces() const override;
127 
128  using Group::resize;
129 
135  void resize( integer_array const & numElements,
136  string_array const & regionNames );
137 
145  void buildMaps();
146 
152  CellBlock & getCellBlock( string const & name )
153  {
154  return this->getGroup( viewKeyStruct::cellBlocks() ).getGroup< CellBlock >( name );
155  }
156 
157  const Group & getCellBlocks() const override;
158 
159  Group & getCellBlocks() override;
160 
161  std::map< integer, std::set< string > > const & getRegionAttributesCellBlocks() const override
162  { return m_regionAttributesCellBlocks; }
163 
164  Group const & getFaceBlocks() const override;
165 
166  Group & getFaceBlocks() override;
167 
168  LineBlockABC const & getLineBlock( string name ) const override;
169 
175  CellBlock & registerCellBlock( string const & name );
176 
183  CellBlock & registerCellBlock( string const & cellBlockName, integer regionAttribute );
184 
190  FaceBlock & registerFaceBlock( string const & name );
191 
197  LineBlock & registerLineBlock( string const & name );
203  template< typename LAMBDA >
204  void forElementSubRegions( LAMBDA lambda )
205  {
206  this->getGroup( viewKeyStruct::cellBlocks() ).forSubGroups< CellBlock >( lambda );
207  }
208 
209  real64 getGlobalLength() const override { return m_globalLength; }
210 
215  void setGlobalLength( real64 globalLength ) { m_globalLength = globalLength; }
216 
217 private:
218 
219  struct viewKeyStruct
220  {
222  static constexpr char const * cellBlocks()
223  { return "cellBlocks"; }
224 
226  static constexpr char const * faceBlocks()
227  { return "faceBlocks"; }
228 
230  static constexpr char const * lineBlocks()
231  { return "lineBlocks"; }
232  };
233 
240  Group & getLineBlocks();
241 
249  CellBlock const & getCellBlock( localIndex const blockIndex ) const;
250 
255  localIndex numCellBlocks() const;
256 
260  void buildNodeToEdges();
261 
265  void buildFaceMaps();
266 
267  template< typename BASEMAP, typename FUNC >
268  void buildToCellMap( localIndex const cellIndex,
269  ToCellRelation< BASEMAP > & toCells,
270  FUNC cellToObjectGetter,
271  localIndex const overAlloc = 0 ) const;
272 
273  array2d< real64, nodes::REFERENCE_POSITION_PERM > m_nodesPositions;
274 
275  ArrayOfArrays< localIndex > m_nodeToEdges;
276  ArrayOfArrays< localIndex > m_edgeToFaces;
277  array2d< localIndex > m_edgeToNodes;
278  ArrayOfArrays< localIndex > m_faceToNodes;
279  ArrayOfArrays< localIndex > m_faceToEdges;
280  ToCellRelation< array2d< localIndex > > m_faceToCells;
281 
282  array1d< globalIndex > m_nodeLocalToGlobal;
283 
284  std::map< string, SortedArray< localIndex > > m_nodeSets;
285 
286  std::map< integer, std::set< string > > m_regionAttributesCellBlocks;
287 
288  real64 m_globalLength;
289 
290  localIndex m_numNodes;
291  localIndex m_numFaces;
292  localIndex m_numEdges;
293 };
294 
295 }
296 #endif /* GEOS_MESH_CELLBLOCKMANAGER_H_ */
Abstract base class for CellBlockManager.
The CellBlockManager class provides an interface to ObjectManagerBase in order to manage CellBlock da...
localIndex numFaces() const override
Total number of faces across all the cell blocks.
array2d< localIndex > getEdgeToNodes() const override
Returns the edge to nodes mapping.
CellBlock & registerCellBlock(string const &name)
Registers and returns a cell block of name name.
ArrayOfArrays< localIndex > getNodeToEdges() const override
Returns the node to edges mapping.
const Group & getCellBlocks() const override
Returns a group containing the cell blocks as CellBlockABC instances.
void setNumNodes(localIndex numNodes)
Defines the number of nodes and resizes some underlying arrays appropriately.
Group const & getFaceBlocks() const override
Returns a group containing the face blocks as FaceBlockABC instances.
ArrayOfArrays< localIndex > getEdgeToFaces() const override
Returns the edge to faces mapping.
ArrayOfArrays< localIndex > getFaceToEdges() const override
Returns the face to edges mapping.
void setGlobalLength(real64 globalLength)
Setter for the global length.
array2d< real64, nodes::REFERENCE_POSITION_PERM > getNodePositions() const override
Returns the node coordinates in a (numNodes, 3) 2d array.
std::map< integer, std::set< string > > const & getRegionAttributesCellBlocks() const override
FaceBlock & registerFaceBlock(string const &name)
Registers and returns a face block of name name.
void forElementSubRegions(LAMBDA lambda)
Launch kernel function over all the sub-regions.
arrayView2d< real64, nodes::REFERENCE_POSITION_USD > getNodePositions()
Returns a view to the vector holding the nodes coordinates.
localIndex numEdges() const override
Total number of edges across all the cell blocks.
LineBlock & registerLineBlock(string const &name)
Registers and returns a line block of name name.
real64 getGlobalLength() const override
Getter for the global length.
ToCellRelation< array2d< localIndex > > getFaceToElements() const override
Returns the face to elements mapping.
std::map< string, SortedArray< localIndex > > & getNodeSets()
Returns a mutable reference to the node sets.
localIndex numNodes() const override
Total number of nodes across all the cell blocks.
ArrayOfArrays< localIndex > getNodeToFaces() const override
Returns the face to nodes mappings.
virtual Group * createChild(string const &childKey, string const &childName) override
Creates a new sub-Group using the ObjectCatalog functionality.
CellBlock & getCellBlock(string const &name)
Get cell block by name.
LineBlockABC const & getLineBlock(string name) const override
Returns LineBlockABC corresponding to the given identifier.
void resize(integer_array const &numElements, string_array const &regionNames)
Set the number of elements for a set of element regions.
CellBlock & registerCellBlock(string const &cellBlockName, integer regionAttribute)
Registers and returns a cell block of name name.
Group & getCellBlocks() override
Returns a group containing the cell blocks as CellBlockABC instances.
ToCellRelation< ArrayOfArrays< localIndex > > getNodeToElements() const override
Returns the node to elements mapping.
static constexpr int maxNodesPerFace()
Maximum number of nodes allowed (in memory) per each face.
ArrayOfArrays< localIndex > getFaceToNodes() const override
Returns the face to nodes mapping.
void generateHighOrderMaps(localIndex const order, globalIndex const maxVertexGlobalID, globalIndex const maxEdgeGlobalID, globalIndex const maxFaceGlobalID, arrayView1d< globalIndex const > const edgeLocalToGlobal, arrayView1d< globalIndex const > const faceLocalToGlobal) override
Generates in place the high-order maps for this cell block manager.
array1d< globalIndex > getNodeLocalToGlobal() const override
The node to global mapping for nodes.
arrayView1d< globalIndex > getNodeLocalToGlobal()
Returns a view to the vector holding the node to global mapping.
std::map< string, SortedArray< localIndex > > const & getNodeSets() const override
Returns the node sets. Key of the map is the name of the set.
CellBlockManager(string const &name, Group *const parent)
Constructor for CellBlockManager object.
Group & getFaceBlocks() override
Returns a group containing the face blocks as FaceBlockABC instances.
void buildMaps()
Trigger the computation of all the mappings.
Simple implementation of the FaceBlockABC contract.
Definition: FaceBlock.hpp:30
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
Group()=delete
Deleted default constructor.
virtual void resize(localIndex const newSize)
Resize the group and all contained wrappers that resize with parent.
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_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:392
array1d< integer > integer_array
A 1-dimensional array of geos::integer types.
Definition: DataTypes.hpp:383
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
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
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:282
Container for maps from a mesh object (node, edge or face) to cells.