From 7ded0907fea3eb758c296b0f5f4cbbdb0be17e49 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 16 Nov 2018 13:47:43 +0100 Subject: [PATCH] using control in DECK to initialize the control in WellState otherwise, it might not be initialized if the well does not exisit in previous well state, which will result in undefined behavoir. it causes failure in running some realizations. --- opm/autodiff/WellStateFullyImplicitBlackoil.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp index b63f0c42f..667f66482 100644 --- a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp +++ b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp @@ -142,6 +142,10 @@ namespace Opm } current_controls_.resize(nw); + // The controls set in the Wells (specified in the DECK) are treated as default initial value + for (int w = 0; w < nw; ++w) { + current_controls_[w] = well_controls_get_current(wells->ctrls[w]); + } perfRateSolvent_.clear(); perfRateSolvent_.resize(nperf, 0.0); productivity_index_.resize(nw * np, 0.0); @@ -172,8 +176,6 @@ namespace Opm current_controls_[ newIndex ] = prevState->currentControls()[ oldIndex ]; // also change the one in the WellControls well_controls_set_current(wells->ctrls[w], current_controls_[ newIndex ]); - } else { - current_controls_[w] = well_controls_get_current(wells->ctrls[w]); } // wellrates