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 
23 #include "physicsSolvers/fluidFlow/wells/WellControls.hpp"
24 #include "dataRepository/Group.hpp"
25 namespace geos
26 {
27 
28 class DomainPartition;
29 
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 
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 
143 
149  WellControls const & getWellControls( WellElementSubRegion const & subRegion ) const;
150 
151 
157  void setPerforationStatus( real64 const & time_n, DomainPartition & domain );
158  void setPerforationStatus( real64 const & time_n, WellElementSubRegion & subRegion );
168  virtual void registerDataOnMesh( Group & meshBodies ) override;
169 
170  virtual real64
171  calculateWellResidualNorm( real64 const & GEOS_UNUSED_PARAM( time_n ),
172  real64 const & GEOS_UNUSED_PARAM( dt ),
173  WellElementSubRegion const & GEOS_UNUSED_PARAM( subRegion ),
174  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
175  arrayView1d< real64 const > const & GEOS_UNUSED_PARAM( localRhs ) ) = 0;
176 
177  virtual real64
178  scalingForWellSystemSolution( ElementSubRegionBase & GEOS_UNUSED_PARAM( subRegion ),
179  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
180  arrayView1d< real64 const > const & GEOS_UNUSED_PARAM( localSolution ) ) = 0;
181 
182  virtual bool
183  checkWellSystemSolution( ElementSubRegionBase & GEOS_UNUSED_PARAM( subRegion ),
184  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
185  arrayView1d< real64 const > const & GEOS_UNUSED_PARAM( localSolution ),
186  real64 const GEOS_UNUSED_PARAM( scalingFactor ) ) = 0;
187  virtual void
188  applyWellSystemSolution( DofManager const & GEOS_UNUSED_PARAM( dofManager ),
189  arrayView1d< real64 const > const & GEOS_UNUSED_PARAM( localSolution ),
190  real64 const GEOS_UNUSED_PARAM( scalingFactor ),
191  real64 const GEOS_UNUSED_PARAM( dt ),
193  MeshLevel & GEOS_UNUSED_PARAM( mesh ),
194  WellElementSubRegion & GEOS_UNUSED_PARAM( subRegion ) ) = 0;
195 
203  virtual real64 setNextDt( real64 const & currentTime,
204  real64 const & currentDt,
205  DomainPartition & domain ) override;
206  virtual void setupDofs( DomainPartition const & domain,
207  DofManager & dofManager ) const override;
208 
209 
210  virtual void implicitStepComplete( real64 const & GEOS_UNUSED_PARAM( time_n ),
211  real64 const & GEOS_UNUSED_PARAM( dt ),
212  DomainPartition & GEOS_UNUSED_PARAM( domain ) ) override {}
213 
214 
215  virtual void applyBoundaryConditions( real64 const GEOS_UNUSED_PARAM( time_n ),
216  real64 const GEOS_UNUSED_PARAM( dt ),
218  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
220  arrayView1d< real64 > const & GEOS_UNUSED_PARAM( localRhs ) ) override {}
221 
230  void selectWellConstraint( real64 const & time_n,
231  real64 const & dt,
232  integer const coupledIterationNumber,
233  DomainPartition & domain );
234 
240  virtual void assembleSystem( real64 const time,
241  real64 const dt,
242  DomainPartition & domain,
243  DofManager const & dofManager,
244  CRSMatrixView< real64, globalIndex const > const & localMatrix,
245  arrayView1d< real64 > const & localRhs ) override;
246 
257  virtual void assembleFluxTerms( real64 const & time_n,
258  real64 const & dt,
259  DomainPartition & domain,
260  DofManager const & dofManager,
261  CRSMatrixView< real64, globalIndex const > const & localMatrix,
262  arrayView1d< real64 > const & localRhs ) = 0;
263 
271  virtual void assembleAccumulationTerms( real64 const & time_n,
272  real64 const & dt,
273  DomainPartition & domain,
274  DofManager const & dofManager,
275  CRSMatrixView< real64, globalIndex const > const & localMatrix,
276  arrayView1d< real64 > const & localRhs ) = 0;
277 
278 
279 
286  virtual real64 updateWellState( MeshBody const & meshBody,
287  ElementRegionManager const & elemManager,
288  WellElementSubRegion & subRegion ) = 0;
294  virtual void updateState( DomainPartition & domain ) override;
295 
300  virtual void initializeWells( DomainPartition & domain, real64 const & time_n ) = 0;
301 
309 
310 
315  virtual void computePerforationRates( real64 const & time_n,
316  real64 const & dt,
317  DomainPartition & domain ) = 0;
318 
319 
328  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep )
329  { m_keepVariablesConstantDuringInitStep = keepVariablesConstantDuringInitStep; }
330 
332  {
333  static constexpr char const * isThermalString() { return "isThermal"; }
334  static constexpr char const * writeCSVFlagString() { return "writeCSV"; }
335  static constexpr char const * timeStepFromTablesFlagString() { return "timeStepFromTables"; }
337  static constexpr char const * targetRegionsString() { return "targetRegions"; }
338 
339  static constexpr char const * fluidNamesString() { return "fluidNames"; }
340  };
341 
342 private:
343 
348  void precomputeData( DomainPartition & domain );
349 
350 protected:
351 
352  virtual void postInputInitialization() override;
353 
355 
356  virtual void initializePostSubGroups() override;
357 
358 
365  virtual void validateWellConstraints( real64 const & time_n,
366  real64 const & dt,
367  WellElementSubRegion const & subRegion ) = 0;
368 
369  virtual void printRates( real64 const & time_n,
370  real64 const & dt,
371  DomainPartition & domain ) = 0;
372 
373 
374 
377 
380 
383 
386 
389 
392 
395  string const m_ratesOutputDir;
396 
397  // flag to enable time step selection base on rates/bhp tables coordinates
398  integer m_timeStepFromTables;
399 
402 
405 
408 
409 };
410 
411 }
412 
413 #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...
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
The class is used to manage mesh body.
Definition: MeshBody.hpp:36
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
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
Create a new constraint object as a child of this group.
virtual real64 updateWellState(MeshBody const &meshBody, ElementRegionManager const &elemManager, WellElementSubRegion &subRegion)=0
Recompute all dependent quantities from primary variables (including constitutive models)
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 individual well for all connections between well elements
WellSolverBase & getWell(WellElementSubRegion const &subRegion)
getter for the well associated to this subRegion
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
WellSolverBase(WellSolverBase &&)=delete
default move constructor
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
virtual void initializeWells(DomainPartition &domain, real64 const &time_n)=0
Initialize all the primary and secondary variables in all the wells.
integer m_estimateSolution
flag to use the estimator
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
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 data on mesh entities.
virtual real64 setNextDt(real64 const &currentTime, real64 const &currentDt, DomainPartition &domain) override
function to set the next time step size
void selectWellConstraint(real64 const &time_n, real64 const &dt, integer const coupledIterationNumber, DomainPartition &domain)
Selects the active well constraint based on current conditions.
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.
static constexpr char const * targetRegionsString()