From 63fcc8a29fd3799d05c61bd3d1fee3d49bfc8c3a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 20 Jul 2025 18:08:37 +0200 Subject: [PATCH] Regression Test: Make sure the grid is opened when reading time steps No grid case curves was seen for ProjectFilesSmallTests\TestCase_RFT_PLT\RegressionTest.rsp --- .../Flow/RimWellPlotTools.cpp | 6 ++++++ .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 20 +++++++++++++------ .../ProjectDataModel/Flow/RimWellRftPlot.h | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 96be6e7a6d..8184a3aa37 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -579,6 +579,12 @@ std::vector pressureDepthData() //-------------------------------------------------------------------------------------------------- std::map> timeStepsMapFromGridCase( RimEclipseCase* gridCase ) { + if ( !gridCase ) return {}; + + // Make sure the grid model is opened. This is required to read out time step dates. If no 3D views are present, the grid model is not + // yet opened. + gridCase->openEclipseGridFile(); + const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); std::pair resultDataInfo = pressureResultDataInfo( eclipseCaseData ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 98fdf028ad..97095892ec 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -1194,6 +1194,20 @@ std::map RimWellRftPlot::findWellSources() //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::onLoadDataAndUpdate() { + if ( !m_isInitialized ) + { + // TODO: m_selectedSources and m_selectedTimeSteps are not stored in the project file, so we need to set them here + // to ensure that the plot is initialized with the correct sources and time steps. Refactor m_selectedSources and + // m_selectedTimeSteps to be stored in the project file, and disable storing of curves to the project file. This is a temporary + // solution to ensure that the plot is initialized correctly setSelectedSourcesFromCurves(); + // + // This function call was previously in initAfterRead, and triggered opening of the grid model. Moved here to allow 3D views to + // trigger open of grid model + + setSelectedSourcesFromCurves(); + m_isInitialized = true; + } + if ( m_isOnLoad ) { if ( plotCount() > 0 ) @@ -1246,12 +1260,6 @@ void RimWellRftPlot::initAfterRead() m_wellLogPlot_OBSOLETE = nullptr; } - // TODO: m_selectedSources and m_selectedTimeSteps are not stored in the project file, so we need to set them here - // to ensure that the plot is initialized with the correct sources and time steps. Refactor m_selectedSources and m_selectedTimeSteps to - // be stored in the project file, and disable storing of curves to the project file. This is a temporary solution to ensure that the - // plot is initialized correctly - setSelectedSourcesFromCurves(); - RimWellLogPlot::initAfterRead(); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h index 30aff12be7..1082e1e5ff 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -169,4 +169,5 @@ private: bool m_isOnLoad; caf::PdmChildField m_wellLogPlot_OBSOLETE; + bool m_isInitialized = false; };