Merge pull request #3060 from joakim-hove/wellpi-extract

Extract method wellPI() from existing lambda implementation
This commit is contained in:
Joakim Hove 2021-02-13 08:55:35 +01:00 committed by GitHub
commit 591826ea4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 32 deletions

View File

@ -267,6 +267,7 @@ namespace Opm {
/// Returns true if the well was actually found and shut.
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
double wellPI(int well_index) const;
protected:
Simulator& ebosSimulator_;

View File

@ -2576,26 +2576,10 @@ namespace Opm {
template<typename TypeTag>
void
double
BlackoilWellModel<TypeTag>::
runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger)
{
if (this->last_run_wellpi_.has_value() && (*this->last_run_wellpi_ == timeStepIdx)) {
// We've already run WELPI scaling for this report step. Most
// common for the very first report step. Don't redo WELPI scaling.
return;
}
auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool
{
return this->schedule()[timeStepIdx]
.wellgroup_events().hasEvent(this->wells_ecl_[well_index].name(),
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
};
auto getWellPI = [this](const int well_index) -> double
wellPI(int well_index) const
{
const auto& pu = this->phase_usage_;
const auto np = this->numPhases();
@ -2624,6 +2608,25 @@ namespace Opm {
std::to_string(static_cast<int>(preferred))
};
}
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger)
{
if (this->last_run_wellpi_.has_value() && (*this->last_run_wellpi_ == timeStepIdx)) {
// We've already run WELPI scaling for this report step. Most
// common for the very first report step. Don't redo WELPI scaling.
return;
}
auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool
{
return this->schedule()[timeStepIdx]
.wellgroup_events().hasEvent(this->wells_ecl_[well_index].name(),
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
};
auto rescaleWellPI =
@ -2663,7 +2666,7 @@ namespace Opm {
const auto nw = this->numLocalWells();
for (auto wellID = 0*nw; wellID < nw; ++wellID) {
if (hasWellPIEvent(wellID)) {
const auto newWellPI = getWellPI(wellID);
const auto newWellPI = this->wellPI(wellID);
rescaleWellPI(wellID, newWellPI);
}
}