GEOS
WellManager.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_WELL_MANAGER_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELL_MANAGER_HPP_
22 
28 namespace geos
29 {
30 
31 class DomainPartition;
32 class WellControls;
33 class WellElementSubRegion;
34 
35 namespace dataRepository
36 {
37 namespace keys
38 {
39 static constexpr auto compositionalMultiphaseWell = "CompositionalMultiphaseWell";
40 static constexpr auto singlePhaseWell = "SinglePhaseWell";
41 }
42 }
50 {
51 public:
52 
54  static string coupledSolverAttributePrefix() { return "well"; }
55 
61  WellManager( const string & name,
62  Group * const parent );
63 
65  virtual ~WellManager() override = default;
66 
68  WellManager() = delete;
69 
71  WellManager( WellManager const & ) = delete;
72 
74  WellManager( WellManager && ) = default;
75 
77  WellManager & operator=( WellManager const & ) = delete;
78 
80  WellManager & operator=( WellManager && ) = delete;
81 
82  virtual Group * createChild( string const & childKey, string const & childName ) override;
83 
85  virtual void expandObjectCatalogs() override;
86 
91  void setFlowSolverName( string const & name ) { m_flowSolverName = name; }
92 
97  void setCompositional( bool const & isCompositional ) { m_isCompositional = isCompositional; }
98 
103  bool isCompositional() const { return m_isCompositional; }
104 
105 
110  string const & getFlowSolverName() const { return m_flowSolverName; }
111 
112 
117  static string catalogName() { return "WellManager"; }
121  string getCatalogName() const override { return catalogName(); }
122 
123  virtual void registerDataOnMesh( Group & meshBodies ) override;
129  WellControls & getWell( WellElementSubRegion const & subRegion );
130 
136  WellControls & getWell( std::string const & wellControlsName );
137 
143  WellControls const & getWell( std::string const & wellControlsName ) const;
148  string wellElementDofName() const;
149 
151  {
152  static constexpr char const * dofFieldString() { return "wellVars"; }
153  static constexpr char const * isThermalString() { return "isThermal"; }
154  static constexpr char const * useMassFlagString() {return "useMass"; }
156  static constexpr char const * targetRegionsString() { return "targetRegions"; }
157  static constexpr char const * timeStepFromTablesFlagString() { return "timeStepFromTables"; }
158  static constexpr char const * useTotalMassEquationString() { return "useTotalMassEquation"; }
159  static constexpr char const * allowLocalCompDensChoppingString() { return CompositionalMultiphaseBase::viewKeyStruct::allowLocalCompDensChoppingString(); }
160 
161 
162  };
163 
169 
175 
181 
182 
187  virtual string resElementDofName() const;
188 
194 
199  virtual localIndex numFluidPhases() const;
200 
205  integer useTotalMassEquation() const { return m_useTotalMassEquation; }
206 
213 
219  WellControls const & getWellControls( WellElementSubRegion const & subRegion ) const;
220 
227 
234 
243  void selectWellConstraint( real64 const & time_n,
244  real64 const & dt,
245  integer const coupledIterationNumber,
246  DomainPartition & domain );
247  /* PhysicsSolverBase interfaces */
248 
256  virtual real64 setNextDt( real64 const & currentTime,
257  real64 const & currentDt,
258  DomainPartition & domain ) override;
259 
260  virtual void setupDofs( DomainPartition const & domain,
261  DofManager & dofManager ) const override;
262 
275  virtual void
276  implicitStepSetup( real64 const & time_n,
277  real64 const & dt,
278  DomainPartition & domain ) override;
279 
280 
299  virtual void
300  assembleSystem( real64 const time,
301  real64 const dt,
302  DomainPartition & domain,
303  DofManager const & dofManager,
304  CRSMatrixView< real64, globalIndex const > const & localMatrix,
305  arrayView1d< real64 > const & localRhs ) override;
306 
307 
308  virtual void
310 
311  virtual void
313  real64 const & dt,
314  DomainPartition & domain ) override;
315 
316  virtual void applyBoundaryConditions( real64 const GEOS_UNUSED_PARAM( time_n ),
317  real64 const GEOS_UNUSED_PARAM( dt ),
319  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
321  arrayView1d< real64 > const & GEOS_UNUSED_PARAM( localRhs ) ) override {}
322 
335  virtual real64
337  real64 const & dt,
338  DomainPartition const & domain,
339  DofManager const & dofManager,
340  arrayView1d< real64 const > const & localRhs ) override;
345  virtual void updateState( DomainPartition & domain ) override;
346 
354  virtual real64
356  DofManager const & dofManager,
357  arrayView1d< real64 const > const & localSolution )override;
358 
371  virtual bool
373  DofManager const & dofManager,
374  arrayView1d< real64 const > const & localSolution,
375  real64 const scalingFactor ) override;
376 
398  virtual void
399  applySystemSolution( DofManager const & dofManager,
400  arrayView1d< real64 const > const & localSolution,
401  real64 const scalingFactor,
402  real64 const dt,
403  DomainPartition & domain ) override;
404 
410 
419  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep );
420 
421 
422 protected:
423  //virtual void postInputInitialization() override;
424 
425  virtual void initializePostSubGroups() override;
426 
428 
429  virtual void postRestartInitialization() override final;
430 
431 
432 private:
433 
435  string m_flowSolverName;
436 
438  integer m_useMass;
439 
441  integer m_useTotalMassEquation;
442 
444  integer m_isThermal;
445 
447  bool m_isCompositional;
448 
449 
451  integer m_numFluidPhases;
452 
454  integer m_numFluidComponents;
455 
457  integer m_numDofPerWellElement;
458 
460  integer m_numDofPerResElement;
461 
463  real64 m_minScalingFactor;
464 
466  integer m_allowCompDensChopping;
467 
468  // flag to enable time step selection base on rates/bhp tables coordinates
469  integer m_timeStepFromTables;
470 };
471 
472 }
473 
474 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELL_MANAGER_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.
string wellElementDofName() const
get the name of DOF defined on well elements
CompositionalMultiphaseWell const & getCompositionalMultiphaseWell(WellElementSubRegion const &subRegion) const
const getter for the compositional multiphase well associated to this well subRegion
virtual localIndex numFluidComponents() const
const getter for the number of fluid components
void setKeepVariablesConstantDuringInitStep(bool const keepVariablesConstantDuringInitStep)
Utility function to keep the well variables during a time step (used in poromechanics simulations)
WellControls const & getWellControls(WellElementSubRegion const &subRegion) const
const getter for the well controls associated to this well subRegion
virtual void implicitStepSetup(real64 const &time_n, real64 const &dt, DomainPartition &domain) override
function to perform setup for implicit timestep
void selectWellConstraint(real64 const &time_n, real64 const &dt, integer const coupledIterationNumber, DomainPartition &domain)
Selects the active well constraint based on current conditions.
virtual real64 setNextDt(real64 const &currentTime, real64 const &currentDt, DomainPartition &domain) override
function to set the next time step size
WellManager & operator=(WellManager &&)=delete
deleted move operator
string getCatalogName() const override
string const & getFlowSolverName() const
getter for the name of the flow solver (used in UpdateState)
WellControls const & getWell(std::string const &wellControlsName) const
Get a well solver for a given well element sub-region.
void setCompositional(bool const &isCompositional)
setter for compositional flag
Definition: WellManager.hpp:97
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 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.
void setFlowSolverName(string const &name)
setter for the name of the flow solver (needed to use the flow kernels like UpdateFluid)
Definition: WellManager.hpp:91
virtual void initializePostSubGroups() override
Called by Initialize() after to initializing sub-Groups.
void chopNegativeDensities(DomainPartition &domain)
Sets all the negative component densities (if any) to zero.
WellManager(WellManager const &)=delete
deleted copy constructor
static string catalogName()
name of the node manager in the object catalog
localIndex numDofPerResElement() const
getter for the number of degrees of freedom per mesh element
virtual Group * createChild(string const &childKey, string const &childName) override
Creates a new sub-Group using the ObjectCatalog functionality.
WellManager & operator=(WellManager const &)=delete
deleted assignment operator
WellControls & getWellControls(WellElementSubRegion const &subRegion)
getter for the well controls associated to this well subRegion
WellManager(WellManager &&)=default
default move constructor
WellManager(const string &name, Group *const parent)
main constructor for Group Objects
virtual void postRestartInitialization() override final
Performs initialization required after reading from a restart file.
integer useTotalMassEquation() const
const getter for well total mass equation usage
virtual void updateState(DomainPartition &domain) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual string resElementDofName() const
get the name of DOF defined on well elements
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 void expandObjectCatalogs() override
Expand catalog for schema generation.
virtual ~WellManager() override=default
default destructor
localIndex numDofPerWellElement() const
getter for the number of degrees of freedom per well element
WellControls & getWell(std::string const &wellControlsName)
Get a well solver for a given well element sub-region.
virtual void setupDofs(DomainPartition const &domain, DofManager &dofManager) const override
Populate degree-of-freedom manager with fields relevant to this solver.
bool isCompositional() const
getter for compositional flag
CompositionalMultiphaseWell & getCompositionalMultiphaseWell(WellElementSubRegion const &subRegion)
getter for the compositional multiphase well associated to this well subRegion
virtual real64 calculateResidualNorm(real64 const &time, real64 const &dt, DomainPartition const &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localRhs) override
calculate the norm of the global system residual
WellControls & getWell(WellElementSubRegion const &subRegion)
Get a well solver for a given well element sub-region.
WellManager()=delete
deleted default constructor
virtual real64 scalingForSystemSolution(DomainPartition &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localSolution) override
Function to determine if the solution vector should be scaled back in order to maintain a known const...
static string coupledSolverAttributePrefix()
String used to form the solverName used to register single-physics solvers in CoupledSolver.
Definition: WellManager.hpp:54
virtual void resetStateToBeginningOfStep(DomainPartition &domain) override
reset state of physics back to the beginning of the step.
virtual localIndex numFluidPhases() const
const getter for the number of fluid phases
integer isThermal() const
getter for iso/thermal switch
virtual void implicitStepComplete(real64 const &time, real64 const &dt, DomainPartition &domain) override
perform cleanup for implicit timestep
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
virtual void registerDataOnMesh(Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
std::string string
String type.
Definition: DataTypes.hpp:90
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()