GEOS
EdgeManager.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 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 
20 #ifndef GEOS_MESH_EDGEMANAGER_HPP_
21 #define GEOS_MESH_EDGEMANAGER_HPP_
22 
24 #include "mesh/generators/CellBlockManagerABC.hpp"
25 #include "InterObjectRelation.hpp"
26 #include "ToElementRelation.hpp"
27 #include "LvArray/src/tensorOps.hpp"
28 
29 
30 namespace geos
31 {
32 class FaceManager;
33 class NodeManager;
34 
43 {
44 public:
45 
48 
51 
56 
60  static string catalogName()
61  { return "EdgeManager"; }
62 
63 
68  virtual string getCatalogName() const override
69  { return catalogName(); }
70 
72 
79  static constexpr localIndex faceMapOverallocation()
81 
86 
92  EdgeManager( string const & name,
93  Group * const parent );
94 
96 
103  virtual void resize( localIndex const newSize ) override;
104 
109  void setDomainBoundaryObjects( FaceManager const & faceManager );
110 
116  void setIsExternal( FaceManager const & faceManager );
117 
122  void buildSets( NodeManager const & nodeManager );
123 
129  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager, bool isBaseMeshLevel );
130 
139  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
140  FaceManager const & faceManager );
141 
148  void buildEdges( localIndex const numNodes,
149  ArrayOfArraysView< localIndex const > const & faceToNodeMap,
150  ArrayOfArrays< localIndex > & faceToEdgeMap );
151 
152 
160 
167  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
168 
177  arrayView1d< localIndex const > const & packList ) const override;
178 
188  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
189  localIndex_array & packList,
190  bool const overwriteUpMaps,
191  bool const overwriteDownMaps ) override;
192 
197  void fixUpDownMaps( bool const clearIfUnmapped );
198 
204 
210  void depopulateUpMaps( std::set< localIndex > const & receivedEdges,
211  ArrayOfArraysView< localIndex const > const & facesToEdges );
212 
219  bool hasNode( const localIndex edgeIndex, const localIndex nodeIndex ) const;
220 
228  template< typename OUT_VECTOR >
229  void calculateCenter( localIndex const edgeIndex,
231  OUT_VECTOR && edgeCenter ) const;
232 
240  template< typename OUT_VECTOR >
241  void calculateLength( localIndex const edgeIndex,
243  OUT_VECTOR && edgeVector ) const;
244 
249 
255  {
257  static constexpr char const * nodeListString() { return "nodeList"; }
258  static constexpr char const * faceListString() { return "faceList"; }
259  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
260  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
261  static constexpr char const * elementListString() { return "elemList"; }
262 
263  dataRepository::ViewKey nodesList = { nodeListString() };
264  dataRepository::ViewKey faceList = { faceListString() };
265  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
266  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
267  dataRepository::ViewKey elementList = { elementListString() };
269  }
272 
274 
279 
284  NodeMapType & nodeList() { return m_toNodesRelation; }
285 
290  NodeMapType const & nodeList() const { return m_toNodesRelation; }
291 
298  localIndex & nodeList( localIndex const edgeIndex, localIndex const nodeIndex )
299  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
300 
307  localIndex nodeList( localIndex const edgeIndex, localIndex const nodeIndex ) const
308  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
309 
314  FaceMapType & faceList() { return m_toFacesRelation; }
315 
320  FaceMapType const & faceList() const { return m_toFacesRelation; }
321 
323 
324 private:
325 
327  NodeMapType m_toNodesRelation;
328 
330  FaceMapType m_toFacesRelation;
331 
333  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
334 
336  map< localIndex, SortedArray< globalIndex > > m_unmappedGlobalIndicesInToFaces;
337 
346  template< bool DO_PACKING >
347  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
348  arrayView1d< localIndex const > const & packList ) const;
349 
350 };
351 
352 template< typename OUT_VECTOR >
353 inline void EdgeManager::calculateCenter( localIndex const edgeIndex,
355  OUT_VECTOR && edgeCenter ) const
356 {
357  LvArray::tensorOps::copy< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][0]] );
358  LvArray::tensorOps::add< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][1]] );
359  LvArray::tensorOps::scale< 3 >( edgeCenter, 0.5 );
360 }
361 
362 template< typename OUT_VECTOR >
363 inline void EdgeManager::calculateLength( localIndex const edgeIndex,
365  OUT_VECTOR && edgeSegment ) const
366 {
367  LvArray::tensorOps::copy< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][1]] );
368  LvArray::tensorOps::subtract< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][0]] );
369 }
370 
371 }
372 #endif /* GEOS_MESH_EDGEMANAGER_HPP_ */
Abstract base class for CellBlockManager.
static constexpr localIndex faceMapExtraSpacePerEdge()
Extra space for extra edges.
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:43
void setupRelatedObjectsInRelations(NodeManager const &nodeManager, FaceManager const &faceManager)
Link the current manager to other managers.
NodeMapType const & nodeList() const
Provide an accessor to an immutable node list.
static constexpr localIndex faceMapOverallocation()
Oversize the Face mapping by this amount for each edge (hardcoded)
Definition: EdgeManager.hpp:79
FixedOneToManyRelation NodeMapType
EdgeToNode map type.
Definition: EdgeManager.hpp:47
void setIsExternal(FaceManager const &faceManager)
Set external edges.
static string catalogName()
Definition: EdgeManager.hpp:60
void depopulateUpMaps(std::set< localIndex > const &receivedEdges, ArrayOfArraysView< localIndex const > const &facesToEdges)
Clean up the edges-to-faces mapping with respect to a new list of edges.
localIndex & nodeList(localIndex const edgeIndex, localIndex const nodeIndex)
Get a reference to a node list.
void buildEdges(localIndex const numNodes, ArrayOfArraysView< localIndex const > const &faceToNodeMap, ArrayOfArrays< localIndex > &faceToEdgeMap)
Build faces-to-edges and nodes-to-edges relation maps.
virtual localIndex packUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Compute the future size of a packed list.
virtual ArrayOfSets< globalIndex > extractMapFromObjectForAssignGlobalIndexNumbers(ObjectManagerBase const &nodeManager) override
Build a vector containing all the global indices of each nodes of each edges.
void calculateLength(localIndex const edgeIndex, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X, OUT_VECTOR &&edgeVector) const
Calculate the edge segment.
bool hasNode(const localIndex edgeIndex, const localIndex nodeIndex) const
Check if edge edgeIndex contains node nodeIndex.
InterObjectRelation< ArrayOfSets< localIndex > > FaceMapType
EdgeToFace map type.
Definition: EdgeManager.hpp:50
virtual void resize(localIndex const newSize) override
Resize the EdgeManager object and all it members.
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 indices that has been packed.
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Pack an array of edge indices in a buffer.
geos::EdgeManager::viewKeyStruct viewKeys
viewKeys
virtual string getCatalogName() const override
Getter used to access the edge manager catalog name.
Definition: EdgeManager.hpp:68
EdgeManager(string const &name, Group *const parent)
main constructor for EdgeManager Objects
void buildSets(NodeManager const &nodeManager)
Build sets from the node sets.
FaceMapType const & faceList() const
Get an immutable accessor to the edge-to-face relation.
NodeMapType & nodeList()
Get a node list.
void calculateCenter(localIndex const edgeIndex, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X, OUT_VECTOR &&edgeCenter) const
Calculate the center of an edge given its index.
void fixUpDownMaps(bool const clearIfUnmapped)
Call fixUpDownMaps of the class ObjectManagerBase for nodes-to-edges and nodes-to-faces relation maps...
localIndex nodeList(localIndex const edgeIndex, localIndex const nodeIndex) const
Get a node list.
void setGeometricalRelations(CellBlockManagerABC const &cellBlockManager, bool isBaseMeshLevel)
Copies the edges to (nodes|faces) mappings from cellBlockManager.
FaceMapType & faceList()
Get the edge-to-face relation.
void setDomainBoundaryObjects(FaceManager const &faceManager)
Set the node of the domain boundary object.
void compressRelationMaps()
Compress all nodes-to-faces relation maps so that the values of each array are contiguous with no ext...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
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.
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
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
Definition: DataTypes.hpp:286
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::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
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:282
Container of keys needed to access the data of the class member.
struct to serve as a container for variable strings and keys