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 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_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 reserve( localIndex const newSize ) override;
104 
111  virtual void resize( localIndex const newSize ) override;
112 
117  void setDomainBoundaryObjects( FaceManager const & faceManager );
118 
124  void setIsExternal( FaceManager const & faceManager );
125 
130  void buildSets( NodeManager const & nodeManager );
131 
137  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager, bool isBaseMeshLevel );
138 
147  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
148  FaceManager const & faceManager );
149 
156  void buildEdges( localIndex const numNodes,
157  ArrayOfArraysView< localIndex const > const & faceToNodeMap,
158  ArrayOfArrays< localIndex > & faceToEdgeMap );
159 
160 
168 
175  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
176 
185  arrayView1d< localIndex const > const & packList ) const override;
186 
196  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
197  localIndex_array & packList,
198  bool const overwriteUpMaps,
199  bool const overwriteDownMaps ) override;
200 
205  void fixUpDownMaps( bool const clearIfUnmapped );
206 
212 
218  void depopulateUpMaps( std::set< localIndex > const & receivedEdges,
219  ArrayOfArraysView< localIndex const > const & facesToEdges );
220 
227  bool hasNode( const localIndex edgeIndex, const localIndex nodeIndex ) const;
228 
236  template< typename OUT_VECTOR >
237  void calculateCenter( localIndex const edgeIndex,
239  OUT_VECTOR && edgeCenter ) const;
240 
248  template< typename OUT_VECTOR >
249  void calculateLength( localIndex const edgeIndex,
251  OUT_VECTOR && edgeVector ) const;
252 
257 
263  {
265  static constexpr char const * nodeListString() { return "nodeList"; }
266  static constexpr char const * faceListString() { return "faceList"; }
267  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
268  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
269  static constexpr char const * elementListString() { return "elemList"; }
270 
271  dataRepository::ViewKey nodesList = { nodeListString() };
272  dataRepository::ViewKey faceList = { faceListString() };
273  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
274  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
275  dataRepository::ViewKey elementList = { elementListString() };
277  }
280 
282 
287 
292  NodeMapType & nodeList() { return m_toNodesRelation; }
293 
298  NodeMapType const & nodeList() const { return m_toNodesRelation; }
299 
306  localIndex & nodeList( localIndex const edgeIndex, localIndex const nodeIndex )
307  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
308 
315  localIndex nodeList( localIndex const edgeIndex, localIndex const nodeIndex ) const
316  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
317 
322  FaceMapType & faceList() { return m_toFacesRelation; }
323 
328  FaceMapType const & faceList() const { return m_toFacesRelation; }
329 
331 
332 private:
333 
335  NodeMapType m_toNodesRelation;
336 
338  FaceMapType m_toFacesRelation;
339 
341  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
342 
344  map< localIndex, SortedArray< globalIndex > > m_unmappedGlobalIndicesInToFaces;
345 
354  template< bool DO_PACKING >
355  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
356  arrayView1d< localIndex const > const & packList ) const;
357 
358 };
359 
360 template< typename OUT_VECTOR >
361 inline void EdgeManager::calculateCenter( localIndex const edgeIndex,
363  OUT_VECTOR && edgeCenter ) const
364 {
365  LvArray::tensorOps::copy< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][0]] );
366  LvArray::tensorOps::add< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][1]] );
367  LvArray::tensorOps::scale< 3 >( edgeCenter, 0.5 );
368 }
369 
370 template< typename OUT_VECTOR >
371 inline void EdgeManager::calculateLength( localIndex const edgeIndex,
373  OUT_VECTOR && edgeSegment ) const
374 {
375  LvArray::tensorOps::copy< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][1]] );
376  LvArray::tensorOps::subtract< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][0]] );
377 }
378 
379 }
380 #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 void reserve(localIndex const newSize) override
Reserve 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.
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
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:285
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
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: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
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:281
Container of keys needed to access the data of the class member.
struct to serve as a container for variable strings and keys