From 87f153588837933b56114965a50882a61ba5c8ad Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 May 2020 10:34:54 +0200 Subject: [PATCH] #5920 Allan Diagrams : Avoid computation until required --- .../RimEclipseResultDefinition.cpp | 2 ++ .../RigCaseCellResultsData.cpp | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 6b88e67196..cfa4a041be 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1937,6 +1937,8 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen int frmIdx2 = it->first.second; int combIndex = it->second; + if ( frmIdx1 >= fnVector.size() || frmIdx2 >= fnVector.size() ) continue; + QString frmName1 = fnVector[frmIdx1]; QString frmName2 = fnVector[frmIdx2]; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index ca5ac8d00e..8998170921 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1420,6 +1420,12 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu computeOilVolumes(); } + // Allan results + if ( resultName == RiaDefines::formationAllanResultName() || resultName == RiaDefines::formationBinaryAllanResultName() ) + { + computeAllanResults( this, m_ownerMainGrid ); + } + // Handle SourSimRL reading if ( type == RiaDefines::ResultCatType::SOURSIMRL ) @@ -2961,7 +2967,11 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF } } - computeAllanResults( this, m_ownerMainGrid ); + // As the Allan formation diagram is depending on formation results, we need to clear the data set + // Will be recomputed when required + auto fnNamesResAddr = + RigEclipseResultAddress( RiaDefines::ResultCatType::ALLAN_DIAGRAMS, RiaDefines::formationAllanResultName() ); + clearScalarResult( fnNamesResAddr ); } //-------------------------------------------------------------------------------------------------- @@ -3078,12 +3088,11 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe CVF_ASSERT( mainGrid ); CVF_ASSERT( cellResultsData ); - auto fnNamesResAddr = RigEclipseResultAddress( RiaDefines::ResultCatType::FORMATION_NAMES, - RiaDefines::activeFormationNamesResultName() ); - bool hasFormationData = cellResultsData->hasResultEntry( fnNamesResAddr ); - - if ( hasFormationData ) + if ( cellResultsData && cellResultsData->activeFormationNames() && + !cellResultsData->activeFormationNames()->formationNames().empty() ) { + auto fnNamesResAddr = RigEclipseResultAddress( RiaDefines::ResultCatType::FORMATION_NAMES, + RiaDefines::activeFormationNamesResultName() ); auto fnAllanResultResAddr = RigEclipseResultAddress( RiaDefines::ResultCatType::ALLAN_DIAGRAMS, RiaDefines::formationAllanResultName() ); auto fnBinAllanResAddr = RigEclipseResultAddress( RiaDefines::ResultCatType::ALLAN_DIAGRAMS,