Add time step filter

This commit is contained in:
Magne Sjaastad 2023-12-06 09:38:39 +01:00
parent 27f9ef4700
commit 3f0b767528
2 changed files with 53 additions and 0 deletions

View File

@ -45,6 +45,8 @@
#include "expressionparser/ExpressionParser.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <QCheckBox>
#include <QMessageBox>
@ -74,6 +76,9 @@ RimGridCalculation::RimGridCalculation()
CAF_PDM_InitFieldNoDefault( &m_destinationCase, "DestinationCase", "Destination Case" );
CAF_PDM_InitField( &m_applyToAllCases, "AllDestinationCase", false, "Apply to All Cases" );
CAF_PDM_InitField( &m_defaultPropertyVariableIndex, "DefaultPropertyVariableName", 0, "Property Variable Name" );
CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "Time Step Selection" );
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
@ -238,6 +243,10 @@ void RimGridCalculation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
filterGroup->add( &m_defaultValue );
}
caf::PdmUiGroup* timeStepGroup = uiOrdering.addNewGroup( "Time Step Filter" );
timeStepGroup->setCollapsedByDefault();
timeStepGroup->add( &m_selectedTimeSteps );
uiOrdering.skipRemainingFields();
}
@ -299,6 +308,23 @@ QList<caf::PdmOptionItemInfo> RimGridCalculation::calculateValueOptions( const c
options.push_back( caf::PdmOptionItemInfo( optionText, i ) );
}
}
else if ( &m_selectedTimeSteps == fieldNeedingOptions )
{
RimEclipseCase* firstEclipseCase = nullptr;
if ( !inputCases().empty() ) firstEclipseCase = inputCases().front();
if ( firstEclipseCase )
{
const auto timeStepStrings = firstEclipseCase->timeStepStrings();
int index = 0;
for ( const auto& text : timeStepStrings )
{
options.push_back( caf::PdmOptionItemInfo( text, index++ ) );
}
}
}
return options;
}
@ -618,6 +644,31 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
// always 1 or more.
const size_t timeStepCount = std::max( size_t( 1 ), calculationCase->results( porosityModel )->maxTimeStepCount() );
if ( calculationCase == calculationCases.front() && hasAggregationExpression )
{
// Print time header
auto timeStepStrings = calculationCase->timeStepStrings();
QString timeHeader;
for ( size_t tsId = 0; tsId < timeStepCount; tsId++ )
{
// Skip time steps that are not in the list of time steps to calculate
if ( timeSteps && std::find( timeSteps->begin(), timeSteps->end(), tsId ) == timeSteps->end() ) continue;
timeHeader += "\t";
auto index = static_cast<int>( tsId );
if ( index < timeStepStrings.size() )
{
timeHeader += timeStepStrings.at( static_cast<int>( tsId ) );
}
else
timeHeader += "Undefined";
}
RiaLogging::info( timeHeader );
}
std::vector<std::vector<double>>* scalarResultFrames =
calculationCase->results( porosityModel )->modifiableCellScalarResultTimesteps( resAddr );
scalarResultFrames->resize( timeStepCount );

View File

@ -117,5 +117,7 @@ private:
caf::PdmPtrField<RimEclipseCase*> m_destinationCase;
caf::PdmField<bool> m_applyToAllCases;
caf::PdmField<std::vector<int>> m_selectedTimeSteps;
caf::PdmField<int> m_defaultPropertyVariableIndex;
};