variableState: Don't reference non-existing variable

The "xvar" exists only if Gas is active.  Therefore, we cannot
extract that variable from "vars" unless we know that Gas is an
active phase.  Failing to do so would wrongfully increment 'nextvar'
whence the final BHP variable would be an out-of-bounds access.
This commit is contained in:
Bård Skaflestad 2014-05-27 16:49:57 +02:00
parent 13d3a42448
commit 35d883319b

View File

@ -532,8 +532,8 @@ namespace {
std::vector<int> all_cells = buildAllCells(nc);
ADB rsSat = fluidRsSat(state.pressure,all_cells);
ADB rvSat = fluidRvSat(state.pressure,all_cells);
ADB xvar = vars[ nextvar++ ];
if (active_[ Gas]) {
ADB xvar = vars[ nextvar++ ];
ADB sg = isSg*xvar + isRv* so;
state.saturation[ pu.phase_pos[ Gas ] ] = sg;
so = so - sg;