diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index f8104b2f95..c06ebae5c8 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -380,20 +380,8 @@ void RigReservoirCellResults::loadOrComputeSOIL() if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) { - const std::vector< std::vector >* swat = NULL; - const std::vector< std::vector >* sgas = NULL; - size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT"); - if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) - { - swat = &(cellScalarResults(scalarIndexSWAT)); - } - size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS"); - if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) - { - sgas = &(cellScalarResults(scalarIndexSGAS)); - } // Early exit if none of SWAT or SGAS is present if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) @@ -401,6 +389,20 @@ void RigReservoirCellResults::loadOrComputeSOIL() return; } + soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + + const std::vector< std::vector >* swat = NULL; + const std::vector< std::vector >* sgas = NULL; + if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) + { + swat = &(cellScalarResults(scalarIndexSWAT)); + } + + if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) + { + sgas = &(cellScalarResults(scalarIndexSGAS)); + } + size_t soilResultValueCount = 0; size_t soilTimeStepCount = 0; if (swat) @@ -417,7 +419,6 @@ void RigReservoirCellResults::loadOrComputeSOIL() soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); } - soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount); std::vector< std::vector >& soil = cellScalarResults(soilResultGridIndex); @@ -427,9 +428,8 @@ void RigReservoirCellResults::loadOrComputeSOIL() { soil[timeStepIdx].resize(soilResultValueCount); - int idx = 0; #pragma omp parallel for - for (idx = 0; idx < static_cast(soilResultValueCount); idx++) + for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) { double soilValue = 1.0; if (sgas)