From 2d115888dee6e86ad5340484820e5785bbb7c91f Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 21 Sep 2016 12:23:34 +0200 Subject: [PATCH] Zero initialize wells with no perforations. For these wells access its well_cells might read of the bounds an array if they are the last wells in the struct. Therefore we cannnot initialiue first_cell and the well control is uninitialized, to. With this commit theses wells are now detected and theor bhp, thp, and well_rates are initialized to zero. --- opm/core/simulator/WellState.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index acadf7ef9..baacaa179 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -65,6 +65,7 @@ namespace Opm for (int w = 0; w < nw; ++w) { assert((wells->type[w] == INJECTOR) || (wells->type[w] == PRODUCER)); const WellControls* ctrl = wells->ctrls[w]; + const int num_perf_this_well = wells->well_connpos[w + 1] - wells->well_connpos[w]; // setup wellname -> well index mapping { @@ -75,10 +76,20 @@ namespace Opm wellMapEntry[ 0 ] = w; wellMapEntry[ 1 ] = wells->well_connpos[w]; // also store the number of perforations in this well - const int num_perf_this_well = wells->well_connpos[w + 1] - wells->well_connpos[w]; wellMapEntry[ 2 ] = num_perf_this_well; } + if ( num_perf_this_well == 0 ) + { + // No perforations of the well. Initialize to zero. + for (int p = 0; p < np; ++p) { + wellrates_[np*w + p] = 0.0; + } + bhp_[w] = 0; + thp_[w] = 0; + continue; + } + if (well_controls_well_is_stopped(ctrl)) { // Stopped well: // 1. Rates: assign zero well rates. @@ -143,7 +154,7 @@ namespace Opm } else { thp_[w] = bhp_[w]; } - } + } } // The perforation rates and perforation pressures are