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  const localIndex & getPhaseIndex() const { return m_phaseIndex; }
133 
135 
137  {
139  static constexpr char const * phaseRateString() { return "phaseRate"; }
141  static constexpr char const * phaseNameString() { return "phaseName"; }
142  };
143 
147  template< typename T > void validatePhaseType( T const & fluidModel );
149 
150  virtual bool checkViolation( WellConstraintBase const & currentConstraint, real64 const & currentTime ) const override;
151 protected:
152 
153  virtual void postInputInitialization() override;
154 
155 private:
156 
158  string m_phaseName;
159 
161  localIndex m_phaseIndex;
162 
163 };
164 
165 template< typename T >
167 {
168  // Find target phase index for phase rate constraint
169  m_phaseIndex = getPhaseIndexFromFluidModel( fluidModel, this->template getReference< string >( viewKeyStruct::phaseNameString()));
170 
171  GEOS_THROW_IF( m_phaseIndex == -1,
172  "PhaseVolumeRateConstraint " << this->template getReference< string >( viewKeyStruct::phaseNameString()) <<
173  ": Invalid phase type for simulation fluid model",
174  InputError );
175 }
176 
177 } //namespace geos
178 
179 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLPHASEVOLUMERATECONSTRAINT_HPP
#define GEOS_THROW_IF(EXP, msg, TYPE)
Conditionally throw an exception.
Definition: Logger.hpp:151
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.
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 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.
Definition: Logger.hpp:464
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.