From e9c0bdba06d66f9389dca762aed0433971b7e0f9 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 27 Feb 2019 14:47:31 +0100 Subject: [PATCH] using B_avg for the inner iteration for multisegment wells --- opm/autodiff/BlackoilWellModel.hpp | 2 +- opm/autodiff/BlackoilWellModel_impl.hpp | 15 ++++++++------- opm/autodiff/MultisegmentWell.hpp | 2 ++ opm/autodiff/MultisegmentWell_impl.hpp | 17 +++++++---------- opm/autodiff/StandardWell.hpp | 1 + opm/autodiff/StandardWellV.hpp | 1 + opm/autodiff/StandardWellV_impl.hpp | 1 + opm/autodiff/StandardWell_impl.hpp | 1 + opm/autodiff/WellInterface.hpp | 1 + 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/opm/autodiff/BlackoilWellModel.hpp b/opm/autodiff/BlackoilWellModel.hpp index 57411760a..8d3ce91f2 100644 --- a/opm/autodiff/BlackoilWellModel.hpp +++ b/opm/autodiff/BlackoilWellModel.hpp @@ -358,7 +358,7 @@ namespace Opm { void computeRepRadiusPerfLength(const Grid& grid, Opm::DeferredLogger& deferred_logger); - void computeAverageFormationFactor(std::vector& B_avg) const; + void computeAverageFormationFactor(std::vector& B_avg) const; void applyVREPGroupControl(); diff --git a/opm/autodiff/BlackoilWellModel_impl.hpp b/opm/autodiff/BlackoilWellModel_impl.hpp index 4fb5050ef..1d46d05e1 100644 --- a/opm/autodiff/BlackoilWellModel_impl.hpp +++ b/opm/autodiff/BlackoilWellModel_impl.hpp @@ -687,15 +687,20 @@ 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) { // solve the well equations as a pre-processing step - last_report_ = solveWellEq(dt, local_deferredLogger); + last_report_ = solveWellEq(B_avg, dt, local_deferredLogger); + if (initial_step_) { // update the explicit quantities to get the initial fluid distribution in the well correct. calculateExplicitQuantities(local_deferredLogger); prepareTimeStep(local_deferredLogger); - last_report_ = solveWellEq(dt, local_deferredLogger); + last_report_ = solveWellEq(B_avg, dt, local_deferredLogger); initial_step_ = false; } // TODO: should we update the explicit related here again, or even prepareTimeStep(). @@ -877,10 +882,6 @@ namespace Opm { { WellState well_state0 = well_state_; - const int numComp = numComponents(); - std::vector< Scalar > B_avg( numComp, Scalar() ); - computeAverageFormationFactor(B_avg); - const int max_iter = param_.max_welleq_iter_; int it = 0; @@ -1443,7 +1444,7 @@ namespace Opm { template void BlackoilWellModel:: - computeAverageFormationFactor(std::vector& B_avg) const + computeAverageFormationFactor(std::vector& B_avg) const { const auto& grid = ebosSimulator_.vanguard().grid(); const auto& gridView = grid.leafGridView(); diff --git a/opm/autodiff/MultisegmentWell.hpp b/opm/autodiff/MultisegmentWell.hpp index c0e688fd3..606648216 100644 --- a/opm/autodiff/MultisegmentWell.hpp +++ b/opm/autodiff/MultisegmentWell.hpp @@ -113,6 +113,7 @@ 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; @@ -352,6 +353,7 @@ namespace Opm // TODO: try to make ebosSimulator const, as it should be void iterateWellEquations(const Simulator& ebosSimulator, + const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger); diff --git a/opm/autodiff/MultisegmentWell_impl.hpp b/opm/autodiff/MultisegmentWell_impl.hpp index c06ca746b..605d99669 100644 --- a/opm/autodiff/MultisegmentWell_impl.hpp +++ b/opm/autodiff/MultisegmentWell_impl.hpp @@ -237,6 +237,7 @@ namespace Opm void MultisegmentWell:: assembleWellEq(const Simulator& ebosSimulator, + const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) @@ -244,7 +245,8 @@ namespace Opm const bool use_inner_iterations = param_.use_inner_iterations_ms_wells_; if (use_inner_iterations) { - iterateWellEquations(ebosSimulator, dt, well_state, deferred_logger); + + iterateWellEquations(ebosSimulator, B_avg, dt, well_state, deferred_logger); } assembleWellEqWithoutIteration(ebosSimulator, dt, well_state, deferred_logger); @@ -1763,6 +1765,7 @@ namespace Opm void MultisegmentWell:: iterateWellEquations(const Simulator& ebosSimulator, + const std::vector& B_avg, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) @@ -1780,14 +1783,8 @@ namespace Opm const BVectorWell dx_well = mswellhelpers::invDXDirect(duneD_, resWell_); - // TODO: use these small values for now, not intend to reach the convergence - // in this stage, but, should we? - // We should try to avoid hard-code values in the code. - // If we want to use the real one, we need to find a way to get them. - // const std::vector B {0.8, 0.8, 0.008}; - const std::vector B {0.5, 0.5, 0.005}; - const auto report = getWellConvergence(B, deferred_logger); + const auto report = getWellConvergence(B_avg, deferred_logger); if (report.converged()) { break; } @@ -1831,8 +1828,8 @@ namespace Opm const int nseg = numberOfSegments(); for (int seg = 0; seg < nseg; ++seg) { - // calculating the accumulation term // TODO: without considering the efficiencty factor for now - // volume of the segment + // calculating the accumulation term + // TODO: without considering the efficiencty factor for now { const EvalWell segment_surface_volume = getSegmentSurfaceVolume(ebosSimulator, seg); // for each component diff --git a/opm/autodiff/StandardWell.hpp b/opm/autodiff/StandardWell.hpp index 4790261ff..44cb377ca 100644 --- a/opm/autodiff/StandardWell.hpp +++ b/opm/autodiff/StandardWell.hpp @@ -142,6 +142,7 @@ 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; diff --git a/opm/autodiff/StandardWellV.hpp b/opm/autodiff/StandardWellV.hpp index 09d918162..0ed849f1a 100644 --- a/opm/autodiff/StandardWellV.hpp +++ b/opm/autodiff/StandardWellV.hpp @@ -143,6 +143,7 @@ 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; diff --git a/opm/autodiff/StandardWellV_impl.hpp b/opm/autodiff/StandardWellV_impl.hpp index 427dd379a..b322ae1c7 100644 --- a/opm/autodiff/StandardWellV_impl.hpp +++ b/opm/autodiff/StandardWellV_impl.hpp @@ -480,6 +480,7 @@ namespace Opm void StandardWellV:: assembleWellEq(const Simulator& ebosSimulator, + const std::vector& /* B_avg */, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger diff --git a/opm/autodiff/StandardWell_impl.hpp b/opm/autodiff/StandardWell_impl.hpp index 60192f3db..909a4c4d0 100644 --- a/opm/autodiff/StandardWell_impl.hpp +++ b/opm/autodiff/StandardWell_impl.hpp @@ -445,6 +445,7 @@ namespace Opm void StandardWell:: assembleWellEq(const Simulator& ebosSimulator, + const std::vector& /* B_avg */, const double dt, WellState& well_state, Opm::DeferredLogger& deferred_logger) diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index a570981aa..186fba2be 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -152,6 +152,7 @@ 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