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 WellElemParallelStatus : unsigned
46  {
47  UNOWNED = 0, // there are no perforations on this mesh partition
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 
56  enum WellElemStatus : unsigned
57  {
58  CLOSED = 0, // no flow in element
59  OPEN = 1
60  };
61 
66 
72  WellElementSubRegion( string const & name,
73  Group * const parent );
74 
76 
81 
86  static string catalogName() { return "wellElementSubRegion"; }
87 
91  virtual string getCatalogName() const override { return catalogName(); }
92 
94 
99 
101  FaceManager const & ) override
102  {}
103 
104  virtual void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
105 
107 
112 
118  {
119  return m_toNodesRelation;
120  }
121 
125  NodeMapType const & nodeList() const
126  {
127  return m_toNodesRelation;
128  }
129 
135  {
136  return m_topWellElementIndex;
137  }
138 
144  {
145  return m_globalWellElementIndex;
146  }
151  void setWellControlsName( string const & name )
152  {
153  m_wellControlsName = name;
154  }
155 
160  string const & getWellControlsName() const
161  {
162  return m_wellControlsName;
163  }
164 
170  {
171  return &m_perforationData;
172  }
173 
178  {
179  return &m_perforationData;
180  }
181 
187  {
188  return m_wellLocalElementStatus;
189  }
190 
195  {
196  return m_wellLocalElementStatus;
197  }
198 
199 
205  {
206  return m_wellElementStatus;
207  }
208 
213  {
214  return m_wellElementStatus;
215  }
216 
221  void setTopRank( int rank )
222  {
223  m_topRank = rank;
224  }
225 
230  bool isLocallyOwned() const;
231 
233 
238 
249  void generate( MeshLevel & mesh,
250  LineBlockABC const & lineBlock,
251  arrayView1d< integer > & elemStatus,
252  globalIndex nodeOffsetGlobal,
253  globalIndex elemOffsetGlobal );
254 
261  LineBlockABC const & lineBlock );
262 
267 
269 
274 
275  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
276 
278  arrayView1d< localIndex const > const & packList ) const override;
279 
288  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
289  localIndex_array & packList,
290  bool const overwriteUpMaps,
291  bool const overwriteDownMaps ) override;
292 
293  virtual void fixUpDownMaps( bool const clearIfUnmapped ) final override;
294 
296 
302  {
304  static constexpr char const * wellControlsString() { return "wellControlsName"; }
306  static constexpr char const * wellNodeListString() { return "nodeList"; }
308  static constexpr char const * nextWellElementIndexString() { return "nextWellElementIndex"; }
310  static constexpr char const * nextWellElementIndexGlobalString() { return "nextWellElementIndexGlobal"; }
312  static constexpr char const * topWellElementIndexString() { return "topWellElementIndex"; }
314  static constexpr char const * topRankString() { return "topRank"; }
316  static constexpr char const * radiusString() { return "radius"; }
318  static constexpr char const * wellLocalElementGlobalIndexString() { return "wellLocalElementGlobalIndex"; }
320  static constexpr char const * wellLocalElementStatusString() { return "wellLocalElementStatus"; }
321 
340  }
343 
349  {
351  static constexpr char const * perforationDataString() { return "wellElementSubRegion"; }
352 
355 
356  }
359 
364  integer const & getNumLocalElements() const { return m_numLocalElements;}
365 
370 
375  void setElementStatus( arrayView1d< integer > const & localElemPerfStatus );
376 
381  array1d< globalIndex > const & getGlobalElementIndex() const { return m_globalElementIndex; }
382 private:
383 
396  void assignUnownedElementsInReservoir( MeshLevel & mesh,
397  LineBlockABC const & lineBlock,
398  SortedArray< globalIndex > const & unownedElems,
399  SortedArray< globalIndex > & localElems,
400  arrayView1d< integer > & elemStatusGlobal ) const;
401 
411  void checkPartitioningValidity( LineBlockABC const & lineBlock,
412  SortedArray< globalIndex > & localElems,
413  arrayView1d< integer > & elemStatusGlobal ) const;
414 
426  void updateNodeManagerSize( MeshLevel & mesh,
427  LineBlockABC const & lineBlock,
428  SortedArray< globalIndex > const & localNodes,
429  SortedArray< globalIndex > const & boundaryNodes,
430  globalIndex nodeOffsetGlobal );
431 
443  void constructSubRegionLocalElementMaps( MeshLevel & mesh,
444  LineBlockABC const & lineBlock,
445  SortedArray< globalIndex > const & localElems,
446  globalIndex nodeOffsetGlobal,
447  globalIndex elemOffsetGlobal );
448 
456  void updateNodeManagerNodeToElementMap( MeshLevel & mesh );
457 
465  template< bool DO_PACKING >
466  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
467  arrayView1d< localIndex const > const & packList ) const;
468 
470  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
471 
473  string m_wellControlsName;
474 
476  NodeMapType m_toNodesRelation;
477 
479  array1d< globalIndex > m_globalWellElementIndex;
480 
482  array1d< globalIndex > m_globalElementIndex;
483 
485  array1d< localIndex > m_nextWellElementIndex;
486 
488  array1d< localIndex > m_nextWellElementIndexGlobal;
489 
491  localIndex m_topWellElementIndex;
492 
494  PerforationData m_perforationData;
495 
497  integer m_topRank;
498 
500  array1d< real64 > m_radius;
501 
503  localIndex m_searchDepth;
504 
506  integer m_numLocalElements;
507 
509  array1d< integer > m_wellElementStatus; // (sized total number of segments)
510 
512  array1d< integer > m_wellLocalElementStatus; // (sized number of local segments)
513 
515  array1d< integer > m_mpiElementOffset;
516 
518  array1d< localIndex > m_elementPerRank;
519 };
520 
521 } /* namespace geos */
522 
523 #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.
array1d< integer > const & getLocalWellElementStatus() const
Get status for local well elements.
WellElemParallelStatus
enumeration for values in segmentStatusList parameter of Generate()
bool isLocallyOwned() const
Check if well is owned by current rank.
array1d< integer > & getWellLocalElementStatus()
Get status for local well elements.
virtual localIndex packUpDownMaps(buffer_unit_type *&buffer, arrayView1d< localIndex const > const &packList) const override
Packs the specific elements in the @ packList.
void setupCommArrays()
Setup offset arrays needed for MPI comm of perforatin sttus.
string const & getWellControlsName() const
Get the name of the WellControls object of this well.
array1d< globalIndex > const & getGlobalElementIndex() const
Get global element index for all elements.
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 element state
void connectPerforationsToMeshElements(MeshLevel &mesh, LineBlockABC const &lineBlock)
For each perforation, find the reservoir element that contains the perforation.
integer const & getNumLocalElements() const
Get number of local elements.
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.
InterObjectRelation< array2d< localIndex, cells::NODE_MAP_PERMUTATION > > NodeMapType
Alias for the type of the element-to-node map.
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.
array1d< integer > & getWellElementStatus()
Get status for all well elements.
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
void setElementStatus(arrayView1d< integer > const &localElemPerfStatus)
Set status (Open/Closed) for locally owned elements.
array1d< integer > const & getWellElementStatus() const
Get status for all well elements.
WellElementSubRegion(string const &name, Group *const parent)
Constructor.
Base template for ordered and unordered maps.
Group::wrapperMap::KeyIndex ViewKey
Type alias for KeyIndexT type used for wrapper lookups.
Definition: Group.hpp:1664
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
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
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::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:266
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:108
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
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.
dataRepository::ViewKey wellLocalElementGlobalIndex
ViewKey for the global element index.
static constexpr char const * nextWellElementIndexGlobalString()
static constexpr char const * wellLocalElementStatusString()
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 * wellLocalElementGlobalIndexString()
static constexpr char const * topWellElementIndexString()
static constexpr char const * topRankString()
dataRepository::ViewKey radius
ViewKey for the well radius.
dataRepository::ViewKey wellLocalElementStatus
ViewKey for the well element status.
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)