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 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 
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 
157 
163  template< typename LAMBDA >
164  void forMaterials( LAMBDA lambda )
165  {
166 
167  for( auto & constitutiveGroup : m_constitutiveGrouping )
168  {
169  lambda( constitutiveGroup );
170  }
171  }
172 
174 
180  {
182  static constexpr char const * constitutivePointVolumeFractionString() { return "ConstitutivePointVolumeFraction"; }
184  static constexpr char const * dNdXString() { return "dNdX"; }
186  static constexpr char const * detJString() { return "detJ"; }
188  static constexpr char const * constitutiveGroupingString() { return "ConstitutiveGrouping"; }
190  static constexpr char const * constitutiveMapString() { return "ConstitutiveMap"; }
192  static constexpr char const * toEmbSurfString() { return "ToEmbeddedSurfaces"; }
194  static constexpr char const * fracturedCellsString() { return "fracturedCells"; }
196  static constexpr char const * bubbleCellsString() { return "bubbleCells"; }
198  static constexpr char const * toFaceElementsString() { return "toFaceElements"; }
199 
204  }
207 
208  virtual viewKeyStruct & viewKeys() override { return m_CellBlockSubRegionViewKeys; }
209  virtual viewKeyStruct const & viewKeys() const override { return m_CellBlockSubRegionViewKeys; }
210 
219  localIndex getFaceNodes( localIndex const elementIndex,
220  localIndex const localFaceIndex,
221  Span< localIndex > const nodeIndices ) const;
222 
227  NodeMapType & nodeList() { return m_toNodesRelation; }
228 
232  NodeMapType const & nodeList() const { return m_toNodesRelation; }
233 
240  localIndex & nodeList( localIndex k, localIndex a ) { return m_toNodesRelation( k, a ); }
241 
245  localIndex const & nodeList( localIndex k, localIndex a ) const { return m_toNodesRelation( k, a ); }
246 
251  FixedOneToManyRelation & edgeList() { return m_toEdgesRelation; }
252 
256  FixedOneToManyRelation const & edgeList() const { return m_toEdgesRelation; }
257 
262  FixedOneToManyRelation & faceList() { return m_toFacesRelation; }
263 
267  FixedOneToManyRelation const & faceList() const { return m_toFacesRelation; }
268 
275  localIndex faceList( localIndex k, localIndex a ) const { return m_toFacesRelation( k, a ); }
276 
281  { return m_dNdX; }
282 
287  { return m_dNdX; }
288 
293  { return m_detJ; }
294 
299  { return m_detJ; }
300 
305  { return m_fracturedCells; }
306 
311  { return m_fracturedCells.toViewConst(); }
312 
316  EmbSurfMapType & embeddedSurfacesList() { return m_toEmbeddedSurfaces; }
317 
321  EmbSurfMapType const & embeddedSurfacesList() const { return m_toEmbeddedSurfaces; }
322 
328  { m_bubbleCells = bubbleCells; }
329 
334  { return m_bubbleCells.toViewConst(); }
335 
341  { m_toFaceElements = faceElemsList; }
342 
347  { return m_toFaceElements.toViewConst(); }
348 
354  {
355  ElementSubRegionBase::calculateElementCenters( m_toNodesRelation, X );
356  }
357 
359  FaceManager const & faceManager ) override;
360 
361 private:
362 
364  map< string, localIndex_array > m_constitutiveGrouping;
365 
367  array3d< real64 > m_constitutivePointVolumeFraction;
368 
370  NodeMapType m_toNodesRelation;
371 
373  EdgeMapType m_toEdgesRelation;
374 
376  FaceMapType m_toFacesRelation;
377 
379  string_array m_externalPropertyNames;
380 
386  void calculateCellVolumesKernel( localIndex const k,
388 
389  void calculateElementCenterAndVolume( localIndex const k,
391 
393  array4d< real64 > m_dNdX;
394 
396  array2d< real64 > m_detJ;
397 
399  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
400 
402  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInEdgelist;
403 
405  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInFacelist;
406 
408  SortedArray< localIndex > m_fracturedCells;
409 
411  EmbSurfMapType m_toEmbeddedSurfaces;
412 
414  array1d< localIndex > m_bubbleCells;
415 
419  array2d< localIndex > m_toFaceElements;
420 
428  template< bool DO_PACKING >
429  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
430  arrayView1d< localIndex const > const & packList ) const;
431 
438  void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
439 
440  template< bool DO_PACKING >
441  localIndex packFracturedElementsImpl( buffer_unit_type * & buffer,
442  arrayView1d< localIndex const > const & packList,
443  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
444 };
445 
446 } /* namespace geos */
447 
448 #endif /* GEOS_MESH_CELLELEMENTSUBREGION_HPP_ */
arrayView2d< real64 const > detJ() const
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
arrayView4d< real64 const > dNdX() 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.
void forMaterials(LAMBDA lambda)
Helper function to apply a lambda function over all constructive groups.
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.
Definition: DataTypes.hpp:329
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1662
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:398
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:192
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:208
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
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:267
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
Definition: DataTypes.hpp:224
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:271
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:228
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:109
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
struct to serve as a container for variable strings and keys
static constexpr char const * toFaceElementsString()
dataRepository::ViewKey constitutiveMap
ViewKey for the constitutive map.
static constexpr char const * bubbleCellsString()
static constexpr char const * dNdXString()
static constexpr char const * constitutiveMapString()
static constexpr char const * constitutiveGroupingString()
static constexpr char const * constitutivePointVolumeFractionString()
dataRepository::ViewKey constitutiveGrouping
ViewKey for the constitutive grouping.
static constexpr char const * detJString()
static constexpr char const * fracturedCellsString()
static constexpr char const * toEmbSurfString()
A struct to serve as a container for variable strings and keys.