Support loading only last geomech frame (#9727)

Support option for loading only the last frame for each geomech timestep. Turn it default on for old projects.
This commit is contained in:
jonjenssen
2023-01-24 18:30:30 +01:00
committed by GitHub
parent a770f89082
commit b28832eccd
8 changed files with 105 additions and 23 deletions

View File

@@ -121,13 +121,15 @@ bool RigGeoMechCaseData::readTimeSteps( std::string* errorMessage, std::vector<s
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter )
bool RigGeoMechCaseData::readFemParts( std::string* errorMessage,
const std::vector<size_t>& timeStepFilter,
bool readOnlyLastFrame )
{
CVF_ASSERT( errorMessage );
#ifdef USE_ODB_API
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
{
m_readerInterface->setTimeStepFilter( timeStepFilter );
m_readerInterface->setTimeStepFilter( timeStepFilter, readOnlyLastFrame );
m_femParts = new RigFemPartCollection();
caf::ProgressInfo progress( 10, "" ); // Here because the next call uses progress

View File

@@ -40,7 +40,7 @@ public:
bool open( std::string* errorMessage );
bool readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames );
bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter = std::vector<size_t>() );
bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter, bool readOnlyLastFrame );
bool readDisplacements( std::string* errorMessage,
int partId,
int timeStep,

View File

@@ -23,6 +23,7 @@
///
//--------------------------------------------------------------------------------------------------
RifGeoMechReaderInterface::RifGeoMechReaderInterface()
: m_readOnlyLastFrame( false )
{
}
@@ -36,13 +37,15 @@ RifGeoMechReaderInterface::~RifGeoMechReaderInterface()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifGeoMechReaderInterface::setTimeStepFilter( const std::vector<size_t>& fileTimeStepIndices )
void RifGeoMechReaderInterface::setTimeStepFilter( const std::vector<size_t>& fileTimeStepIndices, bool readOnlyLastFrame )
{
m_fileTimeStepIndices.reserve( fileTimeStepIndices.size() );
for ( size_t stepIndex : fileTimeStepIndices )
{
m_fileTimeStepIndices.push_back( static_cast<int>( stepIndex ) );
}
m_readOnlyLastFrame = readOnlyLastFrame;
}
//--------------------------------------------------------------------------------------------------
@@ -82,4 +85,21 @@ int RifGeoMechReaderInterface::timeStepIndexOnFile( int timeStepIndex ) const
}
return timeStepIndex;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifGeoMechReaderInterface::frameIndexOnFile( int frameIndex ) const
{
if ( m_readOnlyLastFrame ) return -1;
return frameIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifGeoMechReaderInterface::shouldReadOnlyLastFrame() const
{
return m_readOnlyLastFrame;
}

View File

@@ -73,10 +73,14 @@ public:
int frameIndex,
std::vector<std::vector<float>*>* resultValues ) = 0;
void setTimeStepFilter( const std::vector<size_t>& fileTimeStepIndices );
void setTimeStepFilter( const std::vector<size_t>& fileTimeStepIndices, bool readOnlyLastFrame );
bool isTimeStepIncludedByFilter( int timeStepIndex ) const;
int timeStepIndexOnFile( int timeStepIndex ) const;
int frameIndexOnFile( int frameIndex ) const;
bool shouldReadOnlyLastFrame() const;
private:
std::vector<int> m_fileTimeStepIndices;
bool m_readOnlyLastFrame;
};

View File

@@ -476,12 +476,20 @@ std::vector<double> RifOdbReader::frameTimes( int stepIndex ) const
std::vector<double> frameValues;
int numFrames = stepFrames.size();
for ( int f = 0; f < numFrames; f++ )
if ( shouldReadOnlyLastFrame() )
{
odb_Frame frame = stepFrames.constGet( f );
odb_Frame frame = stepFrames.constGet( stepFrames.size() - 1 );
frameValues.push_back( frame.frameValue() );
}
else
{
int numFrames = stepFrames.size();
for ( int f = 0; f < numFrames; f++ )
{
odb_Frame frame = stepFrames.constGet( f );
frameValues.push_back( frame.frameValue() );
}
}
return frameValues;
}
@@ -491,6 +499,8 @@ std::vector<double> RifOdbReader::frameTimes( int stepIndex ) const
//--------------------------------------------------------------------------------------------------
int RifOdbReader::frameCount( int stepIndex ) const
{
if ( shouldReadOnlyLastFrame() ) return 1;
return frameTimes( stepIndex ).size();
}
@@ -597,12 +607,16 @@ const odb_Frame& RifOdbReader::stepFrame( int stepIndex, int frameIndex ) const
const odb_StepRepository& stepRepository = m_odb->steps();
const odb_StepList& stepList = stepRepository.stepList();
int stepFileIndex = this->timeStepIndexOnFile( stepIndex );
int stepFileIndex = this->timeStepIndexOnFile( stepIndex );
int fileFrameIndex = this->frameIndexOnFile( frameIndex );
const odb_Step& step = stepList.ConstGet( stepFileIndex );
const odb_SequenceFrame& stepFrames = step.frames();
return stepFrames.constGet( frameIndex );
// should we only load the last frame (frameIndex < 0)?
if ( fileFrameIndex < 0 ) fileFrameIndex = stepFrames.size() - 1;
return stepFrames.constGet( fileFrameIndex );
}
//--------------------------------------------------------------------------------------------------