GEOSX
CellBlockManager.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_CELLBLOCKMANAGER_H_
20 #define GEOS_MESH_CELLBLOCKMANAGER_H_
21 
22 #include "mesh/generators/CellBlock.hpp"
23 #include "mesh/generators/FaceBlock.hpp"
24 #include "mesh/generators/InternalWellGenerator.hpp"
25 #include "mesh/generators/LineBlock.hpp"
26 #include "mesh/generators/LineBlockABC.hpp"
27 #include "mesh/generators/CellBlockManagerABC.hpp"
29 
30 namespace geos
31 {
32 
38 {
39 public:
40 
46  CellBlockManager( string const & name, Group * const parent );
47 
48  virtual Group * createChild( string const & childKey, string const & childName ) override;
49 
54  static constexpr int maxNodesPerFace()
55  { return 64; }
56 
58 
66 
68 
70 
72 
74 
76 
78 
80 
82 
84 
92 
93  std::map< string, SortedArray< localIndex > > const & getNodeSets() const override;
94 
103  std::map< string, SortedArray< localIndex > > & getNodeSets();
104 
113 
115  globalIndex const maxVertexGlobalID,
116  globalIndex const maxEdgeGlobalID,
117  globalIndex const maxFaceGlobalID,
118  arrayView1d< globalIndex const > const edgeLocalToGlobal,
119  arrayView1d< globalIndex const > const faceLocalToGlobal ) override;
120 
121  localIndex numNodes() const override;
122 
123  localIndex numEdges() const override;
124 
125  localIndex numFaces() const override;
126 
127  using Group::resize;
128 
134  void resize( integer_array const & numElements,
135  string_array const & regionNames );
136 
144  void buildMaps();
145 
151  CellBlock & getCellBlock( string const & name )
152  {
153  return this->getGroup( viewKeyStruct::cellBlocks() ).getGroup< CellBlock >( name );
154  }
155 
156  const Group & getCellBlocks() const override;
157 
158  Group & getCellBlocks() override;
159 
160  Group const & getFaceBlocks() const override;
161 
162  Group & getFaceBlocks() override;
163 
164  LineBlockABC const & getLineBlock( string name ) const override;
165 
171  CellBlock & registerCellBlock( string const & name );
172 
178  FaceBlock & registerFaceBlock( string const & name );
179 
185  LineBlock & registerLineBlock( string const & name );
191  template< typename LAMBDA >
192  void forElementSubRegions( LAMBDA lambda )
193  {
194  this->getGroup( viewKeyStruct::cellBlocks() ).forSubGroups< CellBlock >( lambda );
195  }
196 
197  real64 getGlobalLength() const override { return m_globalLength; }
198 
203  void setGlobalLength( real64 globalLength ) { m_globalLength = globalLength; }
204 
205 private:
206 
207  struct viewKeyStruct
208  {
210  static constexpr char const * cellBlocks()
211  { return "cellBlocks"; }
212 
214  static constexpr char const * faceBlocks()
215  { return "faceBlocks"; }
216 
218  static constexpr char const * lineBlocks()
219  { return "lineBlocks"; }
220  };
221 
228  Group & getLineBlocks();
229 
237  CellBlock const & getCellBlock( localIndex const blockIndex ) const;
238 
243  localIndex numCellBlocks() const;
244 
248  void buildNodeToEdges();
249 
253  void buildFaceMaps();
254 
255  template< typename BASEMAP, typename FUNC >
256  void buildToCellMap( localIndex const cellIndex,
257  ToCellRelation< BASEMAP > & toCells,
258  FUNC cellToObjectGetter,
259  localIndex const overAlloc = 0 ) const;
260 
261  array2d< real64, nodes::REFERENCE_POSITION_PERM > m_nodesPositions;
262 
263  ArrayOfArrays< localIndex > m_nodeToEdges;
264  ArrayOfArrays< localIndex > m_edgeToFaces;
265  array2d< localIndex > m_edgeToNodes;
266  ArrayOfArrays< localIndex > m_faceToNodes;
267  ArrayOfArrays< localIndex > m_faceToEdges;
268  ToCellRelation< array2d< localIndex > > m_faceToCells;
269 
270  array1d< globalIndex > m_nodeLocalToGlobal;
271 
272  std::map< string, SortedArray< localIndex > > m_nodeSets;
273 
274  real64 m_globalLength;
275 
276  localIndex m_numNodes;
277  localIndex m_numFaces;
278  localIndex m_numEdges;
279 };
280 
281 }
282 #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.
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.
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:29
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:333
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: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
array1d< integer > integer_array
A 1-dimensional array of geos::integer types.
Definition: DataTypes.hpp:423
double real64
64-bit floating point type.
Definition: DataTypes.hpp:139
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
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
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:322
Container for maps from a mesh object (node, edge or face) to cells.