Merge pull request #1198 from dr-robertk/PR/fix-densewell-for-2p

[bugfix] Fix invalid read in WellDenseStandard when used with 2P Model.
This commit is contained in:
Tor Harald Sandve 2017-06-07 13:57:44 +02:00 committed by GitHub
commit 2a66aa23a9

View File

@ -700,11 +700,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);
} }
} }
} }