GEOSX
WellElementSubRegion.hpp
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 
15 #ifndef GEOSX_MESH_WELLELEMENTSUBREGION_HPP_
16 #define GEOSX_MESH_WELLELEMENTSUBREGION_HPP_
17 
20 #include "meshUtilities/PerforationData.hpp"
21 
22 namespace geosx
23 {
24 
30 {
31 public:
32 
36  using EdgeMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::GenerateAdjacencyLists
38  using FaceMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::GenerateAdjacencyLists
39 
43  enum WellElemStatus : unsigned
44  {
45  UNOWNED = 0, // there are no perforations on this element
46  REMOTE = 1, // all perforations are remote
47  LOCAL = 2, // all perforations are local
48  SHARED = REMOTE | LOCAL // both remote and local perforations
49  };
50 
54 
61  WellElementSubRegion( string const & name,
62  Group * const parent );
63 
67  virtual ~WellElementSubRegion() override;
68 
70 
74 
80  static const string CatalogName() { return "wellElementSubRegion"; }
81 
85  virtual const string getCatalogName() const override { return WellElementSubRegion::CatalogName(); }
86 
88 
92 
95  FaceManager const & ) override
96  {}
97 
98  virtual void setupRelatedObjectsInRelations( MeshLevel const * const mesh ) override;
99 
101 
105 
112  {
113  return m_toEdgesRelation;
114  }
115 
120  {
121  return m_toEdgesRelation;
122  }
123 
129  {
130  return m_toFacesRelation;
131  }
132 
137  {
138  return m_toFacesRelation;
139  }
140 
146  {
147  return m_toNodesRelation;
148  }
149 
153  NodeMapType const & nodeList() const
154  {
155  return m_toNodesRelation;
156  }
157 
163  {
164  return m_topWellElementIndex;
165  }
166 
171  void SetWellControlsName( string const & name )
172  {
173  m_wellControlsName = name;
174  }
175 
180  string const & GetWellControlsName() const
181  {
182  return m_wellControlsName;
183  }
184 
190  {
191  return &m_perforationData;
192  }
193 
198  {
199  return &m_perforationData;
200  }
201 
206  void SetTopRank( int rank )
207  {
208  m_topRank = rank;
209  }
210 
215  int GetTopRank() const
216  {
217  return m_topRank;
218  }
219 
224  bool IsLocallyOwned() const;
225 
227 
231 
243  void Generate( MeshLevel & mesh,
244  InternalWellGenerator const & wellGeometry,
245  arrayView1d< integer > & elemStatus,
246  globalIndex nodeOffsetGlobal,
247  globalIndex elemOffsetGlobal );
248 
255  InternalWellGenerator const & wellGeometry );
256 
261 
263 
267 
269  virtual void ViewPackingExclusionList( SortedArray< localIndex > & exclusionList ) const override;
270 
271  virtual localIndex PackUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
272 
273  virtual localIndex PackUpDownMaps( buffer_unit_type * & buffer,
274  arrayView1d< localIndex const > const & packList ) const override;
275 
284  virtual localIndex UnpackUpDownMaps( buffer_unit_type const * & buffer,
285  localIndex_array & packList,
286  bool const overwriteUpMaps,
287  bool const overwriteDownMaps ) override;
288 
289  virtual void FixUpDownMaps( bool const clearIfUnmapped ) final override;
290 
292 
294  void DebugWellElementSubRegionsAfterSetupCommunications() const;
296 
302  {
304  static constexpr auto wellControlsString = "wellControlsName";
306  static constexpr auto wellNodeListString = "nodeList";
308  static constexpr auto nextWellElementIndexString = "nextWellElementIndex";
310  static constexpr auto nextWellElementIndexGlobalString = "nextWellElementIndexGlobal";
312  static constexpr auto topWellElementIndexString = "topWellElementIndex";
314  static constexpr auto topRankString = "topRank";
316  static constexpr auto radiusString = "radius";
317 
319  dataRepository::ViewKey wellControlsName = { wellControlsString };
321  dataRepository::ViewKey wellNodeList = { wellNodeListString };
323  dataRepository::ViewKey nextWellElementIndex = { nextWellElementIndexString };
325  dataRepository::ViewKey nextWellElementIndexGlobal = { nextWellElementIndexGlobalString };
327  dataRepository::ViewKey topWellElementIndex = { topWellElementIndexString };
329  dataRepository::ViewKey topRank = { topRankString };
331  dataRepository::ViewKey radius = { radiusString };
332 
333  }
336 
342  {
344  static constexpr auto perforationDataString = "wellElementSubRegion";
345 
347  dataRepository::GroupKey perforationData = { perforationDataString };
348 
349  }
352 
353 
354 private:
355 
368  void AssignUnownedElementsInReservoir( MeshLevel & mesh,
369  InternalWellGenerator const & wellGeometry,
370  SortedArray< globalIndex > const & unownedElems,
371  SortedArray< globalIndex > & localElems,
372  arrayView1d< integer > & elemStatusGlobal ) const;
373 
383  void CheckPartitioningValidity( InternalWellGenerator const & wellGeometry,
384  SortedArray< globalIndex > & localElems,
385  arrayView1d< integer > & elemStatusGlobal ) const;
386 
398  void UpdateNodeManagerSize( MeshLevel & mesh,
399  InternalWellGenerator const & wellGeometry,
400  SortedArray< globalIndex > const & localNodes,
401  SortedArray< globalIndex > const & boundaryNodes,
402  globalIndex nodeOffsetGlobal );
403 
415  void ConstructSubRegionLocalElementMaps( MeshLevel & mesh,
416  InternalWellGenerator const & wellGeometry,
417  SortedArray< globalIndex > const & localElems,
418  globalIndex nodeOffsetGlobal,
419  globalIndex elemOffsetGlobal );
420 
428  void UpdateNodeManagerNodeToElementMap( MeshLevel & mesh );
429 
431  void DebugNodeManager( MeshLevel const & mesh ) const;
433 
435  void DebugWellElementSubRegions( arrayView1d< integer const > const & wellElemStatus, globalIndex elemOffsetGlobal ) const;
437 
445  template< bool DOPACK >
446  localIndex PackUpDownMapsPrivate( buffer_unit_type * & buffer,
447  arrayView1d< localIndex const > const & packList ) const;
448 
450  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
451 
453  string m_wellControlsName;
454 
456  NodeMapType m_toNodesRelation;
457 
459  EdgeMapType m_toEdgesRelation; // unused but needed in MeshLevel::GenerateAdjacencyLists
460 
462  FaceMapType m_toFacesRelation; // unused but needed in MeshLevel::GenerateAdjacencyLists
463 
465  array1d< localIndex > m_nextWellElementIndex;
466 
468  array1d< localIndex > m_nextWellElementIndexGlobal;
469 
471  localIndex m_topWellElementIndex;
472 
474  PerforationData m_perforationData;
475 
477  integer m_topRank;
478 
480  array1d< real64 > m_radius;
481 
483  localIndex m_searchDepth;
484 
485 };
486 
487 } /* namespace geosx */
488 
489 #endif /* GEOSX_MESH_WELLELEMENTSUBREGION_HPP_ */
geosx::WellElementSubRegion::viewKeyStruct viewKeysWellElementSubRegion
ViewKey struct for the WellElementSubRegion class.
virtual localIndex UnpackUpDownMaps(buffer_unit_type const *&buffer, localIndex_array &packList, bool const overwriteUpMaps, bool const overwriteDownMaps) override
Unpacks the specific elements in the @ packList.
dataRepository::ViewKey nextWellElementIndexGlobal
ViewKey for the global indices of the next well element (to reconstruct maps)
static constexpr auto wellControlsString
String key for the well control name.
FixedOneToManyRelation const & edgeList() const
Get the element-to-edge map.
NodeMapType & nodeList()
Get the element-to-node map.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
WellElemStatus
enumeration for values in segmentStatusList parameter of Generate()
virtual void CalculateElementGeometricQuantities(NodeManager const &, FaceManager const &) override
Calculate the geometric quantities for each element in the subregion.
dataRepository::ViewKey topWellElementIndex
ViewKey for the top well element index.
InterObjectRelation< array2d< localIndex > > FixedOneToManyRelation
A relationship from single objects to many other objects, where each object is related to the same nu...
Struct to serve as a container for variable strings and keys.
struct to serve as a container for group strings and keys
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:38
static constexpr auto topWellElementIndexString
String key for the top well element index.
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
virtual void FixUpDownMaps(bool const clearIfUnmapped) final override
Call ObjectManagerBase::FixUpDownMaps for the connectivity maps needed by the derived class (i...
dataRepository::ViewKey wellControlsName
ViewKey for the well control name.
virtual void setupRelatedObjectsInRelations(MeshLevel const *const mesh) override
Link the connectivity maps of the subregion to the managers storing the mesh information.
dataRepository::ViewKey wellNodeList
ViewKey for the well element-to-node list.
geosx::WellElementSubRegion::groupKeyStruct groupKeysWellElementSubRegion
groupKey struct for the WellElementSubRegion class
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
static constexpr auto radiusString
String key for the well radius.
A struct to serve as a container for variable strings and keys.
dataRepository::ViewKey radius
ViewKey for the well radius.
WellElementSubRegion(string const &name, Group *const parent)
Constructor.
FixedOneToManyRelation const & faceList() const
Get the element-to-face map.
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1545
bool IsLocallyOwned() const
Check if well is owned by current rank.
dataRepository::ViewKey nextWellElementIndex
ViewKey for the local indices of the next well element (used in solvers)
NodeMapType const & nodeList() const
Get the element-to-node map.
virtual const string getCatalogName() const override
Get the catalog name.
static constexpr auto wellNodeListString
String key for the well element-to-node list.
void Generate(MeshLevel &mesh, InternalWellGenerator const &wellGeometry, arrayView1d< integer > &elemStatus, globalIndex nodeOffsetGlobal, globalIndex elemOffsetGlobal)
Build the local well elements from global well element data.
virtual localIndex PackUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Computes the pack size of the specific elements in the @ packList.
void ReconstructLocalConnectivity()
Reconstruct the (local) map nextWellElemId using nextWellElemIdGlobal after the ghost exchange...
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:146
void SetWellControlsName(string const &name)
Set the name of the WellControls object of this well.
struct to serve as a container for group strings and keys
static constexpr auto topRankString
String key for the rank owning the top element.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
FixedOneToManyRelation & faceList()
Get the element-to-face map.
int GetTopRank() const
Get the MPI rank that owns this well (i.e. the top segment).
PerforationData * GetPerforationData()
Get all the local perforations.
virtual ~WellElementSubRegion() override
Default destructor.
FixedOneToManyRelation & edgeList()
Get the element-to-edge map.
void SetTopRank(int rank)
Set for the MPI rank that owns this well (i.e. the top segment).
static constexpr auto nextWellElementIndexGlobalString
String key for the global indices of the next well element (to reconstruct maps)
dataRepository::ViewKey topRank
ViewKey for the rank owning the top element.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
void ConnectPerforationsToMeshElements(MeshLevel &mesh, InternalWellGenerator const &wellGeometry)
For each perforation, find the reservoir element that contains the perforation.
virtual localIndex PackUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Packs the specific elements in the @ packList.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data...
Definition: FaceManager.hpp:40
localIndex GetTopWellElementIndex() const
Get for the top element index.
string const & GetWellControlsName() const
Get the name of the WellControls object of this well.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
static const string CatalogName()
Get the catalog name.
This class describes a collection of local well elements and perforations.
PerforationData const * GetPerforationData() const
Get all the local perforations.
virtual void ViewPackingExclusionList(SortedArray< localIndex > &exclusionList) const override
Inserts in exclusionList the data that shall not be packed.
static constexpr auto nextWellElementIndexString
String key for the local indices of the next well element (used in solvers)