From 22af6e563c736b2ab137f644413954aaaf769efb Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 13 Jun 2019 10:28:55 +0200 Subject: [PATCH] fix upwinding for injector --- .../wells/MultisegmentWell_impl.hpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 677b62a6b..34b5511da 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -1394,6 +1394,11 @@ namespace Opm // the result will contain the derivative with resepct to GTotal in segment seg, // and the derivatives with respect to WFrac GFrac in segment seg_upwind. // the derivative with respect to SPres should be zero. + if (seg == 0 && well_type_ == INJECTOR) { + const double* distr = well_controls_get_current_distr(well_controls_); + return primary_variables_evaluation_[seg][GTotal] * distr[ebosCompIdxToFlowCompIdx(comp_idx)]; + } + const EvalWell segment_rate = primary_variables_evaluation_[seg][GTotal] * volumeFractionScaled(seg_upwind, comp_idx); assert(segment_rate.derivative(SPres + numEq) == 0.); @@ -2431,11 +2436,19 @@ namespace Opm MultisegmentWell:: updateUpwindingSegments() { - // not considering upwinding for the injectors for now - // but we should - // and upwinding segment for top segment is itself for (int seg = 0; seg < numberOfSegments(); ++seg) { - if ( (well_type_ == INJECTOR) || (seg == 0) ) { + // special treatment is needed for segment 0 + if (seg == 0) { + if ( (well_type_ == INJECTOR)) { + // maybe it is safer to return -1 to make sure that we don't return the wrong segment number + // for injectors + upwinding_segments_[seg] = seg; + assert(primary_variables_evaluation_[seg][GTotal] >= 0.); + continue; + } + + // we don't handle injecting producers. + assert(primary_variables_evaluation_[seg][GTotal] <= 0.); upwinding_segments_[seg] = seg; continue; }