GEOS
WellPhaseVolumeRateConstraint.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 WellPhaseVolumeRateConstraint.hpp
18  */
19 
20 
21 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLPHASEVOLUMERATECONSTRAINT_HPP
22 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLPHASEVOLUMERATECONSTRAINT_HPP
23 
25 #include "dataRepository/Group.hpp"
27 #include "WellConstraintsBase.hpp"
28 #include "WellConstants.hpp"
29 
30 namespace geos
31 {
32 
33 
34 template< typename T >
35 localIndex getPhaseIndexFromFluidModel( T const & fluidModel, std::string const & inputPhase )
36 {
37  localIndex phaseIndex=-1;
38  // Find target phase index for phase rate constraint
39  for( integer ip = 0; ip < fluidModel.numFluidPhases(); ++ip )
40  {
41  if( fluidModel.phaseNames()[ip] == inputPhase )
42  {
43  phaseIndex = ip;
44  }
45  }
46  return phaseIndex;
47 }
48 
55 {
56 public:
57 
58 
63 
69  explicit PhaseVolumeRateConstraint( string const & name, dataRepository::Group * const parent );
70 
75 
80 
85 
90 
96 
102 
104 
109  static string catalogName()
110  {
111  return "PhaseVolumeRateConstraint";
112  }
113 
118 
119  // Temp interface - tjb
120  virtual ConstraintTypeId getControl() const override { return ConstraintTypeId::PHASEVOLRATE; };
121 
126  const string & getPhaseName() const { return m_phaseName; }
127 
132  void setPhaseName( const string & phaseName ) { m_phaseName = phaseName; }
133 
138  const localIndex & getPhaseIndex() const { return m_phaseIndex; }
139 
144  void setPhaseIndex( const localIndex & phaseIndex ) { m_phaseIndex = phaseIndex; }
146 
148  {
150  static constexpr char const * phaseRateString() { return "phaseRate"; }
152  static constexpr char const * phaseNameString() { return "phaseName"; }
153  };
154 
158  template< typename T > void validatePhaseType( T const & fluidModel );
160 
161  virtual bool checkViolation( WellConstraintBase const & currentConstraint, real64 const & currentTime ) const override;
162 protected:
163 
164  virtual void postInputInitialization() override;
165 
166 private:
167 
169  string m_phaseName;
170 
172  localIndex m_phaseIndex;
173 
174 };
175 
176 template< typename T >
178 {
179  // Find target phase index for phase rate constraint
180  m_phaseIndex = getPhaseIndexFromFluidModel( fluidModel, this->template getReference< string >( viewKeyStruct::phaseNameString()));
181 
182  GEOS_THROW_IF( m_phaseIndex == -1,
183  "PhaseVolumeRateConstraint " << this->template getReference< string >( viewKeyStruct::phaseNameString()) <<
184  ": Invalid phase type for simulation fluid model",
185  InputError );
186 }
187 
188 } //namespace geos
189 
190 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLPHASEVOLUMERATECONSTRAINT_HPP
#define GEOS_THROW_IF(COND, MSG,...)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:308
This class describes a phase rate constraint used to control a well of WellConstraintType type (Injec...
const string & getPhaseName() const
Get the target phase name.
void setPhaseName(const string &phaseName)
Set the target phase name.
static string catalogName()
name of the node manager in the object catalog
PhaseVolumeRateConstraint(PhaseVolumeRateConstraint const &)=delete
Deleted copy constructor.
~PhaseVolumeRateConstraint() override
Default destructor.
PhaseVolumeRateConstraint & operator=(PhaseVolumeRateConstraint const &)=delete
Deleted assignment operator.
PhaseVolumeRateConstraint()=delete
Deleted default constructor.
virtual bool checkViolation(WellConstraintBase const &currentConstraint, real64 const &currentTime) const override
Check if this constraint is violated.
const localIndex & getPhaseIndex() const
Get the target phase index.
PhaseVolumeRateConstraint(string const &name, dataRepository::Group *const parent)
Constructor for WellControls Objects.
PhaseVolumeRateConstraint & operator=(PhaseVolumeRateConstraint &&)=delete
Deleted move operator.
PhaseVolumeRateConstraint(PhaseVolumeRateConstraint &&)=delete
Deleted move constructor.
virtual void postInputInitialization() override
void setPhaseIndex(const localIndex &phaseIndex)
Set the target phase index.
void validatePhaseType(T const &fluidModel)
Validate phase type is consistent with fluidmodel.
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
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Exception class used to report errors in user input.
static constexpr char const * phaseRateString()
String key for the well target phase rate.
static constexpr char const * phaseNameString()
String key for the well target phase name.