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 class WellElementSubRegion;
40 
47 {
48 public:
49 
50  using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
56  SinglePhaseWell( const string & name,
57  Group * const parent );
58 
60  SinglePhaseWell() = delete;
61 
63  SinglePhaseWell( SinglePhaseWell const & ) = delete;
64 
67 
69  SinglePhaseWell & operator=( SinglePhaseWell const & ) = delete;
70 
73 
77  virtual ~SinglePhaseWell() override = default;
78 
83  static string catalogName() { return "SinglePhaseWell"; }
87  string getCatalogName() const override { return catalogName(); }
88 
89  virtual void registerDataOnMesh( Group & meshBodies ) override;
90 
98  virtual real64 scalingForWellSystemSolution( ElementSubRegionBase & subRegion,
99  DofManager const & dofManager,
100  arrayView1d< real64 const > const & localSolution ) override;
101  virtual real64
102  calculateWellResidualNorm( real64 const & time_n,
103  real64 const & dt,
104  WellElementSubRegion const & subRegion,
105  DofManager const & dofManager,
106  arrayView1d< real64 const > const & localRhs ) override;
107  virtual real64
108  calculateResidualNorm( real64 const & time_n,
109  real64 const & dt,
110  DomainPartition const & domain,
111  DofManager const & dofManager,
112  arrayView1d< real64 const > const & localRhs ) override;
113 
114  virtual bool
115  checkWellSystemSolution( ElementSubRegionBase & subRegion,
116  DofManager const & dofManager,
117  arrayView1d< real64 const > const & localSolution,
118  real64 const scalingFactor ) override;
119 
120  virtual bool
122  DofManager const & dofManager,
123  arrayView1d< real64 const > const & localSolution,
124  real64 const scalingFactor ) override;
125 
126  virtual void
127  applyWellSystemSolution( DofManager const & dofManager,
128  arrayView1d< real64 const > const & localSolution,
129  real64 const scalingFactor,
130  real64 const dt,
131  DomainPartition & domain,
132  MeshLevel & mesh,
133  WellElementSubRegion & subRegion ) override;
134  virtual void
135  applySystemSolution( DofManager const & dofManager,
136  arrayView1d< real64 const > const & localSolution,
137  real64 const scalingFactor,
138  real64 const dt,
139  DomainPartition & domain ) override;
140 
141  virtual void
143 
144  virtual void
145  implicitStepSetup( real64 const & time,
146  real64 const & dt,
147  DomainPartition & domain ) override;
148 
149  virtual void
151  real64 const & dt,
152  DomainPartition & domain ) override;
153 
156  virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); }
157 
158  virtual string resElementDofName() const override;
159 
160  virtual localIndex numFluidComponents() const override { return 1; }
161 
162  virtual localIndex numFluidPhases() const override { return 1; }
163 
169 
174  virtual void updateBHPForConstraint( WellElementSubRegion & subRegion );
175 
180  virtual void updateFluidModel( WellElementSubRegion & subRegion ) const;
186 
191  virtual void computePerforationRates( real64 const & time_n,
192  real64 const & dt, DomainPartition & domain ) override;
193 
199  virtual real64 updateWellState( WellElementSubRegion & subRegion ) override;
200  virtual void updateState( DomainPartition & domain ) override;
201 
206  virtual real64 updateSubRegionState( WellElementSubRegion & subRegion ) override;
207 
217  virtual void assembleSystem( real64 const time,
218  real64 const dt,
219  DomainPartition & domain,
220  DofManager const & dofManager,
221  CRSMatrixView< real64, globalIndex const > const & localMatrix,
222  arrayView1d< real64 > const & localRhs ) override;
223 
233  virtual void assembleWellFluxTerms( real64 const & time,
234  real64 const & dt,
235  WellElementSubRegion const & subRegion,
236  DofManager const & dofManager,
237  CRSMatrixView< real64, globalIndex const > const & localMatrix,
238  arrayView1d< real64 > const & localRhs ) override;
248  virtual void assembleFluxTerms( real64 const & time_n,
249  real64 const & dt,
250  DomainPartition & domain,
251  DofManager const & dofManager,
252  CRSMatrixView< real64, globalIndex const > const & localMatrix,
253  arrayView1d< real64 > const & localRhs ) override;
254 
263  virtual void assembleWellAccumulationTerms( real64 const & time,
264  real64 const & dt,
265  WellElementSubRegion & subRegion,
266  DofManager const & dofManager,
267  CRSMatrixView< real64, globalIndex const > const & localMatrix,
268  arrayView1d< real64 > const & localRhs ) override;
269 
270  virtual void assembleAccumulationTerms( real64 const & time_n,
271  real64 const & dt, DomainPartition & domain,
272  DofManager const & dofManager,
273  CRSMatrixView< real64, globalIndex const > const & localMatrix,
274  arrayView1d< real64 > const & localRhs ) override;
275 
284  DofManager const & dofManager,
285  CRSMatrixView< real64, globalIndex const > const & localMatrix,
286  arrayView1d< real64 > const & localRhs );
287 
288  virtual void assembleWellConstraintTerms( real64 const & time_n,
289  real64 const & dt,
290  WellElementSubRegion const & subRegion,
291  DofManager const & dofManager,
292  CRSMatrixView< real64, globalIndex const > const & localMatrix,
293  arrayView1d< real64 > const & localRhs ) override;
294 
295 
296  virtual void assembleWellPressureRelations( real64 const & time_n,
297  real64 const & dt,
298  WellElementSubRegion const & subRegion,
299  DofManager const & dofManager,
300  CRSMatrixView< real64, globalIndex const > const & localMatrix,
301  arrayView1d< real64 > const & localRhs ) override;
302 
303 
313  virtual void assemblePressureRelations( real64 const & time_n,
314  real64 const & dt,
315  DomainPartition const & domain,
316  DofManager const & dofManager,
317  CRSMatrixView< real64, globalIndex const > const & localMatrix,
318  arrayView1d< real64 > const & localRhs ) override;
319 
320  /*
321  * @brief apply a special treatment to the wells that are shut
322  * @param time_n the time at the previous converged time step
323  * @param domain the physical domain object
324  * @param dofManager degree-of-freedom manager associated with the linear system
325  * @param matrix the system matrix
326  * @param rhs the system right-hand side vector
327  */
328  void shutDownWell( real64 const time_n,
329  DomainPartition const & domain,
330  DofManager const & dofManager,
331  CRSMatrixView< real64, globalIndex const > const & localMatrix,
332  arrayView1d< real64 > const & localRhs );
334  {
335  static constexpr char const * dofFieldString() { return "singlePhaseWellVars"; }
336 
337  // control data (not registered on the mesh)
338  static constexpr char const * currentBHPString() { return "currentBHP"; }
339  static constexpr char const * dCurrentBHPString() { return "dCurrentBHP"; }
340  static constexpr char const * currentVolRateString() { return "currentVolumetricRate"; }
341  static constexpr char const * dCurrentVolRateString() { return "dCurrentVolRate"; }
342  };
343 
344 protected:
345 
347 
348  void saveState( WellElementSubRegion & subRegion );
349 
350  void printRates( real64 const & time_n,
351  real64 const & dt,
352  DomainPartition & domain ) override;
353 
356 
357 private:
358 
359  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
360 
365  void initializeWells( DomainPartition & domain, real64 const & time_n ) override;
366  void initializeWell( DomainPartition & domain, MeshLevel & mesh, WellElementSubRegion & subRegion, real64 const & time_n ) override;
374  virtual void validateWellConstraints( real64 const & time_n,
375  real64 const & dt,
376  WellElementSubRegion const & subRegion,
377  ElementRegionManager const & elemManager ) override;
378 
379  virtual bool evaluateConstraints( real64 const & time_n ,
380  real64 const & GEOS_UNUSED_PARAM( stepDt ),
381  integer const GEOS_UNUSED_PARAM( cycleNumber ),
382  integer const GEOS_UNUSED_PARAM( coupledIterationNumber ),
384  MeshLevel & GEOS_UNUSED_PARAM( mesh ),
385  ElementRegionManager & GEOS_UNUSED_PARAM( elemManager ),
386  WellElementSubRegion & subRegion ,
387  DofManager const & GEOS_UNUSED_PARAM( dofManager ) ) override;
388 
389 
393  void createSeparator();
394 
395 };
396 
397 } // namespace geos
398 
399 
400 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:72
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 ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
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) on the well...
virtual string resElementDofName() const override
get the name of DOF defined on well elements
virtual void assembleWellAccumulationTerms(real64 const &time, real64 const &dt, WellElementSubRegion &subRegion, 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 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
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
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
virtual void calculateReferenceElementRates(WellElementSubRegion &subRegion)
Recompute the volumetric rate that are used in the well constraints.
SinglePhaseWell & operator=(SinglePhaseWell const &)=delete
deleted assignment operator
SinglePhaseWell(SinglePhaseWell const &)=delete
deleted copy constructor
virtual void updateState(DomainPartition &domain) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual real64 updateWellState(WellElementSubRegion &subRegion) override
Recompute all dependent quantities from primary variables (including constitutive models)
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
void updateSeparator(WellElementSubRegion &subRegion)
Update separator model state.
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 void assembleWellFluxTerms(real64 const &time, real64 const &dt, WellElementSubRegion const &subRegion, 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 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