diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 278e699bb..df7db5ce2 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1260,4 +1260,15 @@ getCellsForConnections(const Well& well) const return wellCells; } +std::vector +BlackoilWellModelGeneric::getWellsForTesting(const int timeStepIdx, + const double simulationTime) +{ + const auto& wtest_config = schedule()[timeStepIdx].wtest_config(); + if (!wtest_config.empty()) { // there is a WTEST request + return wellTestState().test_wells(wtest_config, simulationTime); + } else + return {}; +} + } diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index ac67b8ccb..0d53ed97b 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -345,6 +345,9 @@ protected: std::vector getCellsForConnections(const Well& well) const; + std::vector getWellsForTesting(const int timeStepIdx, + const double simulationTime); + Schedule& schedule_; const SummaryState& summaryState_; const EclipseState& eclState_; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 4ad608afa..59fbaf4d5 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -24,8 +24,6 @@ #include #include -#include - #include #include @@ -381,30 +379,24 @@ namespace Opm { const double simulationTime, DeferredLogger& deferred_logger) { - const auto& wtest_config = schedule()[timeStepIdx].wtest_config(); - if (!wtest_config.empty()) { // there is a WTEST request - const std::vector wellsForTesting = wellTestState() - .test_wells(wtest_config, simulationTime); - for (const std::string& well_name : wellsForTesting) { + for (const std::string& well_name : this->getWellsForTesting(timeStepIdx, simulationTime)) { + const Well& wellEcl = schedule().getWell(well_name, timeStepIdx); + if (wellEcl.getStatus() == Well::Status::SHUT) + continue; - const Well& wellEcl = schedule().getWell(well_name, timeStepIdx); - if (wellEcl.getStatus() == Well::Status::SHUT) - continue; + WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger); + // some preparation before the well can be used + well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_, true); - WellInterfacePtr well = createWellForWellTest(well_name, timeStepIdx, deferred_logger); - // some preparation before the well can be used - well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_, true); + double well_efficiency_factor = wellEcl.getEfficiencyFactor(); + WellGroupHelpers::accumulateGroupEfficiencyFactor(schedule().getGroup(wellEcl.groupName(), timeStepIdx), + schedule(), timeStepIdx, well_efficiency_factor); - double well_efficiency_factor = wellEcl.getEfficiencyFactor(); - WellGroupHelpers::accumulateGroupEfficiencyFactor(schedule().getGroup(wellEcl.groupName(), timeStepIdx), - schedule(), timeStepIdx, well_efficiency_factor); + well->setWellEfficiencyFactor(well_efficiency_factor); + well->setVFPProperties(vfp_properties_.get()); + well->setGuideRate(&guideRate_); - well->setWellEfficiencyFactor(well_efficiency_factor); - well->setVFPProperties(vfp_properties_.get()); - well->setGuideRate(&guideRate_); - - well->wellTesting(ebosSimulator_, simulationTime, this->wellState(), this->groupState(), wellTestState(), deferred_logger); - } + well->wellTesting(ebosSimulator_, simulationTime, this->wellState(), this->groupState(), wellTestState(), deferred_logger); } }