diff --git a/opm/autodiff/BlackoilWellModel_impl.hpp b/opm/autodiff/BlackoilWellModel_impl.hpp index 2e4b3b15b..5caadc3e8 100644 --- a/opm/autodiff/BlackoilWellModel_impl.hpp +++ b/opm/autodiff/BlackoilWellModel_impl.hpp @@ -256,7 +256,7 @@ namespace Opm { const double p = fs.pressure(FluidSystem::oilPhaseIdx).value(); cellPressures[cellIdx] = p; } - well_state_.init(wells(), cellPressures, wells_ecl_, timeStepIdx, &previous_well_state_, phase_usage_); + well_state_.init(wells(), cellPressures, schedule(), wells_ecl_, timeStepIdx, &previous_well_state_, phase_usage_); // handling MS well related if (param_.use_multisegment_well_) { // if we use MultisegmentWell model @@ -502,7 +502,7 @@ namespace Opm { if (nw > 0) { const auto phaseUsage = phaseUsageFromDeck(eclState()); const size_t numCells = Opm::UgGridHelpers::numCells(grid()); - well_state_.resize(wells, numCells, phaseUsage); // Resize for restart step + well_state_.resize(wells, schedule(), numCells, phaseUsage); // Resize for restart step wellsToState(restartValues.wells, phaseUsage, well_state_); previous_well_state_ = well_state_; } diff --git a/opm/autodiff/StandardWellV_impl.hpp b/opm/autodiff/StandardWellV_impl.hpp index cb6604dfa..427dd379a 100644 --- a/opm/autodiff/StandardWellV_impl.hpp +++ b/opm/autodiff/StandardWellV_impl.hpp @@ -671,6 +671,7 @@ namespace Opm // Compute Productivity index if asked for const auto& pu = phaseUsage(); const Opm::SummaryConfig& summaryConfig = ebosSimulator.vanguard().summaryConfig(); + const Opm::Schedule& schedule = ebosSimulator.vanguard().schedule(); for (int p = 0; p < np; ++p) { if ( (pu.phase_pos[Water] == p && (summaryConfig.hasSummaryKey("WPIW:" + name()) || summaryConfig.hasSummaryKey("WPIL:" + name()))) || (pu.phase_pos[Oil] == p && (summaryConfig.hasSummaryKey("WPIO:" + name()) || summaryConfig.hasSummaryKey("WPIL:" + name()))) @@ -678,8 +679,9 @@ namespace Opm const unsigned int compIdx = flowPhaseToEbosCompIdx(p); const double drawdown = well_state.perfPress()[first_perf_ + perf] - intQuants.fluidState().pressure(FluidSystem::oilPhaseIdx).value(); + const bool new_well = schedule.hasWellEvent(name(), ScheduleEvents::NEW_WELL, current_step_); double productivity_index = cq_s[compIdx].value() / drawdown; - scaleProductivityIndex(perf, productivity_index, deferred_logger); + scaleProductivityIndex(perf, productivity_index, new_well, deferred_logger); well_state.productivityIndex()[np*index_of_well_ + p] += productivity_index; } } diff --git a/opm/autodiff/StandardWell_impl.hpp b/opm/autodiff/StandardWell_impl.hpp index f9138edfb..60192f3db 100644 --- a/opm/autodiff/StandardWell_impl.hpp +++ b/opm/autodiff/StandardWell_impl.hpp @@ -616,6 +616,7 @@ namespace Opm // Compute Productivity index if asked for const auto& pu = phaseUsage(); const Opm::SummaryConfig& summaryConfig = ebosSimulator.vanguard().summaryConfig(); + const Opm::Schedule& schedule = ebosSimulator.vanguard().schedule(); for (int p = 0; p < np; ++p) { if ( (pu.phase_pos[Water] == p && (summaryConfig.hasSummaryKey("WPIW:" + name()) || summaryConfig.hasSummaryKey("WPIL:" + name()))) || (pu.phase_pos[Oil] == p && (summaryConfig.hasSummaryKey("WPIO:" + name()) || summaryConfig.hasSummaryKey("WPIL:" + name()))) @@ -623,8 +624,9 @@ namespace Opm const unsigned int compIdx = flowPhaseToEbosCompIdx(p); const double drawdown = well_state.perfPress()[first_perf_ + perf] - intQuants.fluidState().pressure(FluidSystem::oilPhaseIdx).value(); + const bool new_well = schedule.hasWellEvent(name(), ScheduleEvents::NEW_WELL, current_step_); double productivity_index = cq_s[compIdx].value() / drawdown; - scaleProductivityIndex(perf, productivity_index, deferred_logger); + scaleProductivityIndex(perf, productivity_index, new_well, deferred_logger); well_state.productivityIndex()[np*index_of_well_ + p] += productivity_index; } } diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index b70572356..a570981aa 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -413,7 +413,7 @@ namespace Opm WellState& well_state, Opm::DeferredLogger& deferred_logger); - void scaleProductivityIndex(const int perfIdx, double& productivity_index, Opm::DeferredLogger& deferred_logger); + void scaleProductivityIndex(const int perfIdx, double& productivity_index, const bool new_well, Opm::DeferredLogger& deferred_logger); // count the number of times an output log message is created in the productivity // index calculations diff --git a/opm/autodiff/WellInterface_impl.hpp b/opm/autodiff/WellInterface_impl.hpp index a1588941a..8b59140b6 100644 --- a/opm/autodiff/WellInterface_impl.hpp +++ b/opm/autodiff/WellInterface_impl.hpp @@ -1262,13 +1262,9 @@ namespace Opm template void - WellInterface::scaleProductivityIndex(const int perfIdx, double& productivity_index, Opm::DeferredLogger& deferred_logger) + WellInterface::scaleProductivityIndex(const int perfIdx, double& productivity_index, const bool new_well, Opm::DeferredLogger& deferred_logger) { - const auto& connection = well_ecl_->getConnections(current_step_)[perfIdx]; - - const bool new_well = well_ecl_->hasEvent(ScheduleEvents::NEW_WELL , current_step_); - if (well_ecl_->getDrainageRadius(current_step_) < 0) { if (new_well && perfIdx == 0) { deferred_logger.warning("PRODUCTIVITY_INDEX_WARNING", "Negative drainage radius not supported. The productivity index is set to zero"); diff --git a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp index 770f25a35..c68cbbd12 100644 --- a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp +++ b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp @@ -63,6 +63,7 @@ namespace Opm /// to give useful initial values to the bhp(), wellRates() /// and perfPhaseRates() fields, depending on controls void init(const Wells* wells, const std::vector& cellPressures, + const Schedule& schedule, const std::vector& wells_ecl, const int report_step, const WellStateFullyImplicitBlackoil* prevState, const PhaseUsage& pu) { @@ -114,8 +115,7 @@ namespace Opm OPM_THROW(std::logic_error, "Could not find well " << well_name << " in wells_ecl "); } - const Well* well_ecl = wells_ecl[index_well_ecl]; - effective_events_occurred_[w] = (well_ecl->hasEvent(effective_events_mask, report_step) ); + effective_events_occurred_[w] = (schedule.hasWellEvent(well_name, effective_events_mask, report_step) ); } } // end of if (!well_ecl.empty() ) @@ -285,11 +285,11 @@ namespace Opm } } - void resize(const Wells* wells, size_t numCells, const PhaseUsage& pu) + void resize(const Wells* wells, const Schedule& schedule, std::size_t numCells, const PhaseUsage& pu) { const std::vector tmp(numCells, 0.0); // <- UGLY HACK to pass the size const std::vector wells_ecl; - init(wells, tmp, wells_ecl, 0, nullptr, pu); + init(wells, tmp, schedule, wells_ecl, 0, nullptr, pu); } /// Allocate and initialize if wells is non-null. Also tries