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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 );
}
//--------------------------------------------------------------------------------------------------

View File

@ -363,7 +363,9 @@ RimGeoMechCase::CaseOpenStatus RimGeoMechCase::openGeoMechCase( std::string* err
}
// Continue reading the open file
if ( !geoMechCaseData->readFemParts( errorMessage, m_timeStepFilter->filteredTimeSteps() ) )
if ( !geoMechCaseData->readFemParts( errorMessage,
m_timeStepFilter->filteredTimeSteps(),
m_timeStepFilter->readOnlyLastFrame() ) )
{
return CASE_OPEN_ERROR;
}

View File

@ -26,9 +26,11 @@
#include "RimEclipseResultCase.h"
#include "RimGeoMechCase.h"
#include "RimProject.h"
#include "RimReloadCaseTools.h"
#include "RimReservoirCellResultsStorage.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiPushButtonEditor.h"
@ -84,10 +86,24 @@ RimTimeStepFilter::RimTimeStepFilter()
m_filteredTimeStepsUi.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
m_filteredTimeStepsUi.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_readOnlyLastFrame, "OnlyLastFrame", false, "Load Only Last Frame Of Each Time Step" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_readOnlyLastFrame );
CAF_PDM_InitFieldNoDefault( &m_applyReloadOfCase, "ApplyReloadOfCase", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyReloadOfCase );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeStepFilter::initAfterRead()
{
if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2023.1" ) )
{
m_readOnlyLastFrame = true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -272,19 +288,18 @@ void RimTimeStepFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
RimGeoMechCase* rimGeoMechCase = parentGeoMechCase();
if ( changedField == &m_applyReloadOfCase )
{
if ( updateFilteredTimeStepsFromUi() )
{
if ( rimEclipseResultCase )
{
RimReloadCaseTools::reloadAllEclipseGridData( rimEclipseResultCase );
}
else if ( rimGeoMechCase )
{
rimGeoMechCase->reloadDataAndUpdate();
}
updateFilteredTimeStepsFromUi();
return;
if ( rimEclipseResultCase )
{
RimReloadCaseTools::reloadAllEclipseGridData( rimEclipseResultCase );
}
else if ( rimGeoMechCase )
{
rimGeoMechCase->reloadDataAndUpdate();
}
return;
}
if ( changedField == &m_filterType || changedField == &m_firstTimeStep || changedField == &m_lastTimeStep ||
@ -448,6 +463,8 @@ void RimTimeStepFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
else if ( geoMechCase )
{
caseLoaded = geoMechCase->geoMechData() != nullptr;
uiOrdering.add( &m_readOnlyLastFrame );
}
if ( caseLoaded )
@ -459,3 +476,19 @@ void RimTimeStepFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeStepFilter::setReadOnlyLastFrame( bool onlyLast )
{
m_readOnlyLastFrame = onlyLast;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimTimeStepFilter::readOnlyLastFrame() const
{
return m_readOnlyLastFrame;
}

View File

@ -60,6 +60,12 @@ public:
TimeStepFilterTypeEnum filterType,
int interval );
void setReadOnlyLastFrame( bool onlyLast );
bool readOnlyLastFrame() const;
protected:
void initAfterRead() override;
private:
static QDateTime incrementDateTime( const QDateTime& dateTime, TimeStepFilterTypeEnum filterType, int interval );
@ -89,4 +95,5 @@ private:
caf::PdmField<bool> m_applyReloadOfCase;
caf::PdmField<QString> m_dateFormat;
caf::PdmField<std::vector<QString>> m_timeStepNamesFromFile;
caf::PdmField<bool> m_readOnlyLastFrame;
};