GEOS
CellElementSubRegion.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 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 
16 
17 #ifndef GEOS_MESH_CELLELEMENTSUBREGION_HPP_
18 #define GEOS_MESH_CELLELEMENTSUBREGION_HPP_
19 
20 #include "mesh/generators/CellBlockABC.hpp"
21 #include "mesh/NodeManager.hpp"
22 #include "mesh/FaceManager.hpp"
24 #include "ElementSubRegionBase.hpp"
25 
26 
27 namespace geos
28 {
29 
30 class MeshLevel;
31 
38 {
39 public:
40 
49 
54  static string catalogName()
55  { return "CellElementSubRegion"; }
56 
60  virtual string getCatalogName() const override final
61  { return catalogName(); }
62 
67 
73  CellElementSubRegion( string const & name, Group * const parent );
74 
76 
81 
86  void copyFromCellBlock( CellBlockABC const & cellBlock );
87 
89 
95  void addFracturedElement( localIndex const cellElemIndex,
96  localIndex const embSurfIndex );
97 
100  localIndex const numFacesPerElement ) override;
101 
102 
107 
108  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
109 
111  arrayView1d< localIndex const > const & packList ) const override;
112 
113  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
114  array1d< localIndex > & packList,
115  bool const overwriteUpMaps,
116  bool const overwriteDownMaps ) override;
117 
126  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
135  arrayView1d< localIndex const > const & packList,
136  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
137 
146  localIndex_array & packList,
147  unordered_map< globalIndex, localIndex > const & embeddedSurfacesGlobalToLocal );
148 
149  virtual void fixUpDownMaps( bool const clearIfUnmapped ) final override;
150 
152 
158  {
160  static constexpr char const * toEmbSurfString() { return "ToEmbeddedSurfaces"; }
162  static constexpr char const * fracturedCellsString() { return "fracturedCells"; }
164  static constexpr char const * bubbleCellsString() { return "bubbleCells"; }
166  static constexpr char const * toFaceElementsString() { return "toFaceElements"; }
167  }
170 
171  virtual viewKeyStruct & viewKeys() override { return m_CellBlockSubRegionViewKeys; }
172  virtual viewKeyStruct const & viewKeys() const override { return m_CellBlockSubRegionViewKeys; }
173 
182  localIndex getFaceNodes( localIndex const elementIndex,
183  localIndex const localFaceIndex,
184  Span< localIndex > const nodeIndices ) const;
185 
190  NodeMapType & nodeList() { return m_toNodesRelation; }
191 
195  NodeMapType const & nodeList() const { return m_toNodesRelation; }
196 
203  localIndex & nodeList( localIndex k, localIndex a ) { return m_toNodesRelation( k, a ); }
204 
208  localIndex const & nodeList( localIndex k, localIndex a ) const { return m_toNodesRelation( k, a ); }
209 
214  FixedOneToManyRelation & edgeList() { return m_toEdgesRelation; }
215 
219  FixedOneToManyRelation const & edgeList() const { return m_toEdgesRelation; }
220 
225  FixedOneToManyRelation & faceList() { return m_toFacesRelation; }
226 
230  FixedOneToManyRelation const & faceList() const { return m_toFacesRelation; }
231 
238  localIndex faceList( localIndex k, localIndex a ) const { return m_toFacesRelation( k, a ); }
239 
244  { return m_fracturedCells; }
245 
250  { return m_fracturedCells.toViewConst(); }
251 
255  EmbSurfMapType & embeddedSurfacesList() { return m_toEmbeddedSurfaces; }
256 
260  EmbSurfMapType const & embeddedSurfacesList() const { return m_toEmbeddedSurfaces; }
261 
267  { m_bubbleCells = bubbleCells; }
268 
273  { return m_bubbleCells.toViewConst(); }
274 
280  { m_toFaceElements = faceElemsList; }
281 
286  { return m_toFaceElements.toViewConst(); }
287 
293  {
294  ElementSubRegionBase::calculateElementCenters( m_toNodesRelation, X );
295  }
296 
298  FaceManager const & faceManager ) override;
299 
300 private:
301 
303  NodeMapType m_toNodesRelation;
304 
306  EdgeMapType m_toEdgesRelation;
307 
309  FaceMapType m_toFacesRelation;
310 
312  string_array m_externalPropertyNames;
313 
319  void calculateCellVolumesKernel( localIndex const k,
321 
322  void calculateElementCenterAndVolume( localIndex const k,
324 
326  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
327 
329  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInEdgelist;
330 
332  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInFacelist;
333 
335  SortedArray< localIndex > m_fracturedCells;
336 
338  EmbSurfMapType m_toEmbeddedSurfaces;
339 
341  array1d< localIndex > m_bubbleCells;
342 
346  array2d< localIndex > m_toFaceElements;
347 
355  template< bool DO_PACKING >
356  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
357  arrayView1d< localIndex const > const & packList ) const;
358 
365  void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
366 
367  template< bool DO_PACKING >
368  localIndex packFracturedElementsImpl( buffer_unit_type * & buffer,
369  arrayView1d< localIndex const > const & packList,
370  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
371 };
372 
373 } /* namespace geos */
374 
375 #endif /* GEOS_MESH_CELLELEMENTSUBREGION_HPP_ */
void setFaceElementsList(arrayView2d< localIndex const > const faceElemsList)
Set the array of neighboring face elements.
CellElementSubRegion(string const &name, Group *const parent)
Constructor for this class.
NodeMapType const & nodeList() const
Get the element-to-node map.
void addFracturedElement(localIndex const cellElemIndex, localIndex const embSurfIndex)
Add fractured element to list and relative entries to the map.
EmbSurfMapType const & embeddedSurfacesList() const
virtual localIndex packUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Computes the pack size of the specific elements in the @ packList.
localIndex const & nodeList(localIndex k, localIndex a) const
Get the local index of the a-th node of the k-th element.
void calculateElementGeometricQuantities(NodeManager const &nodeManager, FaceManager const &faceManager) override
Calculate the geometric quantities for each element in the subregion.
SortedArrayView< localIndex const > const fracturedElementsList() const
FixedOneToManyRelation & faceList()
Get the element-to-face map.
localIndex faceList(localIndex k, localIndex a) const
Get the local index of the a-th face of the k-th element.
FixedOneToManyRelation & edgeList()
Get the element-to-edge map.
void setBubbleElementsList(arrayView1d< localIndex const > const bubbleCells)
Set the array of bubble elements.
NodeMapType & nodeList()
Get the element-to-node map.
EmbSurfMapType & embeddedSurfacesList()
localIndex packFracturedElements(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList, arrayView1d< globalIndex const > const &embeddedSurfacesLocalToGlobal) const
Packs the set of fractured elements and the element-to-embeddedSurfaces map of the elements in the @ ...
virtual void fixUpDownMaps(bool const clearIfUnmapped) final override
Call ObjectManagerBase::fixUpDownMaps for the connectivity maps needed by the derived class (i....
localIndex getFaceNodes(localIndex const elementIndex, localIndex const localFaceIndex, Span< localIndex > const nodeIndices) const
Get the local indices of the nodes in a face of the element.
arrayView2d< localIndex const > const faceElementsList() const
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Packs the specific elements in the @ packList.
SortedArray< localIndex > & fracturedElementsList()
localIndex & nodeList(localIndex k, localIndex a)
Get the local index of the a-th node of the k-th element.
arrayView1d< localIndex const > const bubbleElementsList() const
virtual string getCatalogName() const override final
Const getter for the catalog name.
FixedOneToManyRelation const & faceList() const
Get the element-to-face map.
void calculateElementCenters(arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X) const
Compute the center of each element in the subregion.
static string catalogName()
Const getter for the catalog name.
virtual void resizePerElementValues(localIndex const numNodesPerElement, localIndex const numEdgesPerElement, localIndex const numFacesPerElement) override
Set all "perElement" values for this subregion.
geos::CellElementSubRegion::viewKeyStruct m_CellBlockSubRegionViewKeys
viewKey struct for the CellElementSubRegion class
localIndex packFracturedElementsSize(arrayView1d< localIndex const > const &packList, arrayView1d< globalIndex const > const &embeddedSurfacesLocalToGlobal) const
Computes the pack size of the set of fractured elements and the element-to-embeddedSurfaces map of th...
virtual viewKeyStruct & viewKeys() override
Get the view keys for Group access.
void copyFromCellBlock(CellBlockABC const &cellBlock)
Fill the CellElementSubRegion by copying those of the source CellBlock.
virtual localIndex unpackUpDownMaps(buffer_unit_type const *&buffer, array1d< localIndex > &packList, bool const overwriteUpMaps, bool const overwriteDownMaps) override
Unpacks the specific elements in the @ packList.
virtual viewKeyStruct const & viewKeys() const override
Get the view keys for Group access, const version.
FixedOneToManyRelation const & edgeList() const
Get the element-to-edge map.
localIndex unpackFracturedElements(buffer_unit_type const *&buffer, localIndex_array &packList, unordered_map< globalIndex, localIndex > const &embeddedSurfacesGlobalToLocal)
Unpacks the set of fractured elemetn and the element-to-embeddedSurfaces map from buffer.
localIndex const & numEdgesPerElement() const
Gets the number of edges per element.
localIndex const & numFacesPerElement() const
Get the number of faces per element.
localIndex const & numNodesPerElement() const
Get the number of nodes per element.
void calculateElementCenters(NODE_MAP const &toNodesRelation, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X) const
Compute the center of each element in the subregion.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
Lightweight non-owning wrapper over a contiguous range of elements.
Definition: Span.hpp:42
Base template for ordered and unordered maps.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
stdVector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:361
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:367
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:191
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:266
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:270
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:108
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
struct to serve as a container for variable strings and keys
static constexpr char const * toFaceElementsString()
static constexpr char const * bubbleCellsString()
static constexpr char const * fracturedCellsString()
static constexpr char const * toEmbSurfString()
A struct to serve as a container for variable strings and keys.