From 5691333c61eecf0ffd619777d6b3702c85969361 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 May 2026 08:55:10 +0200 Subject: [PATCH] MSW Export: Add preference for improved MSW data structures and rename extraction methods --- .../Application/RiaPreferences.cpp | 15 ++++++++ .../Application/RiaPreferences.h | 3 ++ .../RicWellPathExportMswTableData.cpp | 34 +++++++++---------- .../RicWellPathExportMswTableData.h | 21 ++++++------ .../RicWellPathExportMswTableData-Test.cpp | 6 ++-- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index 3049f2365d..c5fca58370 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -211,6 +211,12 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitField( &m_useUndoRedo, "useUndoRedo", false, "Enable Undo/Redo for Property Editor changes" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useUndoRedo ); + CAF_PDM_InitField( &m_useImprovedMswDataStructures, + "useImprovedMswDataStructures", + false, + "Use Improved MSW Data Structures" + RiaDefines::betaFeaturePostfix() ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useImprovedMswDataStructures ); + CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolders, "plotTemplateFolders", "Plot Template Folder(s)" ); m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_maxPlotTemplateFoldersDepth, "MaxPlotTemplateFoldersDepth", 2, "Maximum Plot Template Folder Search Depth" ); @@ -391,6 +397,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& otherGroup->setCollapsedByDefault(); otherGroup->add( &holoLensDisableCertificateVerification ); otherGroup->add( &m_useUndoRedo ); + otherGroup->add( &m_useImprovedMswDataStructures ); caf::PdmUiGroup* importExportGroup = uiOrdering.addNewGroup( "Import and Export" ); importExportGroup->setCollapsedByDefault(); @@ -717,6 +724,14 @@ bool RiaPreferences::useUndoRedo() const return m_useUndoRedo(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferences::useImprovedMswDataStructures() const +{ + return m_useImprovedMswDataStructures(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index a33bcbad4c..53393234e7 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -73,6 +73,8 @@ public: bool useUndoRedo() const; + bool useImprovedMswDataStructures() const; + const QString& dateFormat() const; const QString& timeFormat() const; QString @@ -182,6 +184,7 @@ private: caf::PdmField m_timeFormat; caf::PdmField m_useUndoRedo; + caf::PdmField m_useImprovedMswDataStructures; caf::PdmField> m_guiTheme; diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp index 12cd55f725..52e395fcd9 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp @@ -19,6 +19,7 @@ #include "RicWellPathExportMswTableData.h" #include "RiaLogging.h" +#include "RiaPreferences.h" #include "RiaQStringFormatter.h" #include "MswExport/RicWellPathExportMswGeometryPath.h" @@ -71,28 +72,27 @@ std::expected CompletionType completionType, const std::optional& exportDate ) { - bool exportAsTree = true; // This can be made configurable if needed, but for now we will always export as tree structure to preserve - // the hierarchy of the well path segments and completions - - if ( exportAsTree ) + // Data prcessing for MSW has improved. Currently, there exist two code paths for extracting MSW data. The preference for using the + // legacy code path is controlled by the "Use Improved MSW Data Structures" preference (General tab, Other group). + bool useLegacy = !RiaPreferences::current()->useImprovedMswDataStructures(); + if ( useLegacy ) { - return extractSingleWellMswDataTree( eclipseCase, wellPath, exportCompletionsAfterMainBoreSegments, completionType, exportDate ); + return extractSingleWellMsw_Legacy( eclipseCase, wellPath, exportCompletionsAfterMainBoreSegments, completionType, exportDate ); } else { - return extractSingleWellMswDataGeometry( eclipseCase, wellPath, exportCompletionsAfterMainBoreSegments, completionType, exportDate ); + return extractSingleWellMsw( eclipseCase, wellPath, exportCompletionsAfterMainBoreSegments, completionType, exportDate ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::expected - RicWellPathExportMswTableData::extractSingleWellMswDataGeometry( RimEclipseCase* eclipseCase, - RimWellPath* wellPath, - bool exportCompletionsAfterMainBoreSegments, - CompletionType completionType, - const std::optional& exportDate ) +std::expected RicWellPathExportMswTableData::extractSingleWellMsw( RimEclipseCase* eclipseCase, + RimWellPath* wellPath, + bool exportCompletionsAfterMainBoreSegments, + CompletionType completionType, + const std::optional& exportDate ) { if ( !eclipseCase || !wellPath || eclipseCase->eclipseCaseData() == nullptr ) return std::unexpected( "Invalid eclipse case or well path provided" ); @@ -116,11 +116,11 @@ std::expected /// //-------------------------------------------------------------------------------------------------- std::expected - RicWellPathExportMswTableData::extractSingleWellMswDataTree( RimEclipseCase* eclipseCase, - RimWellPath* wellPath, - bool exportCompletionsAfterMainBoreSegments, - CompletionType completionType, - const std::optional& exportDate ) + RicWellPathExportMswTableData::extractSingleWellMsw_Legacy( RimEclipseCase* eclipseCase, + RimWellPath* wellPath, + bool exportCompletionsAfterMainBoreSegments, + CompletionType completionType, + const std::optional& exportDate ) { if ( !eclipseCase || !wellPath || eclipseCase->eclipseCaseData() == nullptr ) { diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h index 2e670db07c..3e7d870667 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h @@ -70,18 +70,17 @@ public: CompletionType completionType = CompletionType::ALL, const std::optional& exportDate = std::nullopt ); - static std::expected extractSingleWellMswDataTree( RimEclipseCase* eclipseCase, - RimWellPath* wellPath, - bool exportCompletionsAfterMainBoreSegments = true, - CompletionType completionType = CompletionType::ALL, - const std::optional& exportDate = std::nullopt ); + static std::expected extractSingleWellMsw_Legacy( RimEclipseCase* eclipseCase, + RimWellPath* wellPath, + bool exportCompletionsAfterMainBoreSegments = true, + CompletionType completionType = CompletionType::ALL, + const std::optional& exportDate = std::nullopt ); - static std::expected - extractSingleWellMswDataGeometry( RimEclipseCase* eclipseCase, - RimWellPath* wellPath, - bool exportCompletionsAfterMainBoreSegments = true, - CompletionType completionType = CompletionType::ALL, - const std::optional& exportDate = std::nullopt ); + static std::expected extractSingleWellMsw( RimEclipseCase* eclipseCase, + RimWellPath* wellPath, + bool exportCompletionsAfterMainBoreSegments = true, + CompletionType completionType = CompletionType::ALL, + const std::optional& exportDate = std::nullopt ); static CompletionType convertFromExportSettings( const class RicExportCompletionDataSettingsUi& settings ); diff --git a/ApplicationLibCode/UnitTests/RicWellPathExportMswTableData-Test.cpp b/ApplicationLibCode/UnitTests/RicWellPathExportMswTableData-Test.cpp index 8b4ba5843d..655f27c808 100644 --- a/ApplicationLibCode/UnitTests/RicWellPathExportMswTableData-Test.cpp +++ b/ApplicationLibCode/UnitTests/RicWellPathExportMswTableData-Test.cpp @@ -100,7 +100,7 @@ std::vector> extractSortedCells( // Parameterized integration tests: Tree mode vs Geometry mode for all MSW project files. // // The test loads a ResInsight project file, extracts well MSW data using both the tree-based -// (extractSingleWellMswDataTree) and geometry-based (extractSingleWellMswDataGeometry) +// (extractSingleWellMsw_Legacy) and geometry-based (extractSingleWellMsw) // algorithms, and verifies that both produce equivalent results for every well path: // // - The same set of reservoir cells in COMPSEGS (sorted {i,j,k,gridName} tuples) @@ -155,8 +155,8 @@ TEST_P( MswTreeVsGeometryTest, CompareTreeAndGeometryModes ) if ( !wellPath->isTopLevelWellPath() ) continue; - auto treeResult = RicWellPathExportMswTableData::extractSingleWellMswDataTree( eclipseCase, wellPath ); - auto geometryResult = RicWellPathExportMswTableData::extractSingleWellMswDataGeometry( eclipseCase, wellPath ); + auto treeResult = RicWellPathExportMswTableData::extractSingleWellMsw_Legacy( eclipseCase, wellPath ); + auto geometryResult = RicWellPathExportMswTableData::extractSingleWellMsw( eclipseCase, wellPath ); // If one mode fails, the other should fail too (no MSW data for this well path). if ( !treeResult.has_value() && !geometryResult.has_value() )