mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3060 from joakim-hove/wellpi-extract
Extract method wellPI() from existing lambda implementation
This commit is contained in:
commit
591826ea4e
@ -267,6 +267,7 @@ namespace Opm {
|
|||||||
/// Returns true if the well was actually found and shut.
|
/// Returns true if the well was actually found and shut.
|
||||||
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
|
||||||
|
|
||||||
|
double wellPI(int well_index) const;
|
||||||
protected:
|
protected:
|
||||||
Simulator& ebosSimulator_;
|
Simulator& ebosSimulator_;
|
||||||
|
|
||||||
|
@ -2576,6 +2576,40 @@ namespace Opm {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<typename TypeTag>
|
||||||
|
double
|
||||||
|
BlackoilWellModel<TypeTag>::
|
||||||
|
wellPI(int well_index) const
|
||||||
|
{
|
||||||
|
const auto& pu = this->phase_usage_;
|
||||||
|
const auto np = this->numPhases();
|
||||||
|
const auto* pi = &this->well_state_.productivityIndex()[np*well_index + 0];
|
||||||
|
|
||||||
|
const auto preferred = this->wells_ecl_[well_index].getPreferredPhase();
|
||||||
|
switch (preferred) { // Should really have LIQUID = OIL + WATER here too...
|
||||||
|
case Phase::WATER:
|
||||||
|
return pu.phase_used[BlackoilPhases::PhaseIndex::Aqua]
|
||||||
|
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Aqua]]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
case Phase::OIL:
|
||||||
|
return pu.phase_used[BlackoilPhases::PhaseIndex::Liquid]
|
||||||
|
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Liquid]]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
case Phase::GAS:
|
||||||
|
return pu.phase_used[BlackoilPhases::PhaseIndex::Vapour]
|
||||||
|
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Vapour]]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::invalid_argument {
|
||||||
|
"Unsupported preferred phase " +
|
||||||
|
std::to_string(static_cast<int>(preferred))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
@ -2595,37 +2629,6 @@ namespace Opm {
|
|||||||
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
|
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto getWellPI = [this](const int well_index) -> double
|
|
||||||
{
|
|
||||||
const auto& pu = this->phase_usage_;
|
|
||||||
const auto np = this->numPhases();
|
|
||||||
const auto* pi = &this->well_state_.productivityIndex()[np*well_index + 0];
|
|
||||||
|
|
||||||
const auto preferred = this->wells_ecl_[well_index].getPreferredPhase();
|
|
||||||
switch (preferred) { // Should really have LIQUID = OIL + WATER here too...
|
|
||||||
case Phase::WATER:
|
|
||||||
return pu.phase_used[BlackoilPhases::PhaseIndex::Aqua]
|
|
||||||
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Aqua]]
|
|
||||||
: 0.0;
|
|
||||||
|
|
||||||
case Phase::OIL:
|
|
||||||
return pu.phase_used[BlackoilPhases::PhaseIndex::Liquid]
|
|
||||||
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Liquid]]
|
|
||||||
: 0.0;
|
|
||||||
|
|
||||||
case Phase::GAS:
|
|
||||||
return pu.phase_used[BlackoilPhases::PhaseIndex::Vapour]
|
|
||||||
? pi[pu.phase_pos[BlackoilPhases::PhaseIndex::Vapour]]
|
|
||||||
: 0.0;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::invalid_argument {
|
|
||||||
"Unsupported preferred phase " +
|
|
||||||
std::to_string(static_cast<int>(preferred))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
auto rescaleWellPI =
|
auto rescaleWellPI =
|
||||||
[this, timeStepIdx](const int well_index,
|
[this, timeStepIdx](const int well_index,
|
||||||
const double newWellPI) -> void
|
const double newWellPI) -> void
|
||||||
@ -2663,7 +2666,7 @@ namespace Opm {
|
|||||||
const auto nw = this->numLocalWells();
|
const auto nw = this->numLocalWells();
|
||||||
for (auto wellID = 0*nw; wellID < nw; ++wellID) {
|
for (auto wellID = 0*nw; wellID < nw; ++wellID) {
|
||||||
if (hasWellPIEvent(wellID)) {
|
if (hasWellPIEvent(wellID)) {
|
||||||
const auto newWellPI = getWellPI(wellID);
|
const auto newWellPI = this->wellPI(wellID);
|
||||||
rescaleWellPI(wellID, newWellPI);
|
rescaleWellPI(wellID, newWellPI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user