From 186992ebb6b4a0abfbf54ad3eca6eeb647d7f28f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 3 Nov 2025 14:26:51 +0100 Subject: [PATCH] Improves relative permeability plot display Enhances the relative permeability plot by: - Adding support for SATNUM and IMBNUM result display in cell reference information. - Disabling the imbibition curve selection by default and enabling it dynamically based on the IMBNUM value. - Removing the `satnum` argument from `calculateRelPermCurves` as it's no longer needed. --- .../Application/RiaResultNames.cpp | 16 ++++++ .../Application/RiaResultNames.h | 3 + .../RigFlowDiagSolverInterface.cpp | 2 +- .../RigFlowDiagSolverInterface.h | 2 +- .../UserInterface/RiuPvtPlotUpdater.cpp | 7 +-- .../RiuRelativePermeabilityPlotPanel.cpp | 18 +++++- .../RiuRelativePermeabilityPlotPanel.h | 15 +++-- .../RiuRelativePermeabilityPlotUpdater.cpp | 55 +++++++++++-------- .../RiuRelativePermeabilityPlotUpdater.h | 6 +- 9 files changed, 83 insertions(+), 41 deletions(-) diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index 348917de64..d71dfa531b 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -668,6 +668,22 @@ std::set RiaResultNames::nncResultNames() combinedRiTranResultName() }; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::satnumResult() +{ + return "SATNUM"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::imbnumResult() +{ + return "IMBNUM"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaResultNames.h b/ApplicationLibCode/Application/RiaResultNames.h index 740e7fed02..a0a00f5277 100644 --- a/ApplicationLibCode/Application/RiaResultNames.h +++ b/ApplicationLibCode/Application/RiaResultNames.h @@ -120,6 +120,9 @@ QString formationBinaryAllanResultName(); QString formationAllanResultName(); std::set nncResultNames(); +QString satnumResult(); +QString imbnumResult(); + // List of well path derived results std::vector wbsAngleResultNames(); std::vector wbsDerivedResultNames(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 75c4535704..a1a6acbb62 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -661,7 +661,7 @@ RigFlowDiagDefines::FlowCharacteristicsResultFrame //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigFlowDiagSolverInterface::calculateRelPermCurves( size_t activeCellIndex, int satnum ) +std::vector RigFlowDiagSolverInterface::calculateRelPermCurves( size_t activeCellIndex ) { using RawCurve = Opm::ECLSaturationFunc::RawCurve; diff --git a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.h b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.h index 06ac585fe9..b0e49271a8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.h +++ b/ApplicationLibCode/ReservoirDataModel/RigFlowDiagSolverInterface.h @@ -79,7 +79,7 @@ public: const std::vector& selected_cell_indices, double max_pv_fraction ); - std::vector calculateRelPermCurves( size_t activeCellIndex, int satnum ); + std::vector calculateRelPermCurves( size_t activeCellIndex ); std::vector calculatePvtCurves( RigFlowDiagDefines::PvtCurveType pvtCurveType, int pvtNum ); bool calculatePvtDynamicPropertiesFvf( int pvtNum, double pressure, double rs, double rv, double* bo, double* bg ); diff --git a/ApplicationLibCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationLibCode/UserInterface/RiuPvtPlotUpdater.cpp index 9e4191758c..108d8e553f 100644 --- a/ApplicationLibCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationLibCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -149,11 +149,8 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseResultDefinition &viscosityDynProps.mu_o, &viscosityDynProps.mu_g ); - QString cellRefText = RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( eclipseCaseData, - gridIndex, - gridLocalCellIndex, - "PVTNUM", - cellPvtNumDouble ); + QString cellRefText = RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex ); + cellRefText += QString( ", PVTNUM: %1" ).arg( cellPvtNum ); m_targetPlotPanel->setPlotData( eclipseCaseData->unitsType(), fvfCurveArr, diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp index 65f5824390..52a58f3c74 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp @@ -163,7 +163,7 @@ RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel( QWidget* par m_showDrainageCheckBox = new QCheckBox( "Drainage" ); m_showImbibitionCheckBox = new QCheckBox( "Imbibition" ); m_showDrainageCheckBox->setChecked( true ); - m_showImbibitionCheckBox->setChecked( true ); + m_showImbibitionCheckBox->setChecked( false ); curveSetLayout->addWidget( m_showDrainageCheckBox ); curveSetLayout->addWidget( m_showImbibitionCheckBox ); @@ -278,6 +278,22 @@ void RiuRelativePermeabilityPlotPanel::setPlotData( RiaDefines::EclipseUnitSyste plotUiSelectedCurves(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuRelativePermeabilityPlotPanel::enableImbibitionCurveSelection( bool enable ) +{ + if ( !enable ) + { + m_showImbibitionCheckBox->setChecked( false ); + m_showImbibitionCheckBox->setDisabled( true ); + } + else + { + m_showImbibitionCheckBox->setDisabled( false ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h index 8479ee8b81..cf6e8673cc 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotPanel.h @@ -51,12 +51,15 @@ public: RiuRelativePermeabilityPlotPanel( QWidget* parent ); ~RiuRelativePermeabilityPlotPanel() override; - void setPlotData( RiaDefines::EclipseUnitSystem unitSystem, - const std::vector& relPermCurves, - double swat, - double sgas, - const QString& caseName, - const QString& cellReferenceText ); + void setPlotData( RiaDefines::EclipseUnitSystem unitSystem, + const std::vector& relPermCurves, + double swat, + double sgas, + const QString& caseName, + const QString& cellReferenceText ); + + void enableImbibitionCurveSelection( bool enable ); + void clearPlot(); RiuRelativePermeabilityPlotUpdater* plotUpdater(); void applyFontSizes( bool replot ); diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 0c41c76316..2eb50ceeef 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -112,7 +112,10 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::swat() ) ); cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::sgas() ) ); - cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, "SATNUM" ) ); + cellResultsData->ensureKnownResultLoaded( + RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::satnumResult() ) ); + cellResultsData->ensureKnownResultLoaded( + RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::imbnumResult() ) ); // Fetch SWAT and SGAS cell values for the selected cell cvf::ref swatAccessor = @@ -135,26 +138,40 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips RiaDefines::PorosityModelType::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, - "SATNUM" ) ); + RiaResultNames::satnumResult() ) ); - if ( satnumAccessor.isNull() ) - { - QString text = QString( "Could not read SATNUM value, not able to create relative permeability curves." ); - RiaLogging::error( text ); + cvf::ref imbnumAccessor = + RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, + gridIndex, + RiaDefines::PorosityModelType::MATRIX_MODEL, + timeStepIndex, + RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, + RiaResultNames::imbnumResult() ) ); - return false; - } - - const double cellSWAT = swatAccessor.notNull() ? swatAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL; - const double cellSGAS = sgasAccessor.notNull() ? sgasAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL; - const int cellSATNUM = satnumAccessor->cellScalar( gridLocalCellIndex ); + const double cellSWAT = swatAccessor.notNull() ? swatAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL; + const double cellSGAS = sgasAccessor.notNull() ? sgasAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL; std::vector relPermCurveArr = - eclipseResultCase->flowDiagSolverInterface()->calculateRelPermCurves( activeCellIndex, cellSATNUM ); + eclipseResultCase->flowDiagSolverInterface()->calculateRelPermCurves( activeCellIndex ); - QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, "SATNUM", cellSATNUM ); - QString caseName = eclipseResultCase->caseUserDescription(); + QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex ); + if ( satnumAccessor.notNull() ) + { + const int cellSATNUM = satnumAccessor->cellScalar( gridLocalCellIndex ); + cellRefText += QString( ", SATNUM: %1" ).arg( cellSATNUM ); + } + + if ( imbnumAccessor.notNull() ) + { + const int cellIMBNUM = imbnumAccessor->cellScalar( gridLocalCellIndex ); + cellRefText += QString( ", IMBNUM: %1" ).arg( cellIMBNUM ); + } + + QString caseName = eclipseResultCase->caseUserDescription(); + + const bool enableImbibitionCurveSelection = ( imbnumAccessor.notNull() && imbnumAccessor->cellScalar( gridLocalCellIndex ) > 0 ); + m_targetPlotPanel->enableImbibitionCurveSelection( enableImbibitionCurveSelection ); m_targetPlotPanel->setPlotData( eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, caseName, cellRefText ); return true; @@ -169,9 +186,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips //-------------------------------------------------------------------------------------------------- QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, - size_t gridLocalCellIndex, - const QString& valueName, - double cellValue ) + size_t gridLocalCellIndex ) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; @@ -196,10 +211,6 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const Ri { retText = QString( "LGR %1, Cell: [%2, %3, %4]" ).arg( gridIndex ).arg( i ).arg( j ).arg( k ); } - if ( cellValue != HUGE_VAL ) - { - retText += QString( " (%1=%2)" ).arg( valueName ).arg( cellValue ); - } return retText; } diff --git a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h index 109415da40..11c2fbe5b7 100644 --- a/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h +++ b/ApplicationLibCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h @@ -34,11 +34,7 @@ class RiuRelativePermeabilityPlotUpdater : public RiuPlotUpdater public: RiuRelativePermeabilityPlotUpdater( RiuRelativePermeabilityPlotPanel* targetPlotPanel ); - static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, - size_t gridIndex, - size_t gridLocalCellIndex, - const QString& valueName, - double cellValue ); + static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex ); protected: void clearPlot() override;