Skip to content

Commit

Permalink
#10488 Element property values not shown in geomech view
Browse files Browse the repository at this point in the history
Make sure element results are created only once
Make sure single element results access data for time step 0 and frame 0
  • Loading branch information
magnesj committed Aug 15, 2023
1 parent ef2de3e commit cedcbe0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,26 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
std::map<std::string, std::vector<float>> 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, "" );
RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement );
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( m_dataForEachFrame[timeStepIndex].size() );
Expand All @@ -70,7 +72,11 @@ std::vector<float>& 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() );

Expand Down

0 comments on commit cedcbe0

Please sign in to comment.