[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)
{
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) {
wellVariables_[w + nw*eqIdx] = 0.0;
wellVariables_[w + nw*eqIdx].setValue(xw.wellSolutions()[w + nw* eqIdx]);
wellVariables_[w + nw*eqIdx].setDerivative(numWellEq + eqIdx, 1.0);
const unsigned int idx = nw * eqIdx + w;
assert( idx < wellVariables_.size() );
assert( idx < xw.wellSolutions().size() );
EvalWell& eval = wellVariables_[ idx ];
eval = 0.0;
eval.setValue( xw.wellSolutions()[ idx ] );
eval.setDerivative(numWellEq + eqIdx, 1.0);
}
}
}