[bugfix] Fix invalid read in WellDenseStandard when used with 2P Model.

This commit is contained in:
Robert Kloefkorn
2017-05-31 13:01:51 +02:00
parent 138eb2c91b
commit 3db16ede73

View File

@@ -683,11 +683,18 @@ namespace Opm {
setWellVariables(const WellState& xw) setWellVariables(const WellState& xw)
{ {
const int nw = wells().number_of_wells; const int nw = wells().number_of_wells;
for (int eqIdx = 0; eqIdx < numWellEq; ++eqIdx) { // for two-phase numComp < numEq
const int numComp = numComponents();
for (int eqIdx = 0; eqIdx < numComp; ++eqIdx) {
for (int w = 0; w < nw; ++w) { for (int w = 0; w < nw; ++w) {
wellVariables_[w + nw*eqIdx] = 0.0; const unsigned int idx = nw * eqIdx + w;
wellVariables_[w + nw*eqIdx].setValue(xw.wellSolutions()[w + nw* eqIdx]); assert( idx < wellVariables_.size() );
wellVariables_[w + nw*eqIdx].setDerivative(numWellEq + eqIdx, 1.0); assert( idx < xw.wellSolutions().size() );
EvalWell& eval = wellVariables_[ idx ];
eval = 0.0;
eval.setValue( xw.wellSolutions()[ idx ] );
eval.setDerivative(numWellEq + eqIdx, 1.0);
} }
} }
} }
@@ -997,7 +1004,7 @@ namespace Opm {
{ {
bval/=global_nc_; bval/=global_nc_;
} }
auto res = residual(); auto res = residual();
const int nw = res.size() / numComp; const int nw = res.size() / numComp;