Use correct region temperature when calculating RS/RV

The InitialStateComputer::temperature_ array, previously used,
was of cartesian size, but used as if it only contained the
values of the cells of a region.
With this commit InitialStateComputer::temperature_ is a compressed local
array and we explicitly copy out only the region values when computing
RS/RV.

Closes #2423.
This commit is contained in:
Markus Blatt 2020-03-09 15:20:07 +01:00
parent bb29ad1060
commit eb8ac2af2d

View File

@ -1082,7 +1082,7 @@ private:
void updateInitialTemperature_(const Opm::EclipseState& eclState)
{
// Get the initial temperature data
std::vector<double> tempiData = eclState.fieldProps().get_global_double("TEMPI");
std::vector<double> tempiData = eclState.fieldProps().get_double("TEMPI");
temperature_ = tempiData;
}
@ -1154,8 +1154,10 @@ private:
if (oil && gas) {
const int oilpos = FluidSystem::oilPhaseIdx;
const int gaspos = FluidSystem::gasPhaseIdx;
const Vec rsVals = computeRs(grid, cells, pressures[oilpos], temperature_, *(rsFunc_[r]), sat[gaspos]);
const Vec rvVals = computeRs(grid, cells, pressures[gaspos], temperature_, *(rvFunc_[r]), sat[oilpos]);
std::vector<double> regionTemperature(cells.size());
copyToRegion(temperature_, cells, regionTemperature);
const Vec rsVals = computeRs(grid, cells, pressures[oilpos], regionTemperature, *(rsFunc_[r]), sat[gaspos]);
const Vec rvVals = computeRs(grid, cells, pressures[gaspos], regionTemperature, *(rvFunc_[r]), sat[oilpos]);
copyFromRegion(rsVals, cells, rs_);
copyFromRegion(rvVals, cells, rv_);
}
@ -1175,6 +1177,18 @@ private:
}
}
template <class CellRangeType>
void copyToRegion(const Vec& source,
const CellRangeType& cells,
Vec& destination)
{
auto d = destination.begin();
auto c = cells.begin();
const auto e = cells.end();
for (; c != e; ++c, ++d) {
*d = source[*c];
}
}
};
} // namespace DeckDependent
} // namespace EQUIL