mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Select none, all cases or a grid case group to apply a calculation
This will enable the use of expressions var_a = sum(x) on a grid case group
This commit is contained in:
parent
d61838940a
commit
e2e861ed95
@ -33,7 +33,9 @@
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseCaseTools.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseResultAddress.h"
|
||||
@ -41,6 +43,8 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGridCalculationCollection.h"
|
||||
#include "RimGridCalculationVariable.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimReloadCaseTools.h"
|
||||
#include "RimResultSelectionUi.h"
|
||||
@ -67,6 +71,14 @@ void caf::AppEnum<RimGridCalculation::DefaultValueType>::setUp()
|
||||
addItem( RimGridCalculation::DefaultValueType::USER_DEFINED, "USER_DEFINED", "User Defined Custom Value" );
|
||||
setDefault( RimGridCalculation::DefaultValueType::POSITIVE_INFINITY );
|
||||
}
|
||||
template <>
|
||||
void caf::AppEnum<RimGridCalculation::AdditionalCasesType>::setUp()
|
||||
{
|
||||
addItem( RimGridCalculation::AdditionalCasesType::NONE, "NONE", "None" );
|
||||
addItem( RimGridCalculation::AdditionalCasesType::GRID_CASE_GROUP, "GRID_CASE_GROUP", "Case Group" );
|
||||
addItem( RimGridCalculation::AdditionalCasesType::ALL_CASES, "NONE", "All Cases" );
|
||||
setDefault( RimGridCalculation::AdditionalCasesType::NONE );
|
||||
}
|
||||
}; // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -79,7 +91,12 @@ RimGridCalculation::RimGridCalculation()
|
||||
CAF_PDM_InitFieldNoDefault( &m_defaultValueType, "DefaultValueType", "Non-visible Cell Value" );
|
||||
CAF_PDM_InitField( &m_defaultValue, "DefaultValue", 0.0, "Custom Value" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_destinationCase, "DestinationCase", "Destination Case" );
|
||||
CAF_PDM_InitField( &m_applyToAllCases, "AllDestinationCase", false, "Apply to All Cases" );
|
||||
|
||||
CAF_PDM_InitField( &m_applyToAllCases_OBSOLETE, "AllDestinationCase", false, "Apply to All Cases" );
|
||||
m_applyToAllCases_OBSOLETE.xmlCapability()->setIOWritable( false );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_additionalCasesType, "AdditionalCasesType", "Apply To Additional Cases" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_additionalCaseGroup, "AdditionalCaseGroup", "Case Group" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_nonVisibleResultAddress, "NonVisibleResultAddress", "" );
|
||||
m_nonVisibleResultAddress = new RimEclipseResultAddress;
|
||||
@ -102,7 +119,7 @@ RimGridCalculation::RimGridCalculation()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCalculation::preCalculate() const
|
||||
{
|
||||
if ( RiaGuiApplication::isRunning() && m_applyToAllCases() )
|
||||
if ( RiaGuiApplication::isRunning() && m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::NONE )
|
||||
{
|
||||
const QString cacheKey = "GridCalculatorMessage";
|
||||
|
||||
@ -222,17 +239,18 @@ bool RimGridCalculation::calculate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimEclipseCase*> RimGridCalculation::outputEclipseCases() const
|
||||
{
|
||||
if ( m_applyToAllCases )
|
||||
if ( m_additionalCasesType() == RimGridCalculation::AdditionalCasesType::ALL_CASES )
|
||||
{
|
||||
// Find all Eclipse cases suitable for grid calculations. This includes all single grid cases and source cases in a grid case group.
|
||||
// Exclude the statistics cases, as it is not possible to use them in a grid calculations.
|
||||
//
|
||||
// Note that data read from file can be released from memory when statistics for a time step is calculated. See
|
||||
// RimEclipseStatisticsCaseEvaluator::evaluateForResults()
|
||||
|
||||
return RimEclipseCaseTools::allEclipseGridCases();
|
||||
}
|
||||
|
||||
if ( m_additionalCasesType() == RimGridCalculation::AdditionalCasesType::GRID_CASE_GROUP )
|
||||
{
|
||||
if ( m_additionalCaseGroup() ) return m_additionalCaseGroup->reservoirs.childrenByType();
|
||||
}
|
||||
|
||||
return { m_destinationCase };
|
||||
}
|
||||
|
||||
@ -287,12 +305,9 @@ void RimGridCalculation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
|
||||
uiOrdering.add( &m_destinationCase );
|
||||
|
||||
uiOrdering.add( &m_applyToAllCases );
|
||||
if ( !allSourceCasesAreEqualToDestinationCase() )
|
||||
{
|
||||
m_applyToAllCases = false;
|
||||
}
|
||||
m_applyToAllCases.uiCapability()->setUiReadOnly( !allSourceCasesAreEqualToDestinationCase() );
|
||||
uiOrdering.add( &m_additionalCasesType );
|
||||
uiOrdering.add( &m_additionalCaseGroup );
|
||||
m_additionalCaseGroup.uiCapability()->setUiHidden( m_additionalCasesType() != RimGridCalculation::AdditionalCasesType::GRID_CASE_GROUP );
|
||||
|
||||
caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup( "Cell Filter" );
|
||||
filterGroup->setCollapsedByDefault();
|
||||
@ -339,8 +354,8 @@ QList<caf::PdmOptionItemInfo> RimGridCalculation::calculateValueOptions( const c
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no input cases are defined, use the destination case to determine the grid size. This will enable use of expressions with
|
||||
// no input cases like "calculation := 1.0"
|
||||
// If no input cases are defined, use the destination case to determine the grid size. This will enable use of expressions
|
||||
// with no input cases like "calculation := 1.0"
|
||||
firstEclipseCase = m_destinationCase();
|
||||
}
|
||||
|
||||
@ -391,6 +406,20 @@ QList<caf::PdmOptionItemInfo> RimGridCalculation::calculateValueOptions( const c
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( &m_additionalCaseGroup == fieldNeedingOptions )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
if ( proj->activeOilField() && proj->activeOilField()->analysisModels() )
|
||||
{
|
||||
auto analysisModels = proj->activeOilField()->analysisModels();
|
||||
for ( RimIdenticalGridCaseGroup* cg : analysisModels->caseGroups() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( cg->name(), cg, false, cg->uiIconProvider() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
@ -410,6 +439,8 @@ void RimGridCalculation::initAfterRead()
|
||||
if ( m_destinationCase == nullptr ) m_destinationCase = gridVar->eclipseCase();
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_applyToAllCases_OBSOLETE ) m_additionalCasesType = RimGridCalculation::AdditionalCasesType::ALL_CASES;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -561,8 +592,8 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
|
||||
auto rigCaseCellResultsData = eclipseCaseData->results( porosityModel );
|
||||
if ( !rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) ) return {};
|
||||
|
||||
// Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as number of
|
||||
// active cells in the destination case. Active cells can be different between source and destination case.
|
||||
// Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as
|
||||
// number of active cells in the destination case. Active cells can be different between source and destination case.
|
||||
auto activeCellInfoDestination = destinationCase->eclipseCaseData()->activeCellInfo( porosityModel );
|
||||
auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices();
|
||||
|
||||
@ -972,9 +1003,9 @@ void RimGridCalculation::findAndEvaluateDependentCalculations( const std::vector
|
||||
{
|
||||
if ( dependentCalc == this ) continue;
|
||||
|
||||
// Propagate the settings for this calculation to the dependent calculation. This will allow changes on top level calculation to be
|
||||
// propagated to dependent calculations automatically. Do not trigger findAndEvaluateDependentCalculations() recursively, as all
|
||||
// dependent calculations are traversed in this function.
|
||||
// Propagate the settings for this calculation to the dependent calculation. This will allow changes on top level
|
||||
// calculation to be propagated to dependent calculations automatically. Do not trigger
|
||||
// findAndEvaluateDependentCalculations() recursively, as all dependent calculations are traversed in this function.
|
||||
|
||||
bool evaluateDependentCalculations = false;
|
||||
dependentCalc->calculateForCases( calculationCases, inputValueVisibilityFilter, timeSteps, evaluateDependentCalculations );
|
||||
|
@ -33,6 +33,7 @@ class RimEclipseCase;
|
||||
class RimGridView;
|
||||
class RigEclipseResultAddress;
|
||||
class RimEclipseResultAddress;
|
||||
class RimCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -50,6 +51,13 @@ public:
|
||||
USER_DEFINED
|
||||
};
|
||||
|
||||
enum class AdditionalCasesType
|
||||
{
|
||||
NONE,
|
||||
GRID_CASE_GROUP,
|
||||
ALL_CASES
|
||||
};
|
||||
|
||||
RimGridCalculation();
|
||||
|
||||
bool preCalculate() const override;
|
||||
@ -136,11 +144,15 @@ private:
|
||||
caf::PdmField<caf::AppEnum<DefaultValueType>> m_defaultValueType;
|
||||
caf::PdmField<double> m_defaultValue;
|
||||
caf::PdmPtrField<RimEclipseCase*> m_destinationCase;
|
||||
caf::PdmField<bool> m_applyToAllCases;
|
||||
|
||||
caf::PdmField<caf::AppEnum<AdditionalCasesType>> m_additionalCasesType;
|
||||
caf::PdmPtrField<RimCaseCollection*> m_additionalCaseGroup;
|
||||
|
||||
caf::PdmField<std::vector<int>> m_selectedTimeSteps;
|
||||
|
||||
caf::PdmProxyValueField<QString> m_nonVisibleResultText;
|
||||
caf::PdmChildField<RimEclipseResultAddress*> m_nonVisibleResultAddress;
|
||||
caf::PdmField<bool> m_editNonVisibleResultAddress;
|
||||
|
||||
caf::PdmField<bool> m_applyToAllCases_OBSOLETE;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user