GEOSX
FaceManager.hpp
Go to the documentation of this file.
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 
19 #ifndef GEOS_MESH_FACEMANAGER_HPP_
20 #define GEOS_MESH_FACEMANAGER_HPP_
21 
22 #include "mesh/generators/CellBlockManagerABC.hpp"
24 #include "ToElementRelation.hpp"
25 
26 namespace geos
27 {
28 
29 class NodeManager;
30 class EdgeManager;
31 class ElementRegionManager;
32 class CellElementSubRegion;
33 
43 {
44 public:
45 
48 
51 
54 
59 
64  static string catalogName()
65  { return "FaceManager"; }
66 
71  virtual string getCatalogName() const override
72  { return catalogName(); }
74 
81  static constexpr localIndex nodeMapOverallocation()
83 
90  static constexpr localIndex edgeMapOverallocation()
92 
97 
103  FaceManager( string const & name, Group * const parent );
104 
106 
112  virtual void resize( localIndex const newsize ) override;
113 
122  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager,
123  ElementRegionManager const & elemRegionManager,
124  NodeManager const & nodeManager, bool isBaseMeshLevel );
125 
132  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
133  EdgeManager const & edgeManager,
134  ElementRegionManager const & elemRegionManager );
135 
140  void computeGeometry( NodeManager const & nodeManager );
141 
148  void setDomainBoundaryObjects( ElementRegionManager const & elemRegionManager );
149 
154  void buildSets( NodeManager const & nodeManager );
155 
161  void sortAllFaceNodes( NodeManager const & nodeManager,
162  ElementRegionManager const & elemManager );
163 
171  arraySlice1d< real64 const > const elementCenter,
172  Span< localIndex > const faceNodes );
173 
178 
184 
192  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
193 
202  arrayView1d< localIndex const > const & packList ) const override;
203 
213  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
214  localIndex_array & packList,
215  bool const overwriteUpMaps,
216  bool const overwriteDownMaps ) override;
217 
223  void fixUpDownMaps( bool const clearIfUnmapped );
224 
226 
233 
238  virtual void enforceStateFieldConsistencyPostTopologyChange( std::set< localIndex > const & targetIndices ) override;
239 
246  void depopulateUpMaps( std::set< localIndex > const & receivedFaces,
247  ElementRegionManager const & elemRegionManager );
248 
249 
250  //void SetGlobalIndexFromCompositionalObject( ObjectManagerBase const * const compositionalObject );
251 
259 
264 
270  {
272  static constexpr char const * nodeListString() { return "nodeList"; }
273  static constexpr char const * edgeListString() { return "edgeList"; }
274  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
275  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
276  static constexpr char const * elementListString() { return "elemList"; }
277  constexpr static char const * faceAreaString() { return "faceArea"; }
278  constexpr static char const * faceCenterString() { return "faceCenter"; }
279  constexpr static char const * faceNormalString() { return "faceNormal"; }
280 
281  dataRepository::ViewKey nodeList = { nodeListString() };
282  dataRepository::ViewKey edgeList = { edgeListString() };
283  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
284  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
285  dataRepository::ViewKey elementList = { elementListString() };
287  }
290 
292 
297 
304  array1d< real64 > & faceArea() { return m_faceArea; }
305 
310  arrayView1d< real64 const > faceArea() const { return m_faceArea; }
311 
318  array2d< real64 > & faceCenter() { return m_faceCenter; }
319 
320 
325  arrayView2d< real64 const > faceCenter() const { return m_faceCenter; }
326 
333  array2d< real64 > & faceNormal() { return m_faceNormal; }
334 
339  arrayView2d< real64 const > faceNormal() const { return m_faceNormal; }
340 
345  NodeMapType & nodeList() { return m_toNodesRelation; }
346 
351  NodeMapType const & nodeList() const { return m_toNodesRelation; }
352 
357  EdgeMapType & edgeList() { return m_toEdgesRelation; }
358 
363  EdgeMapType const & edgeList() const { return m_toEdgesRelation; }
364 
371 
378 
385 
392 
411 
418 
425  ElemMapType & toElementRelation() { return m_toElements; }
426 
433  ElemMapType const & toElementRelation() const { return m_toElements; }
434 
436 
437 private:
438 
447  template< bool DO_PACKING >
448  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
449  arrayView1d< localIndex const > const & packList ) const;
450 
452  NodeMapType m_toNodesRelation;
453 
455  EdgeMapType m_toEdgesRelation;
456 
458  ElemMapType m_toElements;
459 
461  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
462 
464  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToEdges;
465 
467  array1d< real64 > m_faceArea;
468 
470  array2d< real64 > m_faceCenter;
472  array2d< real64 > m_faceNormal;
473 
475  constexpr static int MAX_FACE_NODES = 16;
476 
477 };
478 
479 }
480 #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:42
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:43
FixedToManyElementRelation ElemMapType
FaceToElement map type.
Definition: FaceManager.hpp:53
static constexpr localIndex nodeMapOverallocation()
Get the default number of node per face in node list.
Definition: FaceManager.hpp:81
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:50
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:64
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:71
InterObjectRelation< ArrayOfArrays< localIndex > > NodeMapType
FaceToNode map type.
Definition: FaceManager.hpp:47
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:90
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.
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
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:41
A relationship to an element.
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: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
ToElementRelation< array2d< localIndex > > FixedToManyElementRelation
A ToElementRelation where each object is related to the same number of elements.
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:224
LvArray::ArrayOfSets< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
Definition: DataTypes.hpp:330
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