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 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 
15 #ifndef GEOS_MESH_WELLELEMENTSUBREGION_HPP_
16 #define GEOS_MESH_WELLELEMENTSUBREGION_HPP_
17 
20 #include "mesh/PerforationData.hpp"
21 #include "mesh/generators/LineBlockABC.hpp"
22 
23 namespace geos
24 {
25 
31 {
32 public:
33 
37  using EdgeMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::generateAdjacencyLists
39  using FaceMapType = FixedOneToManyRelation; // unused but needed in MeshLevel::generateAdjacencyLists
40 
44  enum WellElemStatus : unsigned
45  {
46  UNOWNED = 0, // there are no perforations on this element
47  REMOTE = 1, // all perforations are remote
48  LOCAL = 2, // all perforations are local
49  SHARED = REMOTE | LOCAL // both remote and local perforations
50  };
51 
56 
62  WellElementSubRegion( string const & name,
63  Group * const parent );
64 
66 
71 
76  static string catalogName() { return "wellElementSubRegion"; }
77 
81  virtual string getCatalogName() const override { return catalogName(); }
82 
84 
89 
91  FaceManager const & ) override
92  {}
93 
94  virtual void setupRelatedObjectsInRelations( MeshLevel const & mesh ) override;
95 
97 
102 
108  {
109  return m_toNodesRelation;
110  }
111 
115  NodeMapType const & nodeList() const
116  {
117  return m_toNodesRelation;
118  }
119 
125  {
126  return m_topWellElementIndex;
127  }
128 
133  void setWellControlsName( string const & name )
134  {
135  m_wellControlsName = name;
136  }
137 
142  string const & getWellControlsName() const
143  {
144  return m_wellControlsName;
145  }
146 
152  {
153  return &m_perforationData;
154  }
155 
160  {
161  return &m_perforationData;
162  }
163 
168  void setTopRank( int rank )
169  {
170  m_topRank = rank;
171  }
172 
177  bool isLocallyOwned() const;
178 
180 
185 
196  void generate( MeshLevel & mesh,
197  LineBlockABC const & lineBlock,
198  arrayView1d< integer > & elemStatus,
199  globalIndex nodeOffsetGlobal,
200  globalIndex elemOffsetGlobal );
201 
208  LineBlockABC const & lineBlock );
209 
214 
216 
221 
222  virtual localIndex packUpDownMapsSize( arrayView1d< localIndex const > const & packList ) const override;
223 
225  arrayView1d< localIndex const > const & packList ) const override;
226 
235  virtual localIndex unpackUpDownMaps( buffer_unit_type const * & buffer,
236  localIndex_array & packList,
237  bool const overwriteUpMaps,
238  bool const overwriteDownMaps ) override;
239 
240  virtual void fixUpDownMaps( bool const clearIfUnmapped ) final override;
241 
243 
249  {
251  static constexpr char const * wellControlsString() { return "wellControlsName"; }
253  static constexpr char const * wellNodeListString() { return "nodeList"; }
255  static constexpr char const * nextWellElementIndexString() { return "nextWellElementIndex"; }
257  static constexpr char const * nextWellElementIndexGlobalString() { return "nextWellElementIndexGlobal"; }
259  static constexpr char const * topWellElementIndexString() { return "topWellElementIndex"; }
261  static constexpr char const * topRankString() { return "topRank"; }
263  static constexpr char const * radiusString() { return "radius"; }
264 
279  }
282 
288  {
290  static constexpr char const * perforationDataString() { return "wellElementSubRegion"; }
291 
294 
295  }
298 
299 
300 private:
301 
314  void assignUnownedElementsInReservoir( MeshLevel & mesh,
315  LineBlockABC const & lineBlock,
316  SortedArray< globalIndex > const & unownedElems,
317  SortedArray< globalIndex > & localElems,
318  arrayView1d< integer > & elemStatusGlobal ) const;
319 
329  void checkPartitioningValidity( LineBlockABC const & lineBlock,
330  SortedArray< globalIndex > & localElems,
331  arrayView1d< integer > & elemStatusGlobal ) const;
332 
344  void updateNodeManagerSize( MeshLevel & mesh,
345  LineBlockABC const & lineBlock,
346  SortedArray< globalIndex > const & localNodes,
347  SortedArray< globalIndex > const & boundaryNodes,
348  globalIndex nodeOffsetGlobal );
349 
361  void constructSubRegionLocalElementMaps( MeshLevel & mesh,
362  LineBlockABC const & lineBlock,
363  SortedArray< globalIndex > const & localElems,
364  globalIndex nodeOffsetGlobal,
365  globalIndex elemOffsetGlobal );
366 
374  void updateNodeManagerNodeToElementMap( MeshLevel & mesh );
375 
383  template< bool DO_PACKING >
384  localIndex packUpDownMapsImpl( buffer_unit_type * & buffer,
385  arrayView1d< localIndex const > const & packList ) const;
386 
388  map< localIndex, array1d< globalIndex > > m_unmappedGlobalIndicesInNodelist;
389 
391  string m_wellControlsName;
392 
394  NodeMapType m_toNodesRelation;
395 
397  array1d< localIndex > m_nextWellElementIndex;
398 
400  array1d< localIndex > m_nextWellElementIndexGlobal;
401 
403  localIndex m_topWellElementIndex;
404 
406  PerforationData m_perforationData;
407 
409  integer m_topRank;
410 
412  array1d< real64 > m_radius;
413 
415  localIndex m_searchDepth;
416 
417 };
418 
419 } /* namespace geos */
420 
421 #endif /* GEOS_MESH_WELLELEMENTSUBREGION_HPP_ */
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:43
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:41
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:45
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.
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: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
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:122
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
Definition: DataTypes.hpp:307
signed char buffer_unit_type
Type stored in communication buffers.
Definition: DataTypes.hpp:149
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
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)