GEOS
WellElementSubRegion.hpp
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 
16 #ifndef GEOS_MESH_WELLELEMENTSUBREGION_HPP_
17 #define GEOS_MESH_WELLELEMENTSUBREGION_HPP_
18 
21 #include "mesh/PerforationData.hpp"
22 #include "mesh/generators/LineBlockABC.hpp"
23 
24 namespace geos
25 {
26 
32 {
33 public:
34 
38  using EdgeMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::generateAdjacencyLists
40  using FaceMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::generateAdjacencyLists
41 
45  enum WellElemStatus : unsigned
46  {
47  UNOWNED = 0, // there are no perforations on this element
48  REMOTE = 1, // all perforations are remote
49  LOCAL = 2, // all perforations are local
50  SHARED = REMOTE | LOCAL // both remote and local perforations
51  };
52 
57 
63  WellElementSubRegion( string const & name,
64  Group * const parent );
65 
67 
72 
77  static string catalogName() { return "wellElementSubRegion"; }
78 
82  virtual string getCatalogName() const override { return catalogName(); }
83 
85 
90 
92  FaceManager const & ) override
93  {}
94 
95  virtual void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
96 
98 
103 
109  {
110  return m_toNodesRelation;
111  }
112 
116  NodeMapType const & nodeList() const
117  {
118  return m_toNodesRelation;
119  }
120 
126  {
127  return m_topWellElementIndex;
128  }
129 
135  {
136  return m_globalWellElementIndex;
137  }
142  void setWellControlsName( string const & name )
143  {
144  m_wellControlsName = name;
145  }
146 
151  string const & getWellControlsName() const
152  {
153  return m_wellControlsName;
154  }
155 
161  {
162  return &m_perforationData;
163  }
164 
169  {
170  return &m_perforationData;
171  }
172 
177  void setTopRank( int rank )
178  {
179  m_topRank = rank;
180  }
181 
186  bool isLocallyOwned() const;
187 
189 
194 
205  void generate( MeshLevel & mesh,
206  LineBlockABC const & lineBlock,
207  arrayView1d< integer > & elemStatus,
208  globalIndex nodeOffsetGlobal,
209  globalIndex elemOffsetGlobal );
210 
217  LineBlockABC const & lineBlock );
218 
223 
225 
230 
231  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
232 
234  arrayView1d< localIndex const > const & packList ) const override;
235 
244  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
245  localIndex_array & packList,
246  bool const overwriteUpMaps,
247  bool const overwriteDownMaps ) override;
248 
249  virtual void fixUpDownMaps( bool const clearIfUnmapped ) final override;
250 
252 
258  {
260  static constexpr char const * wellControlsString() { return "wellControlsName"; }
262  static constexpr char const * wellNodeListString() { return "nodeList"; }
264  static constexpr char const * nextWellElementIndexString() { return "nextWellElementIndex"; }
266  static constexpr char const * nextWellElementIndexGlobalString() { return "nextWellElementIndexGlobal"; }
268  static constexpr char const * topWellElementIndexString() { return "topWellElementIndex"; }
270  static constexpr char const * topRankString() { return "topRank"; }
272  static constexpr char const * radiusString() { return "radius"; }
273 
288  }
291 
297  {
299  static constexpr char const * perforationDataString() { return "wellElementSubRegion"; }
300 
303 
304  }
307 
308 
309 private:
310 
323  void assignUnownedElementsInReservoir( MeshLevel & mesh,
324  LineBlockABC const & lineBlock,
325  SortedArray< globalIndex > const & unownedElems,
326  SortedArray< globalIndex > & localElems,
327  arrayView1d< integer > & elemStatusGlobal ) const;
328 
338  void checkPartitioningValidity( LineBlockABC const & lineBlock,
339  SortedArray< globalIndex > & localElems,
340  arrayView1d< integer > & elemStatusGlobal ) const;
341 
353  void updateNodeManagerSize( MeshLevel & mesh,
354  LineBlockABC const & lineBlock,
355  SortedArray< globalIndex > const & localNodes,
356  SortedArray< globalIndex > const & boundaryNodes,
357  globalIndex nodeOffsetGlobal );
358 
370  void constructSubRegionLocalElementMaps( MeshLevel & mesh,
371  LineBlockABC const & lineBlock,
372  SortedArray< globalIndex > const & localElems,
373  globalIndex nodeOffsetGlobal,
374  globalIndex elemOffsetGlobal );
375 
383  void updateNodeManagerNodeToElementMap( MeshLevel & mesh );
384 
392  template< bool DO_PACKING >
393  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
394  arrayView1d< localIndex const > const & packList ) const;
395 
397  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
398 
400  string m_wellControlsName;
401 
403  NodeMapType m_toNodesRelation;
404 
406  array1d< globalIndex > m_globalWellElementIndex;
407 
409  array1d< localIndex > m_nextWellElementIndex;
410 
412  array1d< localIndex > m_nextWellElementIndexGlobal;
413 
415  localIndex m_topWellElementIndex;
416 
418  PerforationData m_perforationData;
419 
421  integer m_topRank;
422 
424  array1d< real64 > m_radius;
425 
427  localIndex m_searchDepth;
428 
429 };
430 
431 } /* namespace geos */
432 
433 #endif /* GEOS_MESH_WELLELEMENTSUBREGION_HPP_ */
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
This class describes a collection of local well elements and perforations.
bool isLocallyOwned() const
Check if well is owned by current rank.
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Packs the specific elements in the @ packList.
string const & getWellControlsName() const
Get the name of the WellControls object of this well.
void setTopRank(int rank)
Set for the MPI rank that owns this well (i.e. the top segment).
void generate(MeshLevel &mesh, LineBlockABC const &lineBlock, arrayView1d< integer > &elemStatus, globalIndex nodeOffsetGlobal, globalIndex elemOffsetGlobal)
Build the local well elements from global well element data.
NodeMapType const & nodeList() const
Get the element-to-node map.
static string catalogName()
Get the catalog name.
arrayView1d< globalIndex const > getGlobalWellElementIndex() const
Get for the top element index.
virtual void fixUpDownMaps(bool const clearIfUnmapped) final override
Call ObjectManagerBase::fixUpDownMaps for the connectivity maps needed by the derived class (i....
void setWellControlsName(string const &name)
Set the name of the WellControls object of this well.
NodeMapType & nodeList()
Get the element-to-node map.
PerforationData * getPerforationData()
Get all the local perforations.
WellElemStatus
enumeration for values in segmentStatusList parameter of Generate()
void connectPerforationsToMeshElements(MeshLevel &mesh, LineBlockABC const &lineBlock)
For each perforation, find the reservoir element that contains the perforation.
virtual void setupRelatedObjectsInRelations(MeshLevel const &mesh) override
Link the connectivity maps of the subregion to the managers storing the mesh information.
PerforationData const * getPerforationData() const
Get all the local perforations.
virtual void calculateElementGeometricQuantities(NodeManager const &, FaceManager const &) override
Calculate the geometric quantities for each element in the subregion.
localIndex getTopWellElementIndex() const
Get for the top element index.
geos::WellElementSubRegion::viewKeyStruct viewKeysWellElementSubRegion
ViewKey struct for the WellElementSubRegion class.
virtual string getCatalogName() const override
Get the catalog name.
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.
void reconstructLocalConnectivity()
Reconstruct the (local) map nextWellElemId using nextWellElemIdGlobal after the ghost exchange.
virtual localIndex packUpDownMapsSize(arrayView1d< localIndex const > const &packList) const override
Computes the pack size of the specific elements in the @ packList.
geos::WellElementSubRegion::groupKeyStruct groupKeysWellElementSubRegion
groupKey struct for the WellElementSubRegion class
WellElementSubRegion(string const &name, Group *const parent)
Constructor.
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
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
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...
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:267
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:109
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
struct to serve as a container for group strings and keys
A struct to serve as a container for variable strings and keys.
struct to serve as a container for group strings and keys
static constexpr char const * perforationDataString()
dataRepository::GroupKey perforationData
GroupKey for the PerforationData object.
Struct to serve as a container for variable strings and keys.
static constexpr char const * nextWellElementIndexGlobalString()
dataRepository::ViewKey topRank
ViewKey for the rank owning the top element.
dataRepository::ViewKey topWellElementIndex
ViewKey for the top well element index.
dataRepository::ViewKey nextWellElementIndex
ViewKey for the local indices of the next well element (used in solvers)
static constexpr char const * wellNodeListString()
static constexpr char const * topWellElementIndexString()
static constexpr char const * topRankString()
dataRepository::ViewKey radius
ViewKey for the well radius.
dataRepository::ViewKey wellNodeList
ViewKey for the well element-to-node list.
dataRepository::ViewKey wellControlsName
ViewKey for the well control name.
static constexpr char const * nextWellElementIndexString()
static constexpr char const * radiusString()
static constexpr char const * wellControlsString()
dataRepository::ViewKey nextWellElementIndexGlobal
ViewKey for the global indices of the next well element (to reconstruct maps)