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 Total, S.A
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 GEOSX_MESH_EDGEMANAGER_HPP_
20 #define GEOSX_MESH_EDGEMANAGER_HPP_
21 
22 #include "InterObjectRelation.hpp"
24 #include "ToElementRelation.hpp"
26 
27 
28 namespace geosx
29 {
30 class FaceManager;
31 class NodeManager;
32 class CellBlockManager;
33 
34 
43 {
44 public:
45 
48 
51 
55 
60  static const string CatalogName()
61  { return "EdgeManager"; }
62 
63 
68  virtual const string getCatalogName() const override
69  { return EdgeManager::CatalogName(); }
70 
72 
78  { return 4; }
79 
83 
90  EdgeManager( std::string const & name,
91  Group * const parent );
92 
96  ~EdgeManager() override;
97 
99 
106  virtual void resize( localIndex const newSize ) override;
107 
112  void SetDomainBoundaryObjects( const ObjectDataStructureBaseT * const referenceObject = nullptr );
113 
119  void SetIsExternal( FaceManager const * const faceManager );
120 
126  void BuildEdges( FaceManager * const faceManager, NodeManager * const nodeManager );
127 
134  void BuildEdges( localIndex const numNodes,
135  ArrayOfArraysView< localIndex const > const & faceToNodeMap,
136  ArrayOfArrays< localIndex > & faceToEdgeMap );
137 
138 
146  virtual void
148  std::vector< std::vector< globalIndex > > & globalEdgeNodes ) override;
149 
156  virtual localIndex PackUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
157 
165  virtual localIndex PackUpDownMaps( buffer_unit_type * & buffer,
166  arrayView1d< localIndex const > const & packList ) const override;
167 
177  virtual localIndex UnpackUpDownMaps( buffer_unit_type const * & buffer,
178  localIndex_array & packList,
179  bool const overwriteUpMaps,
180  bool const overwriteDownMaps ) override;
181 
186  void FixUpDownMaps( bool const clearIfUnmapped );
187 
192  void compressRelationMaps();
193 
199  void depopulateUpMaps( std::set< localIndex > const & receivedEdges,
200  ArrayOfArraysView< localIndex const > const & facesToEdges );
201 
209  const map< globalIndex, localIndex > & nodeGlobalToLocal,
210  const map< globalIndex, localIndex > & faceGlobalToLocal );
211 
217  void AddToEdgeToFaceMap( FaceManager const * const faceManager,
218  arrayView1d< localIndex const > const & newFaceIndices );
219 
227  void SplitEdge( const localIndex indexToSplit,
228  const localIndex parentNodeIndex,
229  const localIndex childNodeIndex[2],
230  array1d< SortedArray< localIndex > > & nodesToEdges );
231 
238  bool hasNode( const localIndex edgeID, const localIndex nodeID ) const;
239 
247  template< typename OUT_VECTOR >
248  void calculateCenter( localIndex const edgeIndex,
250  OUT_VECTOR && edgeCenter ) const;
251 
259  template< typename OUT_VECTOR >
260  void calculateLength( localIndex const edgeIndex,
262  OUT_VECTOR && edgeVector ) const;
263 
267 
274  {
276  static constexpr auto nodeListString = "nodeList";
277  static constexpr auto faceListString = "faceList";
278  static constexpr auto elementRegionListString = "elemRegionList";
279  static constexpr auto elementSubRegionListString = "elemSubRegionList";
280  static constexpr auto elementListString = "elemList";
281  static constexpr auto edgesTofractureConnectorsEdgesString = "edgesToFractureConnectors";
282  static constexpr auto fractureConnectorEdgesToEdgesString = "fractureConnectorsToEdges";
283  static constexpr auto fractureConnectorsEdgesToFaceElementsIndexString = "fractureConnectorsToElementIndex";
284 
285  dataRepository::ViewKey nodesList = { nodeListString };
286  dataRepository::ViewKey faceList = { faceListString };
287  dataRepository::ViewKey elementRegionList = { elementRegionListString };
288  dataRepository::ViewKey elementSubRegionList = { elementSubRegionListString };
289  dataRepository::ViewKey elementList = { elementListString };
291  }
293  viewKeys;
294 
295 
301  {}
303  groupKeys;
304 
306 
311  constexpr int maxEdgesPerNode() const { return 200; }
312 
316 
322  NodeMapType & nodeList() { return m_toNodesRelation; }
323 
328  NodeMapType const & nodeList() const { return m_toNodesRelation; }
329 
336  localIndex & nodeList( localIndex const edgeIndex, localIndex const nodeIndex )
337  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
338 
345  localIndex nodeList( localIndex const edgeIndex, localIndex const nodeIndex ) const
346  { return m_toNodesRelation( edgeIndex, nodeIndex ); }
347 
352  FaceMapType & faceList() { return m_toFacesRelation; }
353 
358  FaceMapType const & faceList() const { return m_toFacesRelation; }
359 
361 
362  // TODO These should be in their own subset of edges when we add that capability.
363 
366 
369 
372 
375 
376 
377 private:
378 
380  NodeMapType m_toNodesRelation;
381 
383  FaceMapType m_toFacesRelation;
384 
386  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInToNodes;
387 
389  map< localIndex, SortedArray< globalIndex > > m_unmappedGlobalIndicesInToFaces;
390 
399  template< bool DOPACK >
400  localIndex PackUpDownMapsPrivate( buffer_unit_type * & buffer,
401  arrayView1d< localIndex const > const & packList ) const;
402 
403 };
404 
405 template< typename OUT_VECTOR >
406 inline void EdgeManager::calculateCenter( localIndex const edgeIndex,
408  OUT_VECTOR && edgeCenter ) const
409 {
410  LvArray::tensorOps::copy< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][0]] );
411  LvArray::tensorOps::add< 3 >( edgeCenter, X[m_toNodesRelation[edgeIndex][1]] );
412  LvArray::tensorOps::scale< 3 >( edgeCenter, 0.5 );
413 }
414 
415 template< typename OUT_VECTOR >
416 inline void EdgeManager::calculateLength( localIndex const edgeIndex,
418  OUT_VECTOR && edgeSegment ) const
419 {
420  LvArray::tensorOps::copy< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][1]] );
421  LvArray::tensorOps::subtract< 3 >( edgeSegment, X[m_toNodesRelation[edgeIndex][0]] );
422 }
423 
424 }
425 #endif /* GEOSX_MESH_EDGEMANAGER_HPP_ */
void compressRelationMaps()
Compress all nodes-to-faces relation maps so that the values of each array are contiguous with no ext...
array1d< localIndex > m_fractureConnectorsEdgesToEdges
todo
virtual void ExtractMapFromObjectForAssignGlobalIndexNumbers(ObjectManagerBase const *const nodeManager, std::vector< std::vector< globalIndex > > &globalEdgeNodes) override
Build globalEdgeNodes, a vector containing all the global indices of each nodes of each edges...
localIndex nodeList(localIndex const edgeIndex, localIndex const nodeIndex) const
Get a node list.
void FixUpDownMaps(bool const clearIfUnmapped)
Call FixUpDownMaps of the class ObjectManagerBase for nodes-to-edges and nodes-to-faces relation maps...
struct to serve as a container for group strings and keys
static localIndex faceMapExtraSpacePerEdge()
Oversize the Face mapping by this amount for each edge (hardcoded)
Definition: EdgeManager.hpp:77
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...
FaceMapType & faceList()
Get the edge-to-face relation.
EdgeManager(std::string const &name, Group *const parent)
main constructor for EdgeManager Objects
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data...
Definition: NodeManager.hpp:47
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:349
void SplitEdge(const localIndex indexToSplit, const localIndex parentNodeIndex, const localIndex childNodeIndex[2], array1d< SortedArray< localIndex > > &nodesToEdges)
Split an edge (separate its two extremity nodes)
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
virtual localIndex PackUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Pack an array of edge indices in a buffer.
NodeMapType & nodeList()
Get a node list.
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
void SetDomainBoundaryObjects(const ObjectDataStructureBaseT *const referenceObject=nullptr)
Set the node of the domain boundary object.
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1545
virtual groupKeyStruct & groupKeys()
Get the group keys for Group access.
This class provides a view into an array of arrays like object.
map< localIndex, localIndex > m_edgesToFractureConnectorsEdges
todo
ArrayOfArrays< localIndex > m_fractureConnectorEdgesToFaceElements
todo
virtual viewKeyStruct & viewKeys()
Get the view keys for Group access.
localIndex & nodeList(localIndex const edgeIndex, localIndex const nodeIndex)
Get a reference to a node list.
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.
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:146
virtual void resize(localIndex const newSize) override
Resize the EdgeManager object and all it members.
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.
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:42
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.
SortedArray< localIndex > m_recalculateFractureConnectorEdges
map from the edges to the fracture connectors index (edges that are fracture connectors) ...
virtual localIndex PackUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Compute the future size of a packed list.
constexpr int maxEdgesPerNode() const
}@
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
void calculateLength(localIndex const edgeIndex, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &X, OUT_VECTOR &&edgeVector) const
Calculate the edge segment.
Container of keys needed to access the data of the class member.
bool hasNode(const localIndex edgeID, const localIndex nodeID) const
Check if edge edgeID contains node nodeID.
std::string string
String type.
Definition: DataTypes.hpp:131
void BuildEdges(FaceManager *const faceManager, NodeManager *const nodeManager)
Build faces-to-edges and nodes-to-edges relation maps.
void AddToEdgeToFaceMap(FaceManager const *const faceManager, arrayView1d< localIndex const > const &newFaceIndices)
Add new faces to the faces to edges map.
Container of keys needed to access the data of the class member.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data...
Definition: FaceManager.hpp:40
static const string CatalogName()
Definition: EdgeManager.hpp:60
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
void ConnectivityFromGlobalToLocal(const SortedArray< localIndex > &indices, const map< globalIndex, localIndex > &nodeGlobalToLocal, const map< globalIndex, localIndex > &faceGlobalToLocal)
Build the mapping edge-to-nodes relation from the mapping global to local nodes.
struct to serve as a container for variable strings and keys
void SetIsExternal(FaceManager const *const faceManager)
Set external edges.
virtual const string getCatalogName() const override
Getter used to access the edge manager catalog name.
Definition: EdgeManager.hpp:68
~EdgeManager() override
default destructor
FaceMapType const & faceList() const
Get an immutable accessor to the edge-to-face relation.
NodeMapType const & nodeList() const
Provide an accessor to an immutable node list.