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 Total, S.A
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 
152  virtual void registerDataOnMesh( Group & meshBodies ) override;
153 
154  virtual void setupDofs( DomainPartition const & domain,
155  DofManager & dofManager ) const override;
156 
157  virtual void implicitStepSetup( real64 const & time_n,
158  real64 const & dt,
159  DomainPartition & domain ) override;
160 
161  virtual void implicitStepComplete( real64 const & GEOS_UNUSED_PARAM( time_n ),
162  real64 const & GEOS_UNUSED_PARAM( dt ),
163  DomainPartition & GEOS_UNUSED_PARAM( domain ) ) override {}
164 
165  virtual void applyBoundaryConditions( real64 const GEOS_UNUSED_PARAM( time_n ),
166  real64 const GEOS_UNUSED_PARAM( dt ),
168  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
170  arrayView1d< real64 > const & GEOS_UNUSED_PARAM( localRhs ) ) override {}
171 
172 
184  virtual void assembleSystem( real64 const time,
185  real64 const dt,
186  DomainPartition & domain,
187  DofManager const & dofManager,
188  CRSMatrixView< real64, globalIndex const > const & localMatrix,
189  arrayView1d< real64 > const & localRhs ) override;
190 
200  virtual void assembleFluxTerms( real64 const & time_n,
201  real64 const & dt,
202  DomainPartition & domain,
203  DofManager const & dofManager,
204  CRSMatrixView< real64, globalIndex const > const & localMatrix,
205  arrayView1d< real64 > const & localRhs ) = 0;
206 
214  virtual void assembleAccumulationTerms( real64 const & time_n,
215  real64 const & dt,
216  DomainPartition & domain,
217  DofManager const & dofManager,
218  CRSMatrixView< real64, globalIndex const > const & localMatrix,
219  arrayView1d< real64 > const & localRhs ) = 0;
220 
230  virtual void assemblePressureRelations( real64 const & time_n,
231  real64 const & dt,
232  DomainPartition const & domain,
233  DofManager const & dofManager,
234  CRSMatrixView< real64, globalIndex const > const & localMatrix,
235  arrayView1d< real64 > const & localRhs ) = 0;
236 
241  virtual void updateState( DomainPartition & domain ) override;
242 
248 
253  virtual void computePerforationRates( real64 const & time_n,
254  real64 const & dt,
255  DomainPartition & domain ) = 0;
256 
262  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep )
263  { m_keepVariablesConstantDuringInitStep = keepVariablesConstantDuringInitStep; }
264 
266  {
267  static constexpr char const * fluidNamesString() { return "fluidNames"; }
268  static constexpr char const * isThermalString() { return "isThermal"; }
269  static constexpr char const * writeCSVFlagString() { return "writeCSV"; }
270  };
271 
272 private:
273 
278  void precomputeData( DomainPartition & domain );
279 
280  virtual void setConstitutiveNamesCallSuper( ElementSubRegionBase & subRegion ) const override;
281 
282 
283 protected:
284 
285  virtual void postInputInitialization() override;
286 
288 
289  virtual void initializePostSubGroups() override;
290 
295  virtual void initializeWells( DomainPartition & domain, real64 const & time_n, real64 const & dt ) = 0;
296 
303  virtual void validateWellConstraints( real64 const & time_n,
304  real64 const & dt,
305  WellElementSubRegion const & subRegion ) = 0;
306 
307  virtual void printRates( real64 const & time_n,
308  real64 const & dt,
309  DomainPartition & domain ) = 0;
310 
313 
316 
319 
322 
325 
328 
331  string const m_ratesOutputDir;
332 
335 
338 };
339 
340 }
341 
342 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLSOLVERBASE_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:44
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.
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.
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_keepVariablesConstantDuringInitStep
flag to freeze the initial state during initialization in coupled problems
virtual void initializeWells(DomainPartition &domain, real64 const &time_n, real64 const &dt)=0
Initialize all the primary and secondary variables in all the wells.
integer m_numDofPerResElement
the number of Degrees of Freedom per reservoir element
WellSolverBase(WellSolverBase &&)=default
default move constructor
virtual string resElementDofName() const =0
get the name of DOF defined on well elements
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:180
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:310
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
Structure to hold scoped key names.