diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 3c75712aa..0b9f05555 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -357,6 +357,8 @@ namespace Opm { // used to better efficiency of calcuation mutable BVector scaleAddRes_; + std::vector< Scalar > B_avg_; + const Grid& grid() const { return ebosSimulator_.vanguard().grid(); } @@ -409,7 +411,7 @@ namespace Opm { void setRepRadiusPerfLength(); - void computeAverageFormationFactor(std::vector& B_avg) const; + void updateAverageFormationFactor(); // Calculating well potentials for each well void computeWellPotentials(std::vector& well_potentials, const int reportStepIdx, Opm::DeferredLogger& deferred_logger); @@ -438,7 +440,7 @@ namespace Opm { int reportStepIndex() const; - void assembleWellEq(const std::vector& B_avg, const double dt, Opm::DeferredLogger& deferred_logger); + void assembleWellEq(const double dt, Opm::DeferredLogger& deferred_logger); // some preparation work, mostly related to group control and RESV, // at the beginning of each time step (Not report step) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 9275ce0f3..b1fb0f00b 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -301,6 +301,7 @@ namespace Opm { beginTimeStep() { updatePerforationIntensiveQuantities(); + updateAverageFormationFactor(); Opm::DeferredLogger local_deferredLogger; @@ -321,11 +322,8 @@ namespace Opm { // do the initialization for all the wells // TODO: to see whether we can postpone of the intialization of the well containers to // optimize the usage of the following several member variables - std::vector< Scalar > B_avg(numComponents(), Scalar() ); - computeAverageFormationFactor(B_avg); - for (auto& well : well_container_) { - well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg); + well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_); } // update the updated cell flag @@ -462,13 +460,6 @@ namespace Opm { { const auto& wtest_config = schedule()[timeStepIdx].wtest_config(); if (wtest_config.size() != 0) { // there is a WTEST request - - // average B factors are required for the convergence checking of well equations - // Note: this must be done on all processes, even those with - // no wells needing testing, otherwise we will have locking. - std::vector< Scalar > B_avg(numComponents(), Scalar()); - computeAverageFormationFactor(B_avg); - const auto wellsForTesting = wellTestState_ .updateWells(wtest_config, wells_ecl_, simulationTime); @@ -479,8 +470,7 @@ namespace Opm { 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); - + well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_); const Well& wellEcl = schedule().getWell(well_name, timeStepIdx); double well_efficiency_factor = wellEcl.getEfficiencyFactor(); WellGroupHelpers::accumulateGroupEfficiencyFactor(schedule().getGroup(wellEcl.groupName(), timeStepIdx), @@ -492,7 +482,7 @@ namespace Opm { const WellTestConfig::Reason testing_reason = testWell.second; - well->wellTesting(ebosSimulator_, B_avg, simulationTime, timeStepIdx, + well->wellTesting(ebosSimulator_, simulationTime, timeStepIdx, testing_reason, well_state_, wellTestState_, deferred_logger); } } @@ -1029,9 +1019,6 @@ namespace Opm { // Set the well primary variables based on the value of well solutions initPrimaryVariablesEvaluation(); - std::vector< Scalar > B_avg(numComponents(), Scalar() ); - computeAverageFormationFactor(B_avg); - if (param_.solve_welleq_initially_ && iterationIdx == 0) { for (auto& well : well_container_) { well->solveWellEquation(ebosSimulator_, well_state_, local_deferredLogger); @@ -1041,7 +1028,7 @@ namespace Opm { gliftDebug("assemble() : running assembleWellEq()..", local_deferredLogger); well_state_.enableGliftOptimization(); - assembleWellEq(B_avg, dt, local_deferredLogger); + assembleWellEq(dt, local_deferredLogger); well_state_.disableGliftOptimization(); } catch (const std::runtime_error& e) { exc_type = ExceptionType::RUNTIME_ERROR; @@ -1056,7 +1043,6 @@ namespace Opm { exc_type = ExceptionType::DEFAULT; exc_msg = e.what(); } - logAndCheckForExceptionsAndThrow(local_deferredLogger, exc_type, "assemble() failed: " + exc_msg, terminal_output_); last_report_.converged = true; last_report_.assemble_time_well += perfTimer.stop(); @@ -1065,12 +1051,12 @@ namespace Opm { template void BlackoilWellModel:: - assembleWellEq(const std::vector& B_avg, const double dt, Opm::DeferredLogger& deferred_logger) + assembleWellEq(const double dt, Opm::DeferredLogger& deferred_logger) { for (auto& well : well_container_) { well->maybeDoGasLiftOptimization( well_state_, ebosSimulator_, deferred_logger); - well->assembleWellEq(ebosSimulator_, B_avg, dt, well_state_, deferred_logger); + well->assembleWellEq(ebosSimulator_, dt, well_state_, deferred_logger); } } @@ -1491,12 +1477,6 @@ namespace Opm { auto well_state_copy = well_state_; - // average B factors are required for the convergence checking of well equations - // Note: this must be done on all processes, even those with - // no wells needing testing, otherwise we will have locking. - std::vector< Scalar > B_avg(numComponents(), Scalar() ); - computeAverageFormationFactor(B_avg); - const Opm::SummaryConfig& summaryConfig = ebosSimulator_.vanguard().summaryConfig(); const bool write_restart_file = ebosSimulator_.vanguard().schedule().write_rst_file(reportStepIdx); auto exc_type = ExceptionType::NONE; @@ -1514,7 +1494,7 @@ namespace Opm { { try { std::vector potentials; - well->computeWellPotentials(ebosSimulator_, B_avg, well_state_copy, potentials, deferred_logger); + well->computeWellPotentials(ebosSimulator_, well_state_copy, potentials, deferred_logger); // putting the sucessfully calculated potentials to the well_potentials for (int p = 0; p < np; ++p) { well_potentials[well->indexOfWell() * np + p] = std::abs(potentials[p]); @@ -1693,8 +1673,9 @@ namespace Opm { template void BlackoilWellModel:: - computeAverageFormationFactor(std::vector& B_avg) const + updateAverageFormationFactor() { + std::vector< Scalar > B_avg(numComponents(), Scalar() ); const auto& grid = ebosSimulator_.vanguard().grid(); const auto& gridView = grid.leafGridView(); ElementContext elemCtx(ebosSimulator_); @@ -1732,6 +1713,7 @@ namespace Opm { { bval/=global_num_cells_; } + B_avg_ = B_avg; } @@ -2811,11 +2793,8 @@ namespace Opm { this->previous_well_state_ = this->well_state_; well_container_ = createWellContainer(timeStepIdx); - std::vector< Scalar > B_avg(numComponents(), Scalar() ); - // we don't plan to iterate so just passing trivial B_avg - // for now for (auto& well : well_container_) { - well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg); + well->init(&phase_usage_, depth_, gravity_, local_num_cells_, B_avg_); } std::fill(is_cell_perforated_.begin(), is_cell_perforated_.end(), false); diff --git a/opm/simulators/wells/MultisegmentWell.hpp b/opm/simulators/wells/MultisegmentWell.hpp index 49a5fd105..8e192ffe5 100644 --- a/opm/simulators/wells/MultisegmentWell.hpp +++ b/opm/simulators/wells/MultisegmentWell.hpp @@ -129,7 +129,6 @@ namespace Opm } virtual void assembleWellEq(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) override; @@ -160,7 +159,6 @@ namespace Opm /// computing the well potentials for group control virtual void computeWellPotentials(const Simulator& ebosSimulator, - const std::vector& B_avg, const WellState& well_state, std::vector& well_potentials, Opm::DeferredLogger& deferred_logger) override; @@ -402,19 +400,16 @@ namespace Opm std::vector& mob) const; void computeWellRatesAtBhpLimit(const Simulator& ebosSimulator, - const std::vector& B_avg, std::vector& well_flux, Opm::DeferredLogger& deferred_logger) const; void computeWellRatesWithBhp(const Simulator& ebosSimulator, - const std::vector& B_avg, const Scalar bhp, std::vector& well_flux, Opm::DeferredLogger& deferred_logger) const; std::vector computeWellPotentialWithTHP(const Simulator& ebos_simulator, - const std::vector& B_avg, Opm::DeferredLogger& deferred_logger) const; void assembleControlEq(const WellState& well_state, @@ -447,7 +442,6 @@ namespace Opm bool accelerationalPressureLossConsidered() const; virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, const Well::InjectionControls& inj_controls, const Well::ProductionControls& prod_controls, @@ -496,12 +490,10 @@ namespace Opm std::optional computeBhpAtThpLimitProd(const Simulator& ebos_simulator, - const std::vector& B_avg, const SummaryState& summary_state, DeferredLogger& deferred_logger) const; std::optional computeBhpAtThpLimitInj(const Simulator& ebos_simulator, - const std::vector& B_avg, const SummaryState& summary_state, DeferredLogger& deferred_logger) const; diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 25b346380..2fdd0bfad 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -261,7 +261,6 @@ namespace Opm void MultisegmentWell:: assembleWellEq(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) @@ -271,7 +270,7 @@ namespace Opm const bool use_inner_iterations = param_.use_inner_iterations_ms_wells_; if (use_inner_iterations) { - this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger); + this->iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger); } const auto& summary_state = ebosSimulator.vanguard().summaryState(); @@ -779,7 +778,6 @@ namespace Opm void MultisegmentWell:: computeWellPotentials(const Simulator& ebosSimulator, - const std::vector& B_avg, const WellState& well_state, std::vector& well_potentials, Opm::DeferredLogger& deferred_logger) @@ -819,9 +817,9 @@ namespace Opm const auto& summaryState = ebosSimulator.vanguard().summaryState(); const Well::ProducerCMode& current_control = well_state.currentProductionControls()[this->index_of_well_]; if ( !Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP) { - computeWellRatesAtBhpLimit(ebosSimulator, B_avg, well_potentials, deferred_logger); + computeWellRatesAtBhpLimit(ebosSimulator, well_potentials, deferred_logger); } else { - well_potentials = computeWellPotentialWithTHP(ebosSimulator, B_avg, deferred_logger); + well_potentials = computeWellPotentialWithTHP(ebosSimulator, deferred_logger); } deferred_logger.debug("Cost in iterations of finding well potential for well " + name() + ": " + std::to_string(debug_cost_counter_)); @@ -834,16 +832,15 @@ namespace Opm void MultisegmentWell:: computeWellRatesAtBhpLimit(const Simulator& ebosSimulator, - const std::vector& B_avg, std::vector& well_flux, Opm::DeferredLogger& deferred_logger) const { if (well_ecl_.isInjector()) { const auto controls = well_ecl_.injectionControls(ebosSimulator.vanguard().summaryState()); - computeWellRatesWithBhp(ebosSimulator, B_avg, controls.bhp_limit, well_flux, deferred_logger); + computeWellRatesWithBhp(ebosSimulator, controls.bhp_limit, well_flux, deferred_logger); } else { const auto controls = well_ecl_.productionControls(ebosSimulator.vanguard().summaryState()); - computeWellRatesWithBhp(ebosSimulator, B_avg, controls.bhp_limit, well_flux, deferred_logger); + computeWellRatesWithBhp(ebosSimulator, controls.bhp_limit, well_flux, deferred_logger); } } @@ -853,7 +850,6 @@ namespace Opm void MultisegmentWell:: computeWellRatesWithBhp(const Simulator& ebosSimulator, - const std::vector& B_avg, const Scalar bhp, std::vector& well_flux, Opm::DeferredLogger& deferred_logger) const @@ -898,7 +894,7 @@ namespace Opm well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger); const double dt = ebosSimulator.timeStepSize(); // iterate to get a solution at the given bhp. - well_copy.iterateWellEqWithControl(ebosSimulator, B_avg, dt, inj_controls, prod_controls, well_state_copy, + well_copy.iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state_copy, deferred_logger); // compute the potential and store in the flux vector. @@ -917,7 +913,6 @@ namespace Opm std::vector MultisegmentWell:: computeWellPotentialWithTHP(const Simulator& ebos_simulator, - const std::vector& B_avg, Opm::DeferredLogger& deferred_logger) const { std::vector potentials(number_of_phases_, 0.0); @@ -925,11 +920,11 @@ namespace Opm const auto& well = well_ecl_; if (well.isInjector()){ - auto bhp_at_thp_limit = computeBhpAtThpLimitInj(ebos_simulator, B_avg, summary_state, deferred_logger); + auto bhp_at_thp_limit = computeBhpAtThpLimitInj(ebos_simulator, summary_state, deferred_logger); if (bhp_at_thp_limit) { const auto& controls = well_ecl_.injectionControls(summary_state); const double bhp = std::min(*bhp_at_thp_limit, controls.bhp_limit); - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger); deferred_logger.debug("Converged thp based potential calculation for well " + name() + ", at bhp = " + std::to_string(bhp)); } else { @@ -938,14 +933,14 @@ namespace Opm + name() + ". Instead the bhp based value is used"); const auto& controls = well_ecl_.injectionControls(summary_state); const double bhp = controls.bhp_limit; - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger); } } else { - auto bhp_at_thp_limit = computeBhpAtThpLimitProd(ebos_simulator, B_avg, summary_state, deferred_logger); + auto bhp_at_thp_limit = computeBhpAtThpLimitProd(ebos_simulator, summary_state, deferred_logger); if (bhp_at_thp_limit) { const auto& controls = well_ecl_.productionControls(summary_state); const double bhp = std::max(*bhp_at_thp_limit, controls.bhp_limit); - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger); deferred_logger.debug("Converged thp based potential calculation for well " + name() + ", at bhp = " + std::to_string(bhp)); } else { @@ -954,7 +949,7 @@ namespace Opm + name() + ". Instead the bhp based value is used"); const auto& controls = well_ecl_.productionControls(summary_state); const double bhp = controls.bhp_limit; - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, potentials, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, potentials, deferred_logger); } } @@ -2447,7 +2442,7 @@ namespace Opm // option 2: stick with the above IPR curve // we use IPR here std::vector well_rates_bhp_limit; - computeWellRatesWithBhp(ebos_simulator, Base::B_avg_, bhp_limit, well_rates_bhp_limit, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp_limit, well_rates_bhp_limit, deferred_logger); const double thp = calculateThpFromBhp(well_rates_bhp_limit, bhp_limit, deferred_logger); @@ -2586,7 +2581,7 @@ namespace Opm checkOperabilityUnderTHPLimitProducer(const Simulator& ebos_simulator, const WellState& /*well_state*/, Opm::DeferredLogger& deferred_logger) { const auto& summaryState = ebos_simulator.vanguard().summaryState(); - const auto obtain_bhp = computeBhpAtThpLimitProd(ebos_simulator, Base::B_avg_, summaryState, deferred_logger); + const auto obtain_bhp = computeBhpAtThpLimitProd(ebos_simulator, summaryState, deferred_logger); if (obtain_bhp) { this->operability_status_.can_obtain_bhp_with_thp_limit = true; @@ -2709,7 +2704,6 @@ namespace Opm bool MultisegmentWell:: iterateWellEqWithControl(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, const Well::InjectionControls& inj_controls, const Well::ProductionControls& prod_controls, @@ -2720,7 +2714,7 @@ namespace Opm const int max_iter_number = param_.max_inner_iter_ms_wells_; const WellState well_state0 = well_state; - const std::vector residuals0 = getWellResiduals(B_avg, deferred_logger); + const std::vector residuals0 = getWellResiduals(Base::B_avg_, deferred_logger); std::vector > residual_history; std::vector measure_history; int it = 0; @@ -2739,13 +2733,13 @@ namespace Opm if (it > param_.strict_inner_iter_ms_wells_) relax_convergence = true; - const auto report = getWellConvergence(well_state, B_avg, deferred_logger, relax_convergence); + const auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger, relax_convergence); if (report.converged()) { converged = true; break; } - residual_history.push_back(getWellResiduals(B_avg, deferred_logger)); + residual_history.push_back(getWellResiduals(Base::B_avg_, deferred_logger)); measure_history.push_back(getResidualMeasureValue(well_state, residual_history[it], deferred_logger) ); bool is_oscillate = false; @@ -2763,7 +2757,7 @@ namespace Opm ++stagnate_count; if (stagnate_count == 6) { sstr << " well " << name() << " observes severe stagnation and/or oscillation. We relax the tolerance and check for convergence. \n"; - const auto reportStag = getWellConvergence(well_state, B_avg, deferred_logger, true); + const auto reportStag = getWellConvergence(well_state, Base::B_avg_, deferred_logger, true); if (reportStag.converged()) { converged = true; sstr << " well " << name() << " manages to get converged with relaxed tolerances in " << it << " inner iterations"; @@ -3578,7 +3572,6 @@ namespace Opm std::optional MultisegmentWell:: computeBhpAtThpLimitProd(const Simulator& ebos_simulator, - const std::vector& B_avg, const SummaryState& summary_state, DeferredLogger& deferred_logger) const { @@ -3617,14 +3610,14 @@ namespace Opm }; // Make the frates() function. - auto frates = [this, &ebos_simulator, &B_avg, &deferred_logger](const double bhp) { + auto frates = [this, &ebos_simulator, &deferred_logger](const double bhp) { // Not solving the well equations here, which means we are // calculating at the current Fg/Fw values of the // well. This does not matter unless the well is // crossflowing, and then it is likely still a good // approximation. std::vector rates(3); - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, rates, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, rates, deferred_logger); return rates; }; @@ -3778,7 +3771,6 @@ namespace Opm std::optional MultisegmentWell:: computeBhpAtThpLimitInj(const Simulator& ebos_simulator, - const std::vector& B_avg, const SummaryState& summary_state, DeferredLogger& deferred_logger) const { @@ -3840,14 +3832,14 @@ namespace Opm }; // Make the frates() function. - auto frates = [this, &ebos_simulator, &B_avg, &deferred_logger](const double bhp) { + auto frates = [this, &ebos_simulator, &deferred_logger](const double bhp) { // Not solving the well equations here, which means we are // calculating at the current Fg/Fw values of the // well. This does not matter unless the well is // crossflowing, and then it is likely still a good // approximation. std::vector rates(3); - computeWellRatesWithBhp(ebos_simulator, B_avg, bhp, rates, deferred_logger); + computeWellRatesWithBhp(ebos_simulator, bhp, rates, deferred_logger); return rates; }; diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index fc44ec4ea..daba8d98f 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -176,7 +176,6 @@ namespace Opm virtual void initPrimaryVariablesEvaluation() const override; virtual void assembleWellEq(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) override; @@ -212,7 +211,6 @@ namespace Opm /// computing the well potentials for group control virtual void computeWellPotentials(const Simulator& ebosSimulator, - const std::vector& B_avg, const WellState& well_state, std::vector& well_potentials, Opm::DeferredLogger& deferred_logger) /* const */ override; @@ -234,7 +232,6 @@ namespace Opm // iterate well equations with the specified control until converged bool iterateWellEqWithControl(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, const Well::InjectionControls& inj_controls, const Well::ProductionControls& prod_controls, @@ -469,7 +466,6 @@ namespace Opm Opm::DeferredLogger& deferred_logger) const; void computeWellRatesWithBhpPotential(const Simulator& ebosSimulator, - const std::vector& B_avg, const double& bhp, std::vector& well_flux, Opm::DeferredLogger& deferred_logger); diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index ad27bf12b..1b6e5d605 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -542,7 +542,6 @@ namespace Opm void StandardWell:: assembleWellEq(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) @@ -551,7 +550,7 @@ namespace Opm const bool use_inner_iterations = param_.use_inner_iterations_wells_; if (use_inner_iterations) { - this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger); + this->iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger); } // TODO: inj_controls and prod_controls are not used in the following function for now @@ -2598,7 +2597,6 @@ namespace Opm void StandardWell:: computeWellRatesWithBhpPotential(const Simulator& ebosSimulator, - const std::vector& B_avg, const double& bhp, std::vector& well_flux, Opm::DeferredLogger& deferred_logger) @@ -2618,7 +2616,7 @@ namespace Opm well_state_copy.bhp()[index_of_well_] = bhp; const double dt = ebosSimulator.timeStepSize(); - bool converged = this->iterateWellEquations(ebosSimulator, B_avg, dt, well_state_copy, deferred_logger); + bool converged = this->iterateWellEquations(ebosSimulator, dt, well_state_copy, deferred_logger); if (!converged) { const std::string msg = " well " + name() + " did not get converged during well potential calculations " "returning zero values for the potential"; @@ -2852,7 +2850,6 @@ namespace Opm void StandardWell:: computeWellPotentials(const Simulator& ebosSimulator, - const std::vector& B_avg, const WellState& well_state, std::vector& well_potentials, Opm::DeferredLogger& deferred_logger) // const @@ -2876,7 +2873,7 @@ namespace Opm // get the bhp value based on the bhp constraints const double bhp = well.mostStrictBhpFromBhpLimits(summaryState); assert(std::abs(bhp) != std::numeric_limits::max()); - well.computeWellRatesWithBhpPotential(ebosSimulator, B_avg, bhp, well_potentials, deferred_logger); + well.computeWellRatesWithBhpPotential(ebosSimulator, bhp, well_potentials, deferred_logger); } else { // the well has a THP related constraint well_potentials = well.computeWellPotentialWithTHP(ebosSimulator, deferred_logger, well_state); @@ -4077,7 +4074,6 @@ namespace Opm bool StandardWell:: iterateWellEqWithControl(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, const Well::InjectionControls& inj_controls, const Well::ProductionControls& prod_controls, @@ -4090,7 +4086,7 @@ namespace Opm do { assembleWellEqWithoutIteration(ebosSimulator, dt, inj_controls, prod_controls, well_state, deferred_logger); - auto report = getWellConvergence(well_state, B_avg, deferred_logger); + auto report = getWellConvergence(well_state, Base::B_avg_, deferred_logger); converged = report.converged(); if (converged) { diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index 773dfbe9d..2b10944f0 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -169,7 +169,6 @@ namespace Opm virtual void solveEqAndUpdateWellState(WellState& well_state, Opm::DeferredLogger& deferred_logger) = 0; virtual void assembleWellEq(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger @@ -205,7 +204,6 @@ namespace Opm // TODO: before we decide to put more information under mutable, this function is not const virtual void computeWellPotentials(const Simulator& ebosSimulator, - const std::vector& B_avg, const WellState& well_state, std::vector& well_potentials, Opm::DeferredLogger& deferred_logger) = 0; @@ -265,7 +263,7 @@ namespace Opm // TODO: theoretically, it should be a const function // Simulator is not const is because that assembleWellEq is non-const Simulator - void wellTesting(const Simulator& simulator, const std::vector& B_avg, + void wellTesting(const Simulator& simulator, const double simulation_time, const int report_step, const WellTestConfig::Reason testing_reason, /* const */ WellState& well_state, WellTestState& welltest_state, @@ -513,11 +511,11 @@ namespace Opm virtual void updateIPR(const Simulator& ebos_simulator, Opm::DeferredLogger& deferred_logger) const=0; - void wellTestingEconomic(const Simulator& simulator, const std::vector& B_avg, + void wellTestingEconomic(const Simulator& simulator, const double simulation_time, const WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger); - void wellTestingPhysical(const Simulator& simulator, const std::vector& B_avg, + void wellTestingPhysical(const Simulator& simulator, const double simulation_time, const int report_step, WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger); @@ -531,7 +529,6 @@ namespace Opm // iterate well equations with the specified control until converged virtual bool iterateWellEqWithControl(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, const Well::InjectionControls& inj_controls, const Well::ProductionControls& prod_controls, @@ -539,7 +536,6 @@ namespace Opm Opm::DeferredLogger& deferred_logger) = 0; bool iterateWellEquations(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger); @@ -557,7 +553,6 @@ namespace Opm Opm::DeferredLogger& deferred_logger) const; void solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state, - const std::vector& B_avg, Opm::DeferredLogger& deferred_logger); void initCompletions(); diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index da40b542f..b9b70001e 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1109,7 +1109,7 @@ namespace Opm template void WellInterface:: - wellTesting(const Simulator& simulator, const std::vector& B_avg, + wellTesting(const Simulator& simulator, const double simulation_time, const int report_step, const WellTestConfig::Reason testing_reason, /* const */ WellState& well_state, @@ -1117,12 +1117,12 @@ namespace Opm Opm::DeferredLogger& deferred_logger) { if (testing_reason == WellTestConfig::Reason::PHYSICAL) { - wellTestingPhysical(simulator, B_avg, simulation_time, report_step, + wellTestingPhysical(simulator, simulation_time, report_step, well_state, well_test_state, deferred_logger); } if (testing_reason == WellTestConfig::Reason::ECONOMIC) { - wellTestingEconomic(simulator, B_avg, simulation_time, + wellTestingEconomic(simulator, simulation_time, well_state, well_test_state, deferred_logger); } } @@ -1134,7 +1134,7 @@ namespace Opm template void WellInterface:: - wellTestingEconomic(const Simulator& simulator, const std::vector& B_avg, + wellTestingEconomic(const Simulator& simulator, const double simulation_time, const WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger) { @@ -1155,7 +1155,7 @@ namespace Opm // untill the number of closed completions do not increase anymore. while (testWell) { const size_t original_number_closed_completions = welltest_state_temp.sizeCompletions(); - solveWellForTesting(simulator, well_state_copy, B_avg, deferred_logger); + solveWellForTesting(simulator, well_state_copy, deferred_logger); updateWellTestState(well_state_copy, simulation_time, /*writeMessageToOPMLog=*/ false, welltest_state_temp, deferred_logger); closeCompletions(welltest_state_temp); @@ -1297,7 +1297,6 @@ namespace Opm bool WellInterface:: iterateWellEquations(const Simulator& ebosSimulator, - const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) @@ -1306,7 +1305,7 @@ namespace Opm const auto inj_controls = well_ecl_.isInjector() ? well_ecl_.injectionControls(summary_state) : Well::InjectionControls(0); const auto prod_controls = well_ecl_.isProducer() ? well_ecl_.productionControls(summary_state) : Well::ProductionControls(0); - return this->iterateWellEqWithControl(ebosSimulator, B_avg, dt, inj_controls, prod_controls, well_state, deferred_logger); + return this->iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state, deferred_logger); } @@ -1354,13 +1353,12 @@ namespace Opm void WellInterface:: solveWellForTesting(const Simulator& ebosSimulator, WellState& well_state, - const std::vector& B_avg, Opm::DeferredLogger& deferred_logger) { // keep a copy of the original well state const WellState well_state0 = well_state; const double dt = ebosSimulator.timeStepSize(); - const bool converged = iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger); + const bool converged = iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger); if (converged) { deferred_logger.debug("WellTest: Well equation for well " + name() + " converged"); } else { @@ -1384,7 +1382,7 @@ namespace Opm // keep a copy of the original well state const WellState well_state0 = well_state; const double dt = ebosSimulator.timeStepSize(); - const bool converged = iterateWellEquations(ebosSimulator, B_avg_, dt, well_state, deferred_logger); + const bool converged = iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger); if (converged) { deferred_logger.debug("Compute initial well solution for well " + name() + ". Converged"); } else { @@ -1427,7 +1425,7 @@ namespace Opm template void WellInterface:: - wellTestingPhysical(const Simulator& ebos_simulator, const std::vector& B_avg, + wellTestingPhysical(const Simulator& ebos_simulator, const double /* simulation_time */, const int /* report_step */, WellState& well_state, WellTestState& welltest_state, Opm::DeferredLogger& deferred_logger) @@ -1464,7 +1462,7 @@ namespace Opm calculateExplicitQuantities(ebos_simulator, well_state_copy, deferred_logger); const double dt = ebos_simulator.timeStepSize(); - const bool converged = this->iterateWellEquations(ebos_simulator, B_avg, dt, well_state_copy, deferred_logger); + const bool converged = this->iterateWellEquations(ebos_simulator, dt, well_state_copy, deferred_logger); if (!converged) { const std::string msg = " well " + name() + " did not get converged during well testing for physical reason";