diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 954cba0d83..eddb5fc382 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -447,6 +447,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i std::map> elementProperties = m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName ); + // We are supposed to get here only once. Create result containers for all imported element results in one go for ( auto& [addrString, values] : elementProperties ) { RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" ); @@ -454,7 +455,18 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i currentFrames->enableAsSingleStepResult(); currentFrames->frameData( 0, 0 ).swap( values ); } - return m_femPartResults[partIndex]->createScalarResult( resVarAddr ); + + // Try to find the element result and return it + frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr ); + if ( frames ) + { + return frames; + } + else + { + // Create a dummy empty result + return m_femPartResults[partIndex]->createScalarResult( resVarAddr ); + } } // We need to read the data as bulk fields, and populate the correct scalar caches diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp index 3615310b96..25b0e1e401 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp @@ -58,6 +58,8 @@ int RigFemScalarResultFrames::timeStepCount() const //-------------------------------------------------------------------------------------------------- int RigFemScalarResultFrames::frameCount( int timeStepIndex ) const { + if ( m_isSingleStepResult ) return 1; + if ( timeStepIndex >= timeStepCount() ) return 0; return static_cast( m_dataForEachFrame[timeStepIndex].size() ); @@ -70,7 +72,11 @@ std::vector& RigFemScalarResultFrames::frameData( int timeStepIndex, int { CVF_ASSERT( timeStepIndex < timeStepCount() ); - if ( m_isSingleStepResult ) timeStepIndex = 0; + if ( m_isSingleStepResult ) + { + timeStepIndex = 0; + frameIndex = 0; + } int availFrames = int( m_dataForEachFrame[timeStepIndex].size() );