#14345 Recompute calculated results when data for a time step has been released

The grid calculator releases result data per time step to reduce memory
usage when calculating for many cases. If only some time steps are
released, findOrLoadKnownScalarResult() returned early because data was
present for other time steps, leaving the released time steps empty.
Results computed by ResInsight, like riOILVOLUME, then appeared as
undefined in the 3d view after running a calculation for a selected
time step.

Recompute results computed by ResInsight when data is missing for any
time step. Skip the delegation from the single time step variant when
the requested time step already has data, to avoid repeated
recomputation while the calculator releases other time steps.
This commit is contained in:
Kristian Bendiksen authored and Magne Sjaastad committed 2026-09-07 11:18:09 +02:00
1 parent 4c143482bb
commit e85137db6e
2 files changed
+43 -6

No files matched your search

@@ -1516,7 +1516,15 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu
if ( isDataPresent( scalarResultIndex ) )
{
return scalarResultIndex;
// Data for some time steps can have been released to reduce memory usage, see
// RimGridCalculation::getActiveCellValues(). Results computed by ResInsight can not be reloaded from
// file, so continue to recompute them if data is missing for any time step.
const bool mustRecompute = isResultComputedByResInsight( resultName, scalarResultIndex ) &&
hasEmptyDataForAnyTimeStep( scalarResultIndex );
if ( !mustRecompute )
{
return scalarResultIndex;
}
}
if ( resultName == RiaResultNames::soil() )
@@ -1819,12 +1827,16 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep( const Rig
// Results computed by ResInsight (e.g. riOILVOLUME) can not be read from file for a single time step.
// Delegate to findOrLoadKnownScalarResult(), which computes all time steps using the result
// calculators. Data already present is not computed again.
const bool isComputedResult = mustBeCalculated( scalarResultIndex ) || resultName == RiaResultNames::riCellVolumeResultName() ||
resultName == RiaResultNames::riOilVolumeResultName() || resultName == RiaResultNames::riPorvSoil() ||
resultName == RiaResultNames::riPorvSgas() || resultName == RiaResultNames::riPorvSoilSgas();
if ( isComputedResult )
// calculators. Skip the delegation if data is already present for the requested time step, to avoid
// repeated recomputation when data for other time steps is released during a calculation.
if ( isResultComputedByResInsight( resultName, scalarResultIndex ) )
{
const auto& valuesAllTimeSteps = m_cellScalarResults[scalarResultIndex];
if ( timeStepIndex < valuesAllTimeSteps.size() && !valuesAllTimeSteps[timeStepIndex].empty() )
{
return scalarResultIndex;
}
return findOrLoadKnownScalarResult( resVarAddr );
}
@@ -3151,6 +3163,28 @@ bool RigCaseCellResultsData::isDataPresent( size_t scalarResultIndex ) const
return allocatedValueCount( scalarResultIndex ) > 0;
}
//--------------------------------------------------------------------------------------------------
/// Returns true for results that are computed by ResInsight and can not be read from file
//--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::isResultComputedByResInsight( const QString& resultName, size_t scalarResultIndex ) const
{
return mustBeCalculated( scalarResultIndex ) || resultName == RiaResultNames::riCellVolumeResultName() ||
resultName == RiaResultNames::riOilVolumeResultName() || resultName == RiaResultNames::riPorvSoil() ||
resultName == RiaResultNames::riPorvSgas() || resultName == RiaResultNames::riPorvSoilSgas();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::hasEmptyDataForAnyTimeStep( size_t scalarResultIndex ) const
{
if ( scalarResultIndex >= resultCount() ) return false;
const std::vector<std::vector<double>>& valuesAllTimeSteps = m_cellScalarResults[scalarResultIndex];
return std::any_of( valuesAllTimeSteps.begin(), valuesAllTimeSteps.end(), []( const auto& values ) { return values.empty(); } );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------