GEOS
FaceManager.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_FACEMANAGER_HPP_
21 #define GEOS_MESH_FACEMANAGER_HPP_
22 
23 #include "mesh/generators/CellBlockManagerABC.hpp"
25 #include "ToElementRelation.hpp"
26 
27 namespace geos
28 {
29 
30 class NodeManager;
31 class EdgeManager;
32 class ElementRegionManager;
33 class CellElementSubRegion;
34 
44 {
45 public:
46 
49 
52 
55 
60 
65  static string catalogName()
66  { return "FaceManager"; }
67 
72  virtual string getCatalogName() const override
73  { return catalogName(); }
75 
82  static constexpr localIndex nodeMapOverallocation()
84 
91  static constexpr localIndex edgeMapOverallocation()
93 
98 
104  FaceManager( string const & name, Group * const parent );
105 
107 
113  virtual void reserve( localIndex const newSize ) override;
114 
120  virtual void resize( localIndex const newsize ) override;
121 
130  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager,
131  ElementRegionManager const & elemRegionManager,
132  NodeManager const & nodeManager, bool isBaseMeshLevel );
133 
140  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
141  EdgeManager const & edgeManager,
142  ElementRegionManager const & elemRegionManager );
143 
148  void computeGeometry( NodeManager const & nodeManager );
149 
156  void setDomainBoundaryObjects( ElementRegionManager const & elemRegionManager );
157 
162  void buildSets( NodeManager const & nodeManager );
163 
169  void sortAllFaceNodes( NodeManager const & nodeManager,
170  ElementRegionManager const & elemManager );
171 
179  arraySlice1d< real64 const > const elementCenter,
180  Span< localIndex > const faceNodes );
181 
186 
192 
200  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
201 
210  arrayView1d< localIndex const > const & packList ) const override;
211 
221  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
222  localIndex_array & packList,
223  bool const overwriteUpMaps,
224  bool const overwriteDownMaps ) override;
225 
231  void fixUpDownMaps( bool const clearIfUnmapped );
232 
234 
241 
246  virtual void enforceStateFieldConsistencyPostTopologyChange( std::set< localIndex > const & targetIndices ) override;
247 
254  void depopulateUpMaps( std::set< localIndex > const & receivedFaces,
255  ElementRegionManager const & elemRegionManager );
256 
257 
258  //void SetGlobalIndexFromCompositionalObject( ObjectManagerBase const * const compositionalObject );
259 
267 
272 
278  {
280  static constexpr char const * nodeListString() { return "nodeList"; }
281  static constexpr char const * edgeListString() { return "edgeList"; }
282  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
283  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
284  static constexpr char const * elementListString() { return "elemList"; }
285  constexpr static char const * faceAreaString() { return "faceArea"; }
286  constexpr static char const * faceCenterString() { return "faceCenter"; }
287  constexpr static char const * faceNormalString() { return "faceNormal"; }
288 
289  dataRepository::ViewKey nodeList = { nodeListString() };
290  dataRepository::ViewKey edgeList = { edgeListString() };
291  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
292  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
293  dataRepository::ViewKey elementList = { elementListString() };
295  }
298 
300 
305 
312  array1d< real64 > & faceArea() { return m_faceArea; }
313 
318  arrayView1d< real64 const > faceArea() const { return m_faceArea; }
319 
326  array2d< real64 > & faceCenter() { return m_faceCenter; }
327 
328 
333  arrayView2d< real64 const > faceCenter() const { return m_faceCenter; }
334 
341  array2d< real64 > & faceNormal() { return m_faceNormal; }
342 
347  arrayView2d< real64 const > faceNormal() const { return m_faceNormal; }
348 
353  NodeMapType & nodeList() { return m_toNodesRelation; }
354 
359  NodeMapType const & nodeList() const { return m_toNodesRelation; }
360 
365  EdgeMapType & edgeList() { return m_toEdgesRelation; }
366 
371  EdgeMapType const & edgeList() const { return m_toEdgesRelation; }
372 
379 
386 
393 
400 
419 
426 
433  ElemMapType & toElementRelation() { return m_toElements; }
434 
441  ElemMapType const & toElementRelation() const { return m_toElements; }
442 
444 
449  constexpr static int maxFaceNodes() { return MAX_FACE_NODES; }
450 private:
451 
460  template< bool DO_PACKING >
461  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
462  arrayView1d< localIndex const > const & packList ) const;
463 
465  NodeMapType m_toNodesRelation;
466 
468  EdgeMapType m_toEdgesRelation;
469 
471  ElemMapType m_toElements;
472 
474  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
475 
477  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToEdges;
478 
480  array1d< real64 > m_faceArea;
481 
483  array2d< real64 > m_faceCenter;
485  array2d< real64 > m_faceNormal;
486 
488  constexpr static int MAX_FACE_NODES = 16;
489 
490 };
491 
492 }
493 #endif /* FACEMANAGERT_H_ */
Abstract base class for CellBlockManager.
static constexpr localIndex edgeMapExtraSpacePerFace()
Extra space for extra faces.
static constexpr localIndex nodeMapExtraSpacePerFace()
Extra space for extra nodes.
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:43
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
FixedToManyElementRelation ElemMapType
FaceToElement map type.
Definition: FaceManager.hpp:54
static constexpr localIndex nodeMapOverallocation()
Get the default number of node per face in node list.
Definition: FaceManager.hpp:82
void sortAllFaceNodes(NodeManager const &nodeManager, ElementRegionManager const &elemManager)
Sort all faces nodes counterclockwisely in m_toNodesRelation.
array2d< localIndex > & elementRegionList()
Get a mutable accessor to the faces-to-ElementRegion relation.
array2d< real64 > & faceNormal()
Get a mutable accessor to an array containing all the face normals.
InterObjectRelation< ArrayOfArrays< localIndex > > EdgeMapType
FaceToEdge map type.
Definition: FaceManager.hpp:51
arrayView2d< real64 const > faceCenter() const
Get an immutable accessor to an array containing all the face centers.
array1d< real64 > & faceArea()
Get a mutable accessor to an array containing all the face area.
virtual void reserve(localIndex const newSize) override
Extend base class reserve method reserving m_toNodesRelation, m_toEdgesRelation member containers.
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Pack an array of node indices into a buffer.
array2d< real64 > & faceCenter()
Get a mutable accessor to an array containing all the face center.
static string catalogName()
Return the name of the FaceManager in the object catalog.
Definition: FaceManager.hpp:65
array2d< localIndex > & elementList()
Get a mutable accessor to the faces-to-element-index relation.
void setupRelatedObjectsInRelations(NodeManager const &nodeManager, EdgeManager const &edgeManager, ElementRegionManager const &elemRegionManager)
Link the current manager to other managers.
NodeMapType & nodeList()
Get a mutable accessor to a map containing the list of each nodes for each faces.
void setGeometricalRelations(CellBlockManagerABC const &cellBlockManager, ElementRegionManager const &elemRegionManager, NodeManager const &nodeManager, bool isBaseMeshLevel)
Copies the nodes positions and the faces to (nodes|edges|elements) mappings from cellBlockManager....
NodeMapType const & nodeList() const
Get an immutable accessor to a map containing the list of each nodes for each faces.
arrayView2d< localIndex const > elementRegionList() const
Get an immutable accessor to the faces-to-ElementRegion relation.
void compressRelationMaps()
Compress FaceManager face-to-node and face-to-edge containers so that the values of each array are co...
virtual localIndex packUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Calculate the size that a list would have if it were packed, but without actually packing it.
ElemMapType const & toElementRelation() const
Get an immutable accessor to the faces-to-element-index relation.
array2d< localIndex > & elementSubRegionList()
Get a mutable accessor to the faces-to-ElementSubRegion relation.
arrayView2d< localIndex const > elementSubRegionList() const
Get an immutable accessor to the faces-to-ElementSubRegion relation.
virtual string getCatalogName() const override
Provide a virtual access to catalogName().
Definition: FaceManager.hpp:72
InterObjectRelation< ArrayOfArrays< localIndex > > NodeMapType
FaceToNode map type.
Definition: FaceManager.hpp:48
virtual localIndex unpackUpDownMaps(buffer_unit_type const *&buffer, localIndex_array &packList, bool const overwriteUpMaps, bool const overwriteDownMaps) override
Unpack a buffer to an array of node indices.
virtual void enforceStateFieldConsistencyPostTopologyChange(std::set< localIndex > const &targetIndices) override
Enforce child faces and parent faces to have opposite normals.
static constexpr localIndex edgeMapOverallocation()
Get the default number of edge per face in edge list.
Definition: FaceManager.hpp:91
void setDomainBoundaryObjects(ElementRegionManager const &elemRegionManager)
Builds the face-on-domain-boundary indicator.
void buildSets(NodeManager const &nodeManager)
Build sets from the node sets.
virtual void resize(localIndex const newsize) override
Extend base class resize method resizing m_toNodesRelation, m_toEdgesRelation member containers.
geos::FaceManager::viewKeyStruct viewKeys
viewKeys
ElemMapType & toElementRelation()
Get a mutable accessor to the faces-to-element-index relation.
void depopulateUpMaps(std::set< localIndex > const &receivedFaces, ElementRegionManager const &elemRegionManager)
Clean up the mappings from faces to element index, region, subregion on a new (updated) list of faces...
static void sortFaceNodes(arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X, arraySlice1d< real64 const > const elementCenter, Span< localIndex > const faceNodes)
Reorder face nodes to be labeled counter-clockwise resulting in outgoing normal.
FaceManager(string const &name, Group *const parent)
Main Constructor for FaceManager.
arrayView2d< localIndex const > elementList() const
Get an imutable accessor to the faces-to-element-index relation.
void computeGeometry(NodeManager const &nodeManager)
Compute faces center, area and normal.
void setIsExternal()
Flag faces on boundary or external to the DomainPartition.
virtual ArrayOfSets< globalIndex > extractMapFromObjectForAssignGlobalIndexNumbers(ObjectManagerBase const &nodeManager) override
Extract a face-to-nodes map with global indexed for boundary faces.
arrayView2d< real64 const > faceNormal() const
Get an immutable accessor to an array containing all the face normals.
void fixUpDownMaps(bool const clearIfUnmapped)
Call fixUpDownMaps for nodes-to-edges and nodes-to-faces maps.
arrayView1d< real64 const > faceArea() const
Get an immutable accessor to an array containing all the face area.
EdgeMapType & edgeList()
Get a mutable accessor to a map containing the list of each edges for each faces.
EdgeMapType const & edgeList() const
Get an immutable accessor to a map containing the list of each edges for each faces.
constexpr static int maxFaceNodes()
}@
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
Lightweight non-owning wrapper over a contiguous range of elements.
Definition: Span.hpp:42
BASETYPE m_toElementIndex
The relationship between object indices and element indices.
BASETYPE m_toElementSubRegion
The relationship between object indices and element subregions.
BASETYPE m_toElementRegion
The relationship between object indices and element regions.
Base template for ordered and unordered maps.
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1666
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
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
ToElementRelation< array2d< localIndex > > FixedToManyElementRelation
A ToElementRelation where each object is related to the same number of elements.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:183
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Definition: DataTypes.hpp:289
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