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 resize( localIndex const newsize ) override;
114 
123  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager,
124  ElementRegionManager const & elemRegionManager,
125  NodeManager const & nodeManager, bool isBaseMeshLevel );
126 
133  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
134  EdgeManager const & edgeManager,
135  ElementRegionManager const & elemRegionManager );
136 
141  void computeGeometry( NodeManager const & nodeManager );
142 
149  void setDomainBoundaryObjects( ElementRegionManager const & elemRegionManager );
150 
155  void buildSets( NodeManager const & nodeManager );
156 
162  void sortAllFaceNodes( NodeManager const & nodeManager,
163  ElementRegionManager const & elemManager );
164 
172  arraySlice1d< real64 const > const elementCenter,
173  Span< localIndex > const faceNodes );
174 
179 
185 
193  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
194 
203  arrayView1d< localIndex const > const & packList ) const override;
204 
214  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
215  localIndex_array & packList,
216  bool const overwriteUpMaps,
217  bool const overwriteDownMaps ) override;
218 
224  void fixUpDownMaps( bool const clearIfUnmapped );
225 
227 
234 
239  virtual void enforceStateFieldConsistencyPostTopologyChange( std::set< localIndex > const & targetIndices ) override;
240 
247  void depopulateUpMaps( std::set< localIndex > const & receivedFaces,
248  ElementRegionManager const & elemRegionManager );
249 
250 
251  //void SetGlobalIndexFromCompositionalObject( ObjectManagerBase const * const compositionalObject );
252 
260 
265 
271  {
273  static constexpr char const * nodeListString() { return "nodeList"; }
274  static constexpr char const * edgeListString() { return "edgeList"; }
275  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
276  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
277  static constexpr char const * elementListString() { return "elemList"; }
278  constexpr static char const * faceAreaString() { return "faceArea"; }
279  constexpr static char const * faceCenterString() { return "faceCenter"; }
280  constexpr static char const * faceNormalString() { return "faceNormal"; }
281 
282  dataRepository::ViewKey nodeList = { nodeListString() };
283  dataRepository::ViewKey edgeList = { edgeListString() };
284  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
285  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
286  dataRepository::ViewKey elementList = { elementListString() };
288  }
291 
293 
298 
305  array1d< real64 > & faceArea() { return m_faceArea; }
306 
311  arrayView1d< real64 const > faceArea() const { return m_faceArea; }
312 
319  array2d< real64 > & faceCenter() { return m_faceCenter; }
320 
321 
326  arrayView2d< real64 const > faceCenter() const { return m_faceCenter; }
327 
334  array2d< real64 > & faceNormal() { return m_faceNormal; }
335 
340  arrayView2d< real64 const > faceNormal() const { return m_faceNormal; }
341 
346  NodeMapType & nodeList() { return m_toNodesRelation; }
347 
352  NodeMapType const & nodeList() const { return m_toNodesRelation; }
353 
358  EdgeMapType & edgeList() { return m_toEdgesRelation; }
359 
364  EdgeMapType const & edgeList() const { return m_toEdgesRelation; }
365 
372 
379 
386 
393 
412 
419 
426  ElemMapType & toElementRelation() { return m_toElements; }
427 
434  ElemMapType const & toElementRelation() const { return m_toElements; }
435 
437 
442  constexpr static int maxFaceNodes() { return MAX_FACE_NODES; }
443 private:
444 
453  template< bool DO_PACKING >
454  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
455  arrayView1d< localIndex const > const & packList ) const;
456 
458  NodeMapType m_toNodesRelation;
459 
461  EdgeMapType m_toEdgesRelation;
462 
464  ElemMapType m_toElements;
465 
467  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
468 
470  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToEdges;
471 
473  array1d< real64 > m_faceArea;
474 
476  array2d< real64 > m_faceCenter;
478  array2d< real64 > m_faceNormal;
479 
481  constexpr static int MAX_FACE_NODES = 16;
482 
483 };
484 
485 }
486 #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 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.
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
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:85
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:184
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Definition: DataTypes.hpp:290
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