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 
32 {
33  USER,
34  WHP,
36 };
37 
38 
40 {
41  BHP,
42  PHASEVOLRATE,
43  TOTALVOLRATE,
44  MASSRATE,
46 };
47 
53 {
54 public:
55  friend class WellControls;
56 
59 
62 
67  virtual string getCatalogName() const = 0;
68 
73 
79  explicit WellConstraintBase( string const & name, dataRepository::Group * const parent );
80 
81 
85  ~WellConstraintBase() override;
86 
90  WellConstraintBase() = delete;
91 
96 
101 
107 
113 
115 
116 
121 
122  // Temp interface - tjb
123  virtual ConstraintTypeId getControl() const = 0;
124 
130 
138  bool isConstraintActive( ) const { return m_isConstraintActive; }
139 
144  void setConstraintActive( bool const & constraintActive ) { m_isConstraintActive=constraintActive; }
145 
150  void setConstraintValue( real64 const & constraintValue )
151  {
152  m_constraintValue = constraintValue;
153  }
154 
159  real64 getConstraintValue( real64 const & currentTime ) const
160  {
161  if( m_constraintScheduleTableName.empty() )
162  {
164  }
165 
166  return m_rateSign*m_constraintScheduleTable->evaluate( &currentTime );
167  }
168 
170 
176  {
178  static constexpr char const * constraintScheduleTableNameString() { return "constraintScheduleTableName"; }
179 
181  static constexpr char const * constraintActiveString() { return "constraintActive"; }
182 
183  }
186 
187  // Quantities computed from well constraint solve with this boundary condition
188  // Until we have a more general interface for constraints to return these quantities,
189  // we will store them in the constraint object itself.
190  // This is not ideal but it is a temporary solution to avoid having to solve the constraint multiple times in the well solver and in the
191  // test.
192  void setBHP( real64 bhp ){ m_BHP=bhp;};
193  void setPhaseVolumeRates( array1d< real64 > const & phaseVolumeRates ) { m_phaseVolumeRates = phaseVolumeRates; };
194  void setTotalVolumeRate( real64 totalVolumeRate ){ m_totalVolumeRate = totalVolumeRate; };
195  void setMassRate( real64 massRate ){ m_massRate = massRate; };
196 
201  real64 bottomHolePressure() const { return m_BHP; }
202 
207  arrayView1d< real64 const > phaseVolumeRates() const { return m_phaseVolumeRates; }
208 
213  real64 totalVolumeRate() const { return m_totalVolumeRate; }
214 
219  real64 liquidRate() const { return m_liquidRate; }
220 
225  real64 massRate() const { return m_massRate; }
226 
227  // endof This needs to be somewhere else tjb
232  virtual bool checkViolation( WellConstraintBase const & currentConstraint, real64 const & currentTime ) const = 0;
233 
234 protected:
235 
236  virtual void postInputInitialization() override;
237 
243  void setNextDtFromTables( real64 const currentTime, real64 & nextDt ) const;
244 
245 
246 protected:
247 
250 
253 
256 
259 
260  static void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
261 
264 
267 
268  // Quantities computed from well constraint solve with this boundary condition
269 
270  // botton hole pressure
271  real64 m_BHP;
272 
273  // phase rates
274  array1d< real64 > m_phaseVolumeRates;
275 
276  // liquid rate
277  real64 m_liquidRate;
278 
279  // total volume rate
280  real64 m_totalVolumeRate;
281 
282  // mass rate
283  real64 m_massRate;
284 
287 };
288 
289 
290 } //namespace geos
291 
292 #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.
integer m_isConstraintActive
Constraint status.
ConstraintSourceId getConstraintSource() const
Provide source of constraint (user defined, or computed from WHP constraint)
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.
real64 totalVolumeRate() const
Getter for the total volume rate.
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 setNextDtFromTables(real64 const currentTime, real64 &nextDt) const
set next time step based on tables intervals
virtual string getCatalogName() const =0
function to return the catalog name of the derived class
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.
void setConstraintActive(bool const &constraintActive)
Sets constraint active status.
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.
TableFunction const * m_constraintScheduleTable
Constraint values versus time.
ConstraintSourceId m_constraintSource
Source of the constraint (user defined, or computed from WHP constraint)
This class describes the controls used to operate a well.
This class provides the base class/interface for the catalog value objects.
stdUnorderedMap< 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 * constraintActiveString()
String key for the well constraint active flag.