diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index b125ee317..3c320210c 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -213,8 +213,9 @@ namespace Opm { /// \param[in, out] well_state well state variables void prepareStep(const SimulatorTimerInterface& /*timer*/, const ReservoirState& /*reservoir_state*/, - const WellState& /* well_state */) + WellState& well_state) { + well_model_.prepareTimeStep(ebosSimulator_, well_state); } diff --git a/opm/autodiff/NonlinearSolver_impl.hpp b/opm/autodiff/NonlinearSolver_impl.hpp index 6c64f4cd0..9062ad5b0 100644 --- a/opm/autodiff/NonlinearSolver_impl.hpp +++ b/opm/autodiff/NonlinearSolver_impl.hpp @@ -127,7 +127,11 @@ namespace Opm failureReport_ = SimulatorReport(); // Do model-specific once-per-step calculations. - model_->prepareStep(timer, initial_reservoir_state, initial_well_state); + // TODO: this is not the correct fix, possibly breaking the sequential solver + // TODO: the only reason to do this is that the wellPotentials() is part of the well_state, which will be modified + // during the well_potential calculation + model_->prepareStep(timer, initial_reservoir_state, well_state); + // model_->prepareStep(timer, initial_reservoir_state, initial_reservoir_state); int iteration = 0; diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index 38f769025..ca415a265 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -251,11 +251,16 @@ enum WellVariablePositions { 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; + // TODO: some preparation work, mostly related to group control and RESV, + // at the beginning of each time step (Not report step) + template + void prepareTimeStep(const Simulator& ebos_simulator, + WellState& well_state); + WellCollection* wellCollection() const; const std::vector& diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 92739cd19..ad7b6e11f 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -1834,7 +1834,45 @@ namespace Opm { - template + template + template + void + StandardWellsDense:: + prepareTimeStep(const Simulator& ebos_simulator, + WellState& well_state) + { + + // TODO: we should remove the wellPotentials() from the well_state. + + if (well_collection_->groupControlActive()) { + // calculate the well potentials + // two functions will probably be merged in the final version + // and also the well potentials related parts in well state. + if (param_.compute_well_potentials_) { + 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); + + // update/setup guide rates for each well based on the well_potentials + well_collection_->setGuideRates(wellsPointer(), phase_usage_, well_potentials); + } + applyVREPGroupControl(well_state); + wellCollection()->updateWellTargets(well_state.wellRates()); + } + } + + + + + + + template WellCollection* StandardWellsDense:: wellCollection() const