GEOSX
CellElementSubRegion.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 
16 #ifndef GEOS_MESH_CELLELEMENTSUBREGION_HPP_
17 #define GEOS_MESH_CELLELEMENTSUBREGION_HPP_
18 
19 #include "mesh/generators/CellBlockABC.hpp"
20 #include "mesh/NodeManager.hpp"
21 #include "mesh/FaceManager.hpp"
23 #include "ElementSubRegionBase.hpp"
24 
25 
26 namespace geos
27 {
28 
29 class MeshLevel;
30 
37 {
38 public:
39 
48 
53  static string catalogName()
54  { return "CellElementSubRegion"; }
55 
59  virtual string getCatalogName() const override final
60  { return catalogName(); }
61 
66 
72  CellElementSubRegion( string const & name, Group * const parent );
73 
75 
80 
85  void copyFromCellBlock( CellBlockABC const & cellBlock );
86 
88 
94  void addFracturedElement( localIndex const cellElemIndex,
95  localIndex const embSurfIndex );
96 
99  localIndex const numFacesPerElement ) override;
100 
101 
106 
107  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
108 
110  arrayView1d< localIndex const > const & packList ) const override;
111 
112  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
113  array1d< localIndex > & packList,
114  bool const overwriteUpMaps,
115  bool const overwriteDownMaps ) override;
116 
125  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
134  arrayView1d< localIndex const > const & packList,
135  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
136 
145  localIndex_array & packList,
146  unordered_map< globalIndex, localIndex > const & embeddedSurfacesGlobalToLocal );
147 
148  virtual void fixUpDownMaps( bool const clearIfUnmapped ) final override;
149 
151 
156 
162  template< typename LAMBDA >
163  void forMaterials( LAMBDA lambda )
164  {
165 
166  for( auto & constitutiveGroup : m_constitutiveGrouping )
167  {
168  lambda( constitutiveGroup );
169  }
170  }
171 
173 
179  {
181  static constexpr char const * constitutivePointVolumeFractionString() { return "ConstitutivePointVolumeFraction"; }
183  static constexpr char const * dNdXString() { return "dNdX"; }
185  static constexpr char const * detJString() { return "detJ"; }
187  static constexpr char const * constitutiveGroupingString() { return "ConstitutiveGrouping"; }
189  static constexpr char const * constitutiveMapString() { return "ConstitutiveMap"; }
191  static constexpr char const * toEmbSurfString() { return "ToEmbeddedSurfaces"; }
193  static constexpr char const * fracturedCellsString() { return "fracturedCells"; }
194 
199  }
202 
203  virtual viewKeyStruct & viewKeys() override { return m_CellBlockSubRegionViewKeys; }
204  virtual viewKeyStruct const & viewKeys() const override { return m_CellBlockSubRegionViewKeys; }
205 
214  localIndex getFaceNodes( localIndex const elementIndex,
215  localIndex const localFaceIndex,
216  Span< localIndex > const nodeIndices ) const;
217 
222  NodeMapType & nodeList() { return m_toNodesRelation; }
223 
227  NodeMapType const & nodeList() const { return m_toNodesRelation; }
228 
235  localIndex & nodeList( localIndex k, localIndex a ) { return m_toNodesRelation( k, a ); }
236 
240  localIndex const & nodeList( localIndex k, localIndex a ) const { return m_toNodesRelation( k, a ); }
241 
246  FixedOneToManyRelation & edgeList() { return m_toEdgesRelation; }
247 
251  FixedOneToManyRelation const & edgeList() const { return m_toEdgesRelation; }
252 
257  FixedOneToManyRelation & faceList() { return m_toFacesRelation; }
258 
262  FixedOneToManyRelation const & faceList() const { return m_toFacesRelation; }
263 
270  localIndex faceList( localIndex k, localIndex a ) const { return m_toFacesRelation( k, a ); }
271 
276  { return m_dNdX; }
277 
282  { return m_dNdX; }
283 
288  { return m_detJ; }
289 
294  { return m_detJ; }
295 
300  { return m_fracturedCells; }
301 
306  { return m_fracturedCells.toViewConst(); }
307 
311  EmbSurfMapType & embeddedSurfacesList() { return m_toEmbeddedSurfaces; }
312 
316  EmbSurfMapType const & embeddedSurfacesList() const { return m_toEmbeddedSurfaces; }
317 
323  {
324  ElementSubRegionBase::calculateElementCenters( m_toNodesRelation, X );
325  }
326 
328  FaceManager const & faceManager ) override;
329 
330 private:
331 
333  map< string, localIndex_array > m_constitutiveGrouping;
334 
336  array3d< real64 > m_constitutivePointVolumeFraction;
337 
339  NodeMapType m_toNodesRelation;
340 
342  EdgeMapType m_toEdgesRelation;
343 
345  FaceMapType m_toFacesRelation;
346 
348  string_array m_externalPropertyNames;
349 
355  void calculateCellVolumesKernel( localIndex const k,
357 
358  void calculateElementCenterAndVolume( localIndex const k,
360 
362  array4d< real64 > m_dNdX;
363 
365  array2d< real64 > m_detJ;
366 
368  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
369 
371  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInEdgelist;
372 
374  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInFacelist;
375 
377  SortedArray< localIndex > m_fracturedCells;
378 
380  EmbSurfMapType m_toEmbeddedSurfaces;
381 
389  template< bool DO_PACKING >
390  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
391  arrayView1d< localIndex const > const & packList ) const;
392 
399  void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
400 
401  template< bool DO_PACKING >
402  localIndex packFracturedElementsImpl( buffer_unit_type * & buffer,
403  arrayView1d< localIndex const > const & packList,
404  arrayView1d< globalIndex const > const & embeddedSurfacesLocalToGlobal ) const;
405 };
406 
407 } /* namespace geos */
408 
409 #endif /* GEOS_MESH_CELLELEMENTSUBREGION_HPP_ */
arrayView2d< real64 const > detJ() const
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.
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.
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.
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:43
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:41
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
Lightweight non-owning wrapper over a contiguous range of elements.
Definition: Span.hpp:41
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:369
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1625
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
array1d< localIndex > localIndex_array
A 1-dimensional array of geos::localIndex types.
Definition: DataTypes.hpp:438
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:232
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:248
array1d< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:432
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:307
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
Definition: DataTypes.hpp:264
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:311
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:268
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:149
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
struct to serve as a container for variable strings and keys
dataRepository::ViewKey constitutiveMap
ViewKey for the constitutive map.
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.