diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index ab0dae88e..522196969 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -199,8 +199,6 @@ public: desiredRestoreStep ); } - bool is_well_potentials_computed = param_.getDefault("compute_well_potentials", false ); - std::vector well_potentials; DynamicListEconLimited dynamic_list_econ_limited; SimulatorReport report; SimulatorReport stepReport; @@ -229,6 +227,9 @@ public: OpmLog::note(ss.str()); } + // TODO: not used at all, keeping it for interface purpose. + + std::vector well_potentials; // Create wells and well state. WellsManager wells_manager(eclState(), timer.currentStepNum(), @@ -395,11 +396,6 @@ public: report.output_write_time += perfTimer.stop(); prev_well_state = well_state; - // The well potentials are only computed if they are needed - // For now thay are only used to determine default guide rates for group controlled wells - if ( is_well_potentials_computed ) { - computeWellPotentials(wells, well_state, well_potentials); - } updateListEconLimited(solver, eclState().getSchedule(), timer.currentStepNum(), wells, well_state, dynamic_list_econ_limited); @@ -605,23 +601,6 @@ protected: } - void computeWellPotentials(const Wells* wells, - const WellState& xw, - std::vector& well_potentials) - { - const int nw = wells->number_of_wells; - const int np = wells->number_of_phases; - well_potentials.clear(); - well_potentials.resize(nw*np,0.0); - for (int w = 0; w < nw; ++w) { - for (int perf = wells->well_connpos[w]; perf < wells->well_connpos[w + 1]; ++perf) { - for (int phase = 0; phase < np; ++phase) { - well_potentials[w*np + phase] += xw.wellPotentials()[perf*np + phase]; - } - } - } - } - void updateListEconLimited(const std::unique_ptr& solver, const Schedule& schedule, diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index ca415a265..f31203432 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -243,17 +243,13 @@ enum WellVariablePositions { const double grav); - // TODO: Later we might want to change the function to only handle one well, - // the requirement for well potential calculation can be based on individual wells. - // getBhp() will be refactored to reduce the duplication of the code calculating the bhp from THP. + // Calculating well potentials for each well + // TODO: getBhp() will be refactored to reduce the duplication of the code calculating the bhp from THP. template void computeWellPotentials(const Simulator& ebosSimulator, - WellState& well_state) const; - - // TODO: temporary function name for now before changing the simulator and also WellsMananger - void computeWellPotentials(const WellState& well_state, - std::vector& well_potentials) const; + const WellState& well_state, + std::vector& well_potentials) const; // TODO: some preparation work, mostly related to group control and RESV, // at the beginning of each time step (Not report step) diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 46468bcef..37fc38d24 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -134,10 +134,6 @@ namespace Opm { return report; } - if (param_.compute_well_potentials_) { - computeWellPotentials(ebosSimulator, well_state); - } - resetWellControlFromState(well_state); updateWellControls(well_state); // Set the primary variables for the wells @@ -1703,13 +1699,16 @@ namespace Opm { void StandardWellsDense:: computeWellPotentials(const Simulator& ebosSimulator, - WellState& well_state) const + const WellState& well_state, + std::vector& well_potentials) const { // number of wells and phases const int nw = wells().number_of_wells; const int np = wells().number_of_phases; + well_potentials.resize(nw * np, 0.0); + for (int w = 0; w < nw; ++w) { // bhp needs to be determined for the well potential calculation // There can be more than one BHP/THP constraints. @@ -1783,7 +1782,6 @@ namespace Opm { const double& alq = well_controls_iget_alq(well_control, ctrl_index); // Calculating the BHP value based on THP - const WellType& well_type = wells().type[w]; const int first_perf = wells().well_connpos[w]; //first perforation if (well_type == INJECTOR) { @@ -1819,12 +1817,12 @@ namespace Opm { for (int perf = wells().well_connpos[w]; perf < wells().well_connpos[w+1]; ++perf) { const int cell_index = wells().well_cells[perf]; const auto& intQuants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_index, /*timeIdx=*/ 0)); - std::vector well_potentials(np, 0.0); + std::vector well_potentials_perf(np, 0.0); std::vector mob(np, 0.0); getMobility(ebosSimulator, perf, cell_index, mob); - computeWellFlux(w, wells().WI[perf], intQuants.fluidState(), mob, bhp, wellPerforationPressureDiffs()[perf], allow_cf, well_potentials); + computeWellFlux(w, wells().WI[perf], intQuants.fluidState(), mob, bhp, wellPerforationPressureDiffs()[perf], allow_cf, well_potentials_perf); for(int p = 0; p < np; ++p) { - well_state.wellPotentials()[perf * np + p] = well_potentials[p].value(); + well_potentials[w * np + p] += std::abs(well_potentials_perf[p].value()); } } } // end of for (int w = 0; w < nw; ++w) @@ -1852,12 +1850,10 @@ namespace Opm { setWellVariables(well_state); computeWellConnectionPressures(ebos_simulator, well_state); - computeWellPotentials(ebos_simulator, well_state); - // To store well potentials for each well std::vector well_potentials; - computeWellPotentials(well_state, well_potentials); + computeWellPotentials(ebos_simulator, well_state, well_potentials); // update/setup guide rates for each well based on the well_potentials well_collection_->setGuideRates(wellsPointer(), phase_usage_, well_potentials);