mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8041 Histogram Calculations : Guard access to missing or empty result data
Crash seen when computing histogram data based on a difference case with no data.
This commit is contained in:
parent
515168600f
commit
cb6180b118
@ -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<double>& weights = m_caseData->cellScalarResults( mobPorvAddress, 0 );
|
||||
const std::vector<double>& values = m_caseData->cellScalarResults( m_resultAddress, timeStepIndex );
|
||||
|
||||
|
@ -52,6 +52,9 @@ private:
|
||||
template <typename StatisticsAccumulator>
|
||||
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<double>& values = m_caseData->cellScalarResults( m_resultAddress, clampedTimeStepIndex );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user