diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp index c9b9ac3c22..6d3f60aef0 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp @@ -115,6 +115,9 @@ void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean( size_t time m_caseData->ensureKnownResultLoaded( mobPorvAddress ); + if ( !m_caseData->hasResultEntry( m_resultAddress ) ) return; + if ( m_caseData->timeStepCount( m_resultAddress ) == 0 ) return; + const std::vector& weights = m_caseData->cellScalarResults( mobPorvAddress, 0 ); const std::vector& values = m_caseData->cellScalarResults( m_resultAddress, timeStepIndex ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h index 4288421890..641e89b977 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h @@ -52,6 +52,9 @@ private: template void traverseCells( StatisticsAccumulator& accumulator, size_t timeStepIndex ) { + if ( !m_caseData->hasResultEntry( m_resultAddress ) ) return; + if ( m_caseData->timeStepCount( m_resultAddress ) == 0 ) return; + size_t clampedTimeStepIndex = std::min( timeStepIndex, m_caseData->timeStepCount( m_resultAddress ) - 1 ); const std::vector& values = m_caseData->cellScalarResults( m_resultAddress, clampedTimeStepIndex );