GEOSX
EdgeManager.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_EDGEMANAGER_HPP_
20 #define GEOS_MESH_EDGEMANAGER_HPP_
21 
23 #include "mesh/generators/CellBlockManagerABC.hpp"
24 #include "InterObjectRelation.hpp"
25 #include "ToElementRelation.hpp"
26 #include "LvArray/src/tensorOps.hpp"
27 
28 
29 namespace geos
30 {
31 class FaceManager;
32 class NodeManager;
33 
42 {
43 public:
44 
47 
50 
55 
59  static string catalogName()
60  { return "EdgeManager"; }
61 
62 
67  virtual string getCatalogName() const override
68  { return catalogName(); }
69 
71 
78  static constexpr localIndex faceMapOverallocation()
80 
85 
91  EdgeManager( string const & name,
92  Group * const parent );
93 
95 
102  virtual void resize( localIndex const newSize ) override;
103 
108  void setDomainBoundaryObjects( FaceManager const & faceManager );
109 
115  void setIsExternal( FaceManager const & faceManager );
116 
121  void buildSets( NodeManager const & nodeManager );
122 
128  void setGeometricalRelations( CellBlockManagerABC const & cellBlockManager, bool isBaseMeshLevel );
129 
138  void setupRelatedObjectsInRelations( NodeManager const & nodeManager,
139  FaceManager const & faceManager );
140 
147  void buildEdges( localIndex const numNodes,
148  ArrayOfArraysView< localIndex const > const & faceToNodeMap,
149  ArrayOfArrays< localIndex > & faceToEdgeMap );
150 
151 
159 
166  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
167 
176  arrayView1d< localIndex const > const & packList ) const override;
177 
187  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
188  localIndex_array & packList,
189  bool const overwriteUpMaps,
190  bool const overwriteDownMaps ) override;
191 
196  void fixUpDownMaps( bool const clearIfUnmapped );
197 
203 
209  void depopulateUpMaps( std::set< localIndex > const & receivedEdges,
210  ArrayOfArraysView< localIndex const > const & facesToEdges );
211 
218  bool hasNode( const localIndex edgeIndex, const localIndex nodeIndex ) const;
219 
227  template< typename OUT_VECTOR >
228  void calculateCenter( localIndex const edgeIndex,
230  OUT_VECTOR && edgeCenter ) const;
231 
239  template< typename OUT_VECTOR >
240  void calculateLength( localIndex const edgeIndex,
242  OUT_VECTOR && edgeVector ) const;
243 
248 
254  {
256  static constexpr char const * nodeListString() { return "nodeList"; }
257  static constexpr char const * faceListString() { return "faceList"; }
258  static constexpr char const * elementRegionListString() { return "elemRegionList"; }
259  static constexpr char const * elementSubRegionListString() { return "elemSubRegionList"; }
260  static constexpr char const * elementListString() { return "elemList"; }
261 
262  dataRepository::ViewKey nodesList = { nodeListString() };
263  dataRepository::ViewKey faceList = { faceListString() };
264  dataRepository::ViewKey elementRegionList = { elementRegionListString() };
265  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString() };
266  dataRepository::ViewKey elementList = { elementListString() };
268  }
271 
273 
278 
283  NodeMapType & nodeList() { return m_toNodesRelation; }
284 
289  NodeMapType const & nodeList() const { return m_toNodesRelation; }
290 
297  localIndex & nodeList( localIndex const edgeIndex, localIndex const nodeIndex )
298  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
299 
306  localIndex nodeList( localIndex const edgeIndex, localIndex const nodeIndex ) const
307  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
308 
313  FaceMapType & faceList() { return m_toFacesRelation; }
314 
319  FaceMapType const & faceList() const { return m_toFacesRelation; }
320 
322 
323 private:
324 
326  NodeMapType m_toNodesRelation;
327 
329  FaceMapType m_toFacesRelation;
330 
332  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
333 
335  map< localIndex, SortedArray< globalIndex > > m_unmappedGlobalIndicesInToFaces;
336 
345  template< bool DO_PACKING >
346  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
347  arrayView1d< localIndex const > const & packList ) const;
348 
349 };
350 
351 template< typename OUT_VECTOR >
352 inline void EdgeManager::calculateCenter( localIndex const edgeIndex,
354  OUT_VECTOR && edgeCenter ) const
355 {
356  LvArray::tensorOps::copy< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][0]] );
357  LvArray::tensorOps::add< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][1]] );
358  LvArray::tensorOps::scale< 3 >( edgeCenter, 0.5 );
359 }
360 
361 template< typename OUT_VECTOR >
362 inline void EdgeManager::calculateLength( localIndex const edgeIndex,
364  OUT_VECTOR && edgeSegment ) const
365 {
366  LvArray::tensorOps::copy< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][1]] );
367  LvArray::tensorOps::subtract< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][0]] );
368 }
369 
370 }
371 #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:42
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:78
FixedOneToManyRelation NodeMapType
EdgeToNode map type.
Definition: EdgeManager.hpp:46
void setIsExternal(FaceManager const &faceManager)
Set external edges.
static string catalogName()
Definition: EdgeManager.hpp:59
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:49
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:67
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:43
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.
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
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:326
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: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
LvArray::ArrayOfArrays< T, INDEX_TYPE, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
Definition: DataTypes.hpp:322
Container of keys needed to access the data of the class member.
struct to serve as a container for variable strings and keys