GEOS
SinglePhaseWell.hpp
Go to the documentation of this file.
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 
20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
22 
23 #include "WellSolverBase.hpp"
24 
25 #include "constitutive/fluid/singlefluid/SingleFluidLayouts.hpp"
26 
27 namespace geos
28 {
29 
30 namespace dataRepository
31 {
32 class Group;
33 }
34 
35 namespace constitutive
36 {
37 class SingleFluidBase;
38 }
39 
40 namespace singlePhaseStatistics
41 {
42 class StatsAggregator;
43 }
44 
45 class WellElementSubRegion;
46 
53 {
54 public:
55 
56  using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
62  SinglePhaseWell( const string & name,
63  Group * const parent );
64 
66  SinglePhaseWell() = delete;
67 
69  SinglePhaseWell( SinglePhaseWell const & ) = delete;
70 
73 
75  SinglePhaseWell & operator=( SinglePhaseWell const & ) = delete;
76 
79 
83  virtual ~SinglePhaseWell() override = default;
84 
89  static string catalogName() { return "SinglePhaseWell"; }
93  string getCatalogName() const override { return catalogName(); }
94 
95  virtual void registerDataOnMesh( Group & meshBodies ) override;
96 
104  virtual real64
105  calculateResidualNorm( real64 const & time_n,
106  real64 const & dt,
107  DomainPartition const & domain,
108  DofManager const & dofManager,
109  arrayView1d< real64 const > const & localRhs ) override;
110 
111  virtual bool
113  DofManager const & dofManager,
114  arrayView1d< real64 const > const & localSolution,
115  real64 const scalingFactor ) override;
116 
117  virtual void
118  applySystemSolution( DofManager const & dofManager,
119  arrayView1d< real64 const > const & localSolution,
120  real64 const scalingFactor,
121  real64 const dt,
122  DomainPartition & domain ) override;
123 
124  virtual void
126 
127  virtual void
128  implicitStepSetup( real64 const & time,
129  real64 const & dt,
130  DomainPartition & domain ) override;
131 
132  virtual void
134  real64 const & dt,
135  DomainPartition & domain ) override;
136 
139  virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); }
140 
141  virtual string resElementDofName() const override;
142 
143  virtual localIndex numFluidComponents() const override { return 1; }
144 
145  virtual localIndex numFluidPhases() const override { return 1; }
146 
153 
158  virtual void updateBHPForConstraint( WellElementSubRegion & subRegion );
159 
164  virtual void updateFluidModel( WellElementSubRegion & subRegion ) const;
165 
170  virtual void computePerforationRates( real64 const & time_n,
171  real64 const & dt, DomainPartition & domain ) override;
172 
178  virtual real64 updateSubRegionState( WellElementSubRegion & subRegion ) override;
179 
189  virtual void assembleSystem( real64 const time,
190  real64 const dt,
191  DomainPartition & domain,
192  DofManager const & dofManager,
193  CRSMatrixView< real64, globalIndex const > const & localMatrix,
194  arrayView1d< real64 > const & localRhs ) override;
195 
205  virtual void assembleFluxTerms( real64 const & time_n,
206  real64 const & dt,
207  DomainPartition & domain,
208  DofManager const & dofManager,
209  CRSMatrixView< real64, globalIndex const > const & localMatrix,
210  arrayView1d< real64 > const & localRhs ) override;
211 
219  virtual void assembleAccumulationTerms( real64 const & time_n,
220  real64 const & dt, DomainPartition & domain,
221  DofManager const & dofManager,
222  CRSMatrixView< real64, globalIndex const > const & localMatrix,
223  arrayView1d< real64 > const & localRhs ) override;
224 
233  DofManager const & dofManager,
234  CRSMatrixView< real64, globalIndex const > const & localMatrix,
235  arrayView1d< real64 > const & localRhs );
236 
246  virtual void assemblePressureRelations( real64 const & time_n,
247  real64 const & dt,
248  DomainPartition const & domain,
249  DofManager const & dofManager,
250  CRSMatrixView< real64, globalIndex const > const & localMatrix,
251  arrayView1d< real64 > const & localRhs ) override;
252 
253  /*
254  * @brief apply a special treatment to the wells that are shut
255  * @param time_n the time at the previous converged time step
256  * @param domain the physical domain object
257  * @param dofManager degree-of-freedom manager associated with the linear system
258  * @param matrix the system matrix
259  * @param rhs the system right-hand side vector
260  */
261  void shutDownWell( real64 const time_n,
262  DomainPartition const & domain,
263  DofManager const & dofManager,
264  CRSMatrixView< real64, globalIndex const > const & localMatrix,
265  arrayView1d< real64 > const & localRhs );
267  {
268  static constexpr char const * dofFieldString() { return "singlePhaseWellVars"; }
269 
270  // control data (not registered on the mesh)
271  static constexpr char const * currentBHPString() { return "currentBHP"; }
272  static constexpr char const * dCurrentBHPString() { return "dCurrentBHP"; }
273  static constexpr char const * currentVolRateString() { return "currentVolumetricRate"; }
274  static constexpr char const * dCurrentVolRateString() { return "dCurrentVolRate"; }
275  };
276 
277 protected:
278 
279  void printRates( real64 const & time_n,
280  real64 const & dt,
281  DomainPartition & domain ) override;
282 
285 
286 private:
287 
288  struct ReferenceConditions
289  {
290  real64 pressure;
291  real64 temperature;
292  };
293 
295  std::unique_ptr< singlePhaseStatistics::StatsAggregator > m_reservoirStatsAggregator;
296 
297  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
298 
303  void initializeWells( DomainPartition & domain, real64 const & time_n ) override;
304 
305  void precomputeReferenceConditions( real64 time_n,
306  Group & meshBodies,
307  MeshBody & meshBody,
308  WellElementSubRegion const & subRegion );
309 
310  ReferenceConditions getReferenceConditions( WellElementSubRegion const & subRegion );
311 
318  virtual void validateWellConstraints( real64 const & time_n,
319  real64 const & dt,
320  WellElementSubRegion const & subRegion ) override;
321 
322 };
323 
324 } // namespace geos
325 
326 
327 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:45
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
The class is used to manage mesh body.
Definition: MeshBody.hpp:36
void assembleVolumeBalanceTerms(DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
assembles the volume balance terms for all well elements
virtual real64 updateSubRegionState(WellElementSubRegion &subRegion) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual string resElementDofName() const override
get the name of DOF defined on well elements
virtual void updateVolRateForConstraint(WellElementSubRegion &subRegion)
Recompute the volumetric rate that are used in the well constraints.
virtual void assembleSystem(real64 const time, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
function to assemble the linear system matrix and rhs
virtual string wellElementDofName() const override
get the name of DOF defined on well elements
SinglePhaseWell(const string &name, Group *const parent)
main constructor for Group Objects
virtual ~SinglePhaseWell() override=default
default destructor
virtual void assemblePressureRelations(real64 const &time_n, real64 const &dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the pressure relations at all connections between well elements except at the well head
static string catalogName()
name of the node manager in the object catalog
SinglePhaseWell & operator=(SinglePhaseWell const &)=delete
deleted assignment operator
SinglePhaseWell(SinglePhaseWell const &)=delete
deleted copy constructor
virtual void updateFluidModel(WellElementSubRegion &subRegion) const
Update fluid constitutive model state.
SinglePhaseWell(SinglePhaseWell &&)=default
default move constructor
integer m_allowNegativePressure
flag if negative pressure is allowed
virtual void assembleFluxTerms(real64 const &time_n, real64 const &dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the flux terms for all connections between well elements
virtual localIndex numFluidComponents() const override
const getter for the number of fluid components
virtual void assembleAccumulationTerms(real64 const &time_n, real64 const &dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the accumulation term for all the well elements
virtual void registerDataOnMesh(Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
SinglePhaseWell & operator=(SinglePhaseWell &&)=delete
deleted move operator
string getCatalogName() const override
virtual void computePerforationRates(real64 const &time_n, real64 const &dt, DomainPartition &domain) override
Recompute the perforation rates for all the wells.
virtual localIndex numFluidPhases() const override
Get the number of fluid phases.
virtual void updateBHPForConstraint(WellElementSubRegion &subRegion)
Recompute the BHP pressure that is used in the well constraints.
SinglePhaseWell()=delete
deleted default constructor
This class describes a collection of local well elements and perforations.
virtual void implicitStepComplete(real64 const &time, real64 const &dt, DomainPartition &domain) override
perform cleanup for implicit timestep
virtual void resetStateToBeginningOfStep(DomainPartition &domain) override
reset state of physics back to the beginning of the step.
virtual void implicitStepSetup(real64 const &time, real64 const &dt, DomainPartition &domain) override
function to perform setup for implicit timestep
virtual void applySystemSolution(DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor, real64 const dt, DomainPartition &domain) override
Function to apply the solution vector to the state.
virtual real64 calculateResidualNorm(real64 const &time_n, real64 const &dt, DomainPartition const &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localRhs) override
calculate the norm of the global system residual
virtual bool checkSystemSolution(DomainPartition &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor) override
Function to check system solution for physical consistency and constraint violation.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
int integer
Signed integer type.
Definition: DataTypes.hpp:81