GEOS
WellConstraintsBase.hpp
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 
16 /*
17  * @file WellConstraintBase.hpp
18  */
19 
20 
21 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONSTRAINTBASE_HPP
22 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONSTRAINTBASE_HPP
23 
25 
27 #include "dataRepository/Group.hpp"
28 namespace geos
29 {
30 
31 
32 
34 {
35  BHP,
36  PHASEVOLRATE,
37  TOTALVOLRATE,
38  MASSRATE,
39  WHP,
40  LIQUIDRATE,
42 };
43 
44 /*
45  class WellContraint : public dataRepository::Group
46  {
47  public:
48 
49  virtual bool estimateWellSolution()=0;
50  virtual void assembleConstraintEquation()=0;
51  virtual void getBHP()=0;
52  virtual void getPhaseRate(integer phase)=0;
53  }
54  */
55 
56 
62 {
63 public:
64  friend class WellControls;
65 
68 
71 
76 
82  explicit WellConstraintBase( string const & name, dataRepository::Group * const parent );
83 
84 
88  ~WellConstraintBase() override;
89 
93  WellConstraintBase() = delete;
94 
99 
104 
110 
116 
118 
119 
124 
125  // Temp interface - tjb
126  virtual ConstraintTypeId getControl() const = 0;
127 
135  bool isConstraintActive( ) const { return m_isConstraintActive; }
136 
141  bool setConstraintActive( bool const & constraintActive ) { return m_isConstraintActive=constraintActive; }
142 
147  void setConstraintValue( real64 const & constraintValue )
148  {
149  m_constraintValue = constraintValue;
150  }
151 
156  real64 getConstraintValue( real64 const & currentTime ) const
157  {
158  if( m_constraintScheduleTableName.empty() )
159  {
161  }
162 
163  return m_rateSign*m_constraintScheduleTable->evaluate( &currentTime );
164  }
165 
167 
173  {
175  static constexpr char const * constraintScheduleTableNameString() { return "constraintScheduleTableName"; }
176 
178  static constexpr char const * constraintValueString() { return "constraintValue"; }
179 
180 
181  }
184 
185  // Quantities computed from well constraint solve with this boundary condition
186  // This needs to be somewhere else tjb
187  void setBHP( real64 bhp ){ m_BHP=bhp;};
188  void setPhaseVolumeRates( array1d< real64 > const & phaseVolumeRates ) { m_phaseVolumeRates = phaseVolumeRates; };
189  void setTotalVolumeRate( real64 totalVolumeRate ){ m_totalVolumeRate = totalVolumeRate; };
190  void setMassRate( real64 massRate ){ m_massRate = massRate; };
191 
196  real64 bottomHolePressure() const { return m_BHP; }
197 
202  arrayView1d< real64 const > phaseVolumeRates() const { return m_phaseVolumeRates; }
203 
208  real64 totalVolumeRate() const { return m_totalVolumeRate; }
209 
214  real64 liquidRate() const { return m_liquidRate; }
215 
220  real64 massRate() const { return m_massRate; }
221 
222  // endof This needs to be somewhere else tjb
227  virtual bool checkViolation( WellConstraintBase const & currentConstraint, real64 const & currentTime ) const = 0;
228 
229 protected:
230 
231  virtual void postInputInitialization() override;
232 
238  void setNextDtFromTables( real64 const currentTime, real64 & nextDt );
239 
240 
241 protected:
242 
245 
248 
251 
252  void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
253 
256 
259 
260  // Quantities computed from well constraint solve with this boundary condition
261 
262  // botton hole pressure
263  real64 m_BHP;
264 
265  // phase rates
266  array1d< real64 > m_phaseVolumeRates;
267 
268  // liquid rate
269  real64 m_liquidRate;
270 
271  // total volume rate
272  real64 m_totalVolumeRate;
273 
274  // mass rate
275  real64 m_massRate;
276 
279 };
280 
281 
282 } //namespace geos
283 
284 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONSTRAINTBASE_HPP
virtual void evaluate(dataRepository::Group const &group, real64 const time, SortedArrayView< localIndex const > const &set, arrayView1d< real64 > const &result) const override final
Method to evaluate a function on a target object.
static CatalogInterface::CatalogType & getCatalog()
Get the singleton catalog for WellConstraintBase.
WellConstraintBase & operator=(WellConstraintBase const &)=delete
Deleted assignment operator.
WellConstraintBase & operator=(WellConstraintBase &&)=delete
Deleted move operator.
WellConstraintBase(WellConstraintBase const &)=delete
Deleted copy constructor.
bool setConstraintActive(bool const &constraintActive)
Sets constraint active status.
real64 totalVolumeRate() const
Getter for the total volume rate.
void setNextDtFromTables(real64 const currentTime, real64 &nextDt)
set next time step based on tables intervals
string m_constraintScheduleTableName
Constraint schedule table name.
real64 getConstraintValue(real64 const &currentTime) const
Get the target bottom hole pressure value.
real64 m_rateSign
Rate sign. +1 for injector, -1 for producer.
~WellConstraintBase() override
Default destructor.
virtual void postInputInitialization() override
real64 m_constraintValue
Constraint value.
real64 massRate() const
Getter for the mass rate.
bool isConstraintActive() const
Defines whether the constraint should be evaluated or not.
real64 bottomHolePressure() const
Getter for the bottom hole pressure.
void setConstraintValue(real64 const &constraintValue)
Sets constraint value.
virtual bool checkViolation(WellConstraintBase const &currentConstraint, real64 const &currentTime) const =0
Check if this constraint is violated.
bool m_useScheduleTable
Flag to indicate whether a schedule table should be generated for constraint value;.
WellConstraintBase()=delete
Deleted default constructor.
WellConstraintBase(string const &name, dataRepository::Group *const parent)
Constructor for WellControls Objects.
arrayView1d< real64 const > phaseVolumeRates() const
Getter for the phase volume rates.
WellConstraintBase(WellConstraintBase &&)=delete
Deleted move constructor.
struct geos::WellConstraintBase::viewKeyStruct viewKeysWellConstraint
ViewKey struct for the WellControls class.
real64 liquidRate() const
Getter for the liquid rate.
bool m_isConstraintActive
Constraint status.
TableFunction const * m_constraintScheduleTable
Constraint values versus time.
This class describes the controls used to operate a well.
This class provides the base class/interface for the catalog value objects.
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
Struct to serve as a container for variable strings and keys.
static constexpr char const * constraintScheduleTableNameString()
string key for schedule table name
static constexpr char const * constraintValueString()
String key for the well constraint value.