From a93532e1ceeaf26a22a4ae889f3a0485036de8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 18 Jan 2013 13:23:37 +0100 Subject: [PATCH] Opm::WellState::init(): Handle shut wells This is a minor bugfix to account for the presence of shut wells (characterised by "ctrls[w]->current < 0"). The existing code would lead to indexing outside the "ctrls" array in the context of a shut well. --- opm/core/simulator/WellState.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index 981ccd9b..f0de92b0 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -42,12 +42,15 @@ namespace Opm // to pressure in first perforation cell. for (int w = 0; w < nw; ++w) { const WellControls* ctrl = wells->ctrls[w]; - if (ctrl->type[ctrl->current] == BHP) { - bhp_[w] = ctrl->target[ctrl->current]; - } else { + + if ((ctrl->current < 0) || // SHUT + (ctrl->type[ctrl->current] != BHP)) { const int cell = wells->well_cells[wells->well_connpos[w]]; bhp_[w] = state.pressure()[cell]; } + else { + bhp_[w] = ctrl->target[ctrl->current]; + } } perfrates_.resize(wells->well_connpos[nw], 0.0); perfpress_.resize(wells->well_connpos[nw], -1e100);