adding two THP control related fucntions to WellInterface

getTHPConstraint() and getTHPControlIndex();
This commit is contained in:
Kai Bao 2018-11-15 08:57:47 +01:00
parent 01efbc639c
commit eeae6aa4fc
2 changed files with 36 additions and 2 deletions

View File

@ -316,6 +316,10 @@ namespace Opm
bool wellHasTHPConstraints() const;
double getTHPConstraint() const;
int getTHPControlIndex() const;
// Component fractions for each phase for the well
const std::vector<double>& compFrac() const;

View File

@ -364,18 +364,48 @@ namespace Opm
template<typename TypeTag>
bool
WellInterface<TypeTag>::
wellHasTHPConstraints() const
{
return getTHPControlIndex() >= 0;
}
template<typename TypeTag>
double
WellInterface<TypeTag>::
getTHPConstraint() const
{
const int thp_control_index = getTHPControlIndex();
if (thp_control_index < 0) {
OPM_THROW(std::runtime_error, " there is no THP constraint/limit for well " << name()
<< ", while we are requesting it ");
}
return well_controls_iget_target(well_controls_, thp_control_index);
}
template<typename TypeTag>
int
WellInterface<TypeTag>::
getTHPControlIndex() const
{
const int nwc = well_controls_get_num(well_controls_);
for (int ctrl_index = 0; ctrl_index < nwc; ++ctrl_index) {
if (well_controls_iget_type(well_controls_, ctrl_index) == THP) {
return true;
return ctrl_index;
}
}
return false;
return -1;
}