GEOS
WellSolverBase.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_WELLSOLVERBASE_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLSOLVERBASE_HPP_
22 
24 
25 namespace geos
26 {
27 
28 class DomainPartition;
29 class WellControls;
30 class WellElementSubRegion;
31 
39 {
40 public:
41 
43  static string coupledSolverAttributePrefix() { return "well"; }
44 
50  WellSolverBase( const string & name,
51  Group * const parent );
52 
54  virtual ~WellSolverBase() override;
55 
57  WellSolverBase() = delete;
58 
60  WellSolverBase( WellSolverBase const & ) = delete;
61 
63  WellSolverBase( WellSolverBase && ) = default;
64 
66  WellSolverBase & operator=( WellSolverBase const & ) = delete;
67 
70 
71  virtual Group * createChild( string const & childKey, string const & childName ) override;
72 
74  virtual void expandObjectCatalogs() override;
75 
76 
81  void setFlowSolverName( string const & name ) { m_flowSolverName = name; }
82 
87  string const & getFlowSolverName() const { return m_flowSolverName; }
88 
94 
100 
105  integer isThermal() const { return m_isThermal; }
106 
111  virtual string wellElementDofName() const = 0;
112 
117  virtual string resElementDofName() const = 0;
118 
123  virtual localIndex numFluidComponents() const = 0;
124 
129  virtual localIndex numFluidPhases() const = 0;
130 
137 
143  WellControls const & getWellControls( WellElementSubRegion const & subRegion ) const;
144 
145 
151  void setPerforationStatus( real64 const & time_n, DomainPartition & domain );
152 
160  virtual void registerDataOnMesh( Group & meshBodies ) override;
161 
162  virtual void setupDofs( DomainPartition const & domain,
163  DofManager & dofManager ) const override;
164 
165  virtual void implicitStepSetup( real64 const & time_n,
166  real64 const & dt,
167  DomainPartition & domain ) override;
168 
169  virtual void implicitStepComplete( real64 const & GEOS_UNUSED_PARAM( time_n ),
170  real64 const & GEOS_UNUSED_PARAM( dt ),
171  DomainPartition & GEOS_UNUSED_PARAM( domain ) ) override {}
172 
173  virtual void applyBoundaryConditions( real64 const GEOS_UNUSED_PARAM( time_n ),
174  real64 const GEOS_UNUSED_PARAM( dt ),
176  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
178  arrayView1d< real64 > const & GEOS_UNUSED_PARAM( localRhs ) ) override {}
179 
180 
192  virtual void assembleSystem( real64 const time,
193  real64 const dt,
194  DomainPartition & domain,
195  DofManager const & dofManager,
196  CRSMatrixView< real64, globalIndex const > const & localMatrix,
197  arrayView1d< real64 > const & localRhs ) override;
198 
208  virtual void assembleFluxTerms( real64 const & time_n,
209  real64 const & dt,
210  DomainPartition & domain,
211  DofManager const & dofManager,
212  CRSMatrixView< real64, globalIndex const > const & localMatrix,
213  arrayView1d< real64 > const & localRhs ) = 0;
214 
222  virtual void assembleAccumulationTerms( real64 const & time_n,
223  real64 const & dt,
224  DomainPartition & domain,
225  DofManager const & dofManager,
226  CRSMatrixView< real64, globalIndex const > const & localMatrix,
227  arrayView1d< real64 > const & localRhs ) = 0;
228 
238  virtual void assemblePressureRelations( real64 const & time_n,
239  real64 const & dt,
240  DomainPartition const & domain,
241  DofManager const & dofManager,
242  CRSMatrixView< real64, globalIndex const > const & localMatrix,
243  arrayView1d< real64 > const & localRhs ) = 0;
244 
249  virtual void updateState( DomainPartition & domain ) override;
250 
257 
262  virtual void computePerforationRates( real64 const & time_n,
263  real64 const & dt,
264  DomainPartition & domain ) = 0;
265 
273  virtual real64 setNextDt( real64 const & currentTime,
274  real64 const & currentDt,
275  DomainPartition & domain ) override;
276 
282  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep )
283  { m_keepVariablesConstantDuringInitStep = keepVariablesConstantDuringInitStep; }
284 
286  {
287  static constexpr char const * isThermalString() { return "isThermal"; }
288  static constexpr char const * writeCSVFlagString() { return "writeCSV"; }
289  static constexpr char const * timeStepFromTablesFlagString() { return "timeStepFromTables"; }
290 
291  static constexpr char const * fluidNamesString() { return "fluidNames"; }
292  };
293 
294 private:
295 
300  void precomputeData( DomainPartition & domain );
301 
302 protected:
303 
304  virtual void postInputInitialization() override;
305 
307 
308  virtual void initializePostSubGroups() override;
309 
314  virtual void initializeWells( DomainPartition & domain, real64 const & time_n ) = 0;
315 
322  virtual void validateWellConstraints( real64 const & time_n,
323  real64 const & dt,
324  WellElementSubRegion const & subRegion ) = 0;
325 
326  virtual void printRates( real64 const & time_n,
327  real64 const & dt,
328  DomainPartition & domain ) = 0;
329 
332 
335 
338 
341 
344 
347 
350  string const m_ratesOutputDir;
351 
352  // flag to enable time step selection base on rates/bhp tables coordinates
353  integer m_timeStepFromTables;
354 
357 
360 };
361 
362 }
363 
364 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLSOLVERBASE_HPP_
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:97
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...
Base class for all physics solvers.
This class describes the controls used to operate a well.
This class describes a collection of local well elements and perforations.
virtual string wellElementDofName() const =0
get the name of DOF defined on well elements
virtual void validateWellConstraints(real64 const &time_n, real64 const &dt, WellElementSubRegion const &subRegion)=0
Make sure that the well constraints are compatible.
bool m_keepVariablesConstantDuringInitStep
flag to freeze the initial state during initialization in coupled problems
virtual real64 updateSubRegionState(WellElementSubRegion &subRegion)=0
Recompute all dependent quantities from primary variables (including constitutive models)
virtual void computePerforationRates(real64 const &time_n, real64 const &dt, DomainPartition &domain)=0
Recompute the perforation rates for all the wells.
void setPerforationStatus(real64 const &time_n, DomainPartition &domain)
Open and close perfs based on user defined perf status table.
string m_flowSolverName
name of the flow solver
virtual void expandObjectCatalogs() override
Expand catalog for schema generation.
integer m_isThermal
flag indicating whether thermal formulation is used
virtual void updateState(DomainPartition &domain) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
virtual localIndex numFluidPhases() const =0
Get the number of fluid phases.
integer m_numComponents
the number of fluid components
virtual Group * createChild(string const &childKey, string const &childName) override
creates a child group of of this PhysicsSolverBase instantiation
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)=0
assembles the accumulation term for all the well elements
virtual void initializePostSubGroups() override
Called by Initialize() after to initializing sub-Groups.
string m_referenceFluidModelName
name of the fluid constitutive model used as a reference for component/phase description
integer m_numDofPerWellElement
the number of Degrees of Freedom per well element
static string coupledSolverAttributePrefix()
String used to form the solverName used to register single-physics solvers in CoupledSolver.
string const & getFlowSolverName() const
getter for the name of the flow solver (used in UpdateState)
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)=0
assembles the flux terms for all connections between well elements
WellControls & getWellControls(WellElementSubRegion const &subRegion)
getter for the well controls associated to this well subRegion
localIndex numDofPerResElement() const
getter for the number of degrees of freedom per mesh element
virtual localIndex numFluidComponents() const =0
const getter for the number of fluid components
integer isThermal() const
getter for iso/thermal switch
virtual void postInputInitialization() override
integer m_writeCSV
rates output
WellControls const & getWellControls(WellElementSubRegion const &subRegion) const
const getter for the well controls associated to this well subRegion
integer m_numDofPerResElement
the number of Degrees of Freedom per reservoir element
WellSolverBase(WellSolverBase &&)=default
default move constructor
virtual void initializeWells(DomainPartition &domain, real64 const &time_n)=0
Initialize all the primary and secondary variables in all the wells.
virtual string resElementDofName() const =0
get the name of DOF defined on well elements
virtual real64 setNextDt(real64 const &currentTime, real64 const &currentDt, DomainPartition &domain) override
function to set the next time step size
localIndex numDofPerWellElement() const
getter for the number of degrees of freedom per well element
WellSolverBase()=delete
deleted default constructor
WellSolverBase & operator=(WellSolverBase const &)=delete
deleted assignment operator
WellSolverBase(WellSolverBase const &)=delete
deleted copy constructor
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)=0
assembles the pressure relations at all connections between well elements except at the well head
integer m_numPhases
the max number of fluid phases
void setFlowSolverName(string const &name)
setter for the name of the flow solver (needed to use the flow kernels like UpdateFluid)
virtual ~WellSolverBase() override
default destructor
WellSolverBase & operator=(WellSolverBase &&)=delete
deleted move operator
void setKeepVariablesConstantDuringInitStep(bool const keepVariablesConstantDuringInitStep)
Utility function to keep the well variables during a time step (used in poromechanics simulations)
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
WellSolverBase(const string &name, Group *const parent)
main constructor for Group Objects
virtual void registerDataOnMesh(Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
virtual void implicitStepSetup(real64 const &time_n, real64 const &dt, DomainPartition &domain) override
function to perform setup for implicit timestep
virtual void setupDofs(DomainPartition const &domain, DofManager &dofManager) const override
Populate degree-of-freedom manager with fields relevant to this solver.
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
Structure to hold scoped key names.