diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicScheduleDataGenerator.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicScheduleDataGenerator.cpp index d8e007c0fa..bf0b3def7f 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicScheduleDataGenerator.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicScheduleDataGenerator.cpp @@ -243,14 +243,10 @@ QString RicScheduleDataGenerator::generateMswForWell( const RimWellEventTimeline } // Extract MSW data using the existing infrastructure - // Use timeStep = -1 to disable date filtering (similar to ignoreDates=true for COMPDAT) - // This ensures perforations created from events are included regardless of their custom start dates // Pass the export date to filter valve/perforation output based on their creation dates - int timeStep = -1; bool exportAfterMainBore = true; auto mswDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( &eclipseCase, &wellPath, - timeStep, exportAfterMainBore, RicWellPathExportMswTableData::CompletionType::ALL, date ); diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index efcb5aacda..c31da5a269 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -211,7 +211,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v if ( exportSettings.includePerforations ) { - auto exportDate = exportDateForTimeStep( *exportSettings.caseToApply, exportSettings.timeStep ); + auto exportDate = exportDateForTimeStep( exportSettings.caseToApply, exportSettings.timeStep ); std::vector perforationCompletionData = generatePerforationsCompdatValues( wellPathLateral, wellPathLateral->perforationIntervalCollection()->perforations(), @@ -385,7 +385,7 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::compu exportSettings.includePerforations = true; exportSettings.includeFractures = true; - auto exportDate = exportDateForTimeStep( *eclipseCase, timeStepIndex ); + auto exportDate = exportDateForTimeStep( eclipseCase, timeStepIndex ); completionsPerEclipseCell = generatePerforationsCompdatValues( wellPath, wellPath->perforationIntervalCollection()->perforations(), exportSettings, exportDate ); @@ -1812,10 +1812,12 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::compl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::optional RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( const RimEclipseCase& eclipseCase, +std::optional RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( const RimEclipseCase* eclipseCase, size_t timeStepIndex ) { - auto timeSteps = eclipseCase.timeStepDates(); + if ( !eclipseCase ) return std::nullopt; + + auto timeSteps = eclipseCase->timeStepDates(); if ( timeStepIndex < timeSteps.size() ) return timeSteps[timeStepIndex]; return std::nullopt; } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 823d5f55fc..d501010f8a 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -132,6 +132,8 @@ public: gsl::not_null wellPath, const QString& gridName = "" ); + static std::optional exportDateForTimeStep( const RimEclipseCase* eclipseCase, size_t timeStepIndex ); + private: static std::vector generatePerforationsCompdatValues( gsl::not_null wellPath, const std::vector& intervals, @@ -197,6 +199,4 @@ private: static void exportCarfinForTemporaryLgrs( const RimEclipseCase* sourceCase, const QString& folder ); static RimWellPath* topLevelWellPath( const RigCompletionData& completion ); - - static std::optional exportDateForTimeStep( const RimEclipseCase& eclipseCase, size_t timeStepIndex ); }; diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 4a75e530d8..fd9bac7379 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -21,6 +21,7 @@ #include "RiaLogging.h" #include "RicExportCompletionDataSettingsUi.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" #include "RicWellPathExportCompletionsFileTools.h" #include "RicWellPathExportMswTableData.h" @@ -43,7 +44,7 @@ namespace internal //-------------------------------------------------------------------------------------------------- RigMswUnifiedData extractUnifiedMswData( RimEclipseCase* eclipseCase, - int timeStep, + const std::optional& exportDate, const std::vector& wellPaths, RicWellPathExportMswTableData::CompletionType completionType = RicWellPathExportMswTableData::CompletionType::ALL ) { @@ -53,7 +54,7 @@ RigMswUnifiedData { bool exportAfterMainbore = true; auto wellData = - RicWellPathExportMswTableData::extractSingleWellMswData( eclipseCase, wellPath, timeStep, exportAfterMainbore, completionType ); + RicWellPathExportMswTableData::extractSingleWellMswData( eclipseCase, wellPath, exportAfterMainbore, completionType, exportDate ); if ( wellData.has_value() ) { unifiedData.addWellData( std::move( wellData.value() ) ); @@ -70,8 +71,9 @@ void exportUnifiedMswData( const RicExportCompletionDataSettingsUi& exportSettin const QString& exportFolder, const std::vector& wellPaths ) { - auto completionType = RicWellPathExportMswTableData::convertFromExportSettings( exportSettings ); - RigMswUnifiedData unifiedData = extractUnifiedMswData( exportSettings.caseToApply, exportSettings.timeStep, wellPaths, completionType ); + auto completionType = RicWellPathExportMswTableData::convertFromExportSettings( exportSettings ); + auto exportDate = RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( exportSettings.caseToApply, exportSettings.timeStep ); + RigMswUnifiedData unifiedData = extractUnifiedMswData( exportSettings.caseToApply, exportDate, wellPaths, completionType ); if ( unifiedData.isEmpty() ) { @@ -140,11 +142,13 @@ void exportSplitMswData( const RicExportCompletionDataSettingsUi& exportSettings for ( const auto& wellPath : wellPaths ) { auto completionType = RicWellPathExportMswTableData::convertFromExportSettings( exportSettings ); + auto exportDate = + RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( exportSettings.caseToApply, exportSettings.timeStep ); auto wellDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( exportSettings.caseToApply, wellPath, - exportSettings.timeStep, exportSettings.exportCompletionWelspecAfterMainBore(), - completionType ); + completionType, + exportDate ); if ( !wellDataResult.has_value() ) { diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp index f34b6747c2..cb5dd1d320 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.cpp @@ -65,7 +65,6 @@ constexpr double VALVE_SEGMENT_LENGTH = 0.1; std::expected RicWellPathExportMswTableData::extractSingleWellMswData( RimEclipseCase* eclipseCase, RimWellPath* wellPath, - int timeStep, bool exportCompletionsAfterMainBoreSegments, CompletionType completionType, const std::optional& exportDate ) @@ -92,7 +91,7 @@ std::expected if ( !generateWellSegmentsForMswExportInfo( eclipseCase, wellPath, createSegmentsForPerforations, - timeStep, + exportDate, initialMD, cellIntersections, &exportInfo, @@ -197,12 +196,11 @@ void RicWellPathExportMswTableData::generateFishbonesMswExportInfoForWell( const auto cellIntersections = generateCellSegments( eclipseCase, wellPath ); double initialMD = computeIntitialMeasuredDepth( eclipseCase, wellPath, mswParameters, cellIntersections ); - int timeStep = 0; const bool createSegmentsForPerforations = true; if ( !generateWellSegmentsForMswExportInfo( eclipseCase, wellPath, createSegmentsForPerforations, - timeStep, + std::nullopt, initialMD, cellIntersections, exportInfo, @@ -549,11 +547,11 @@ bool RicWellPathExportMswTableData::appendFracturesMswExportInfo( RimEclipseCase //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathExportMswTableData::generateWellSegmentsForMswExportInfo( const RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - bool createSegmentsForPerforations, - int timeStep, - double initialMD, +bool RicWellPathExportMswTableData::generateWellSegmentsForMswExportInfo( const RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + bool createSegmentsForPerforations, + const std::optional& exportDate, + double initialMD, const std::vector& cellIntersections, gsl::not_null exportInfo, gsl::not_null branch ) @@ -594,7 +592,7 @@ bool RicWellPathExportMswTableData::generateWellSegmentsForMswExportInfo( const bool foundSubGridIntersections = false; - createWellPathSegments( branch, filteredIntersections, perforationIntervals, wellPath, timeStep, eclipseCase, &foundSubGridIntersections ); + createWellPathSegments( branch, filteredIntersections, perforationIntervals, wellPath, exportDate, eclipseCase, &foundSubGridIntersections ); createValveCompletions( branch, perforationIntervals, wellPath, exportInfo->unitSystem() ); @@ -620,7 +618,7 @@ bool RicWellPathExportMswTableData::generateWellSegmentsForMswExportInfo( const if ( generateWellSegmentsForMswExportInfo( eclipseCase, childWellPath, createSegmentsForPerforations, - timeStep, + exportDate, tieInOnParentWellPath, childCellIntersections, exportInfo, @@ -805,7 +803,7 @@ void RicWellPathExportMswTableData::createWellPathSegments( gsl::not_null& cellSegmentIntersections, const std::vector& perforationIntervals, const RimWellPath* wellPath, - int timeStep, + const std::optional& exportDate, const RimEclipseCase* eclipseCase, bool* foundSubGridIntersections ) { @@ -837,7 +835,7 @@ void RicWellPathExportMswTableData::createWellPathSegments( gsl::not_null( interval->name(), wellPath, overlapStart, overlapStartTVD, interval ); std::vector completionData = - generatePerforationIntersections( wellPath, interval, timeStep, eclipseCase ); + generatePerforationIntersections( wellPath, interval, exportDate, eclipseCase ); assignPerforationIntersections( completionData, intervalCompletion.get(), cellIntInfo, @@ -1423,7 +1421,7 @@ void RicWellPathExportMswTableData::assignFractureCompletionsToCellSegment( cons std::vector RicWellPathExportMswTableData::generatePerforationIntersections( gsl::not_null wellPath, gsl::not_null perforationInterval, - int timeStep, + const std::optional& exportDate, gsl::not_null eclipseCase ) { std::vector completionData; @@ -1431,8 +1429,7 @@ std::vector auto wellPathGeometry = wellPath->wellPathGeometry(); CVF_ASSERT( wellPathGeometry ); - bool hasDate = (size_t)timeStep < eclipseCase->timeStepDates().size(); - bool isActive = !hasDate || perforationInterval->isActiveOnDate( eclipseCase->timeStepDates()[timeStep] ); + bool isActive = !exportDate.has_value() || perforationInterval->isActiveOnDate( *exportDate ); if ( wellPath->perforationIntervalCollection()->isChecked() && perforationInterval->isChecked() && isActive ) { diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h index cfba241d70..fb3a45ad2c 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h @@ -66,7 +66,6 @@ public: // The intention is to extract MSW data from a single well. Any handling of multiple wells is supposed to be managed in a different class static std::expected extractSingleWellMswData( RimEclipseCase* eclipseCase, RimWellPath* wellPath, - int timeStep, bool exportCompletionsAfterMainBoreSegments = true, CompletionType completionType = CompletionType::ALL, const std::optional& exportDate = std::nullopt ); @@ -84,7 +83,7 @@ private: static bool generateWellSegmentsForMswExportInfo( const RimEclipseCase* eclipseCase, const RimWellPath* wellPath, bool createSegmentsForPerforations, - int timeStep, + const std::optional& exportDate, double initialMD, const std::vector& cellIntersections, gsl::not_null exportInfo, @@ -125,7 +124,7 @@ private: const std::vector& cellSegmentIntersections, const std::vector& perforationIntervals, const RimWellPath* wellPath, - int timeStep, + const std::optional& exportDate, const RimEclipseCase* eclipseCase, bool* foundSubGridIntersections ); @@ -163,7 +162,7 @@ private: static std::vector generatePerforationIntersections( gsl::not_null wellPath, gsl::not_null perforationInterval, - int timeStep, + const std::optional& exportDate, gsl::not_null eclipseCase ); static void assignPerforationIntersections( const std::vector& completionData, diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimMswSegmentCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimMswSegmentCollection.cpp index 7c88989ee6..4060bbe720 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimMswSegmentCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimMswSegmentCollection.cpp @@ -20,6 +20,7 @@ #include "RiaLogging.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" #include "CompletionExportCommands/RicWellPathExportMswTableData.h" #include "CompletionsMsw/RigMswTableData.h" @@ -167,8 +168,12 @@ void RimMswSegmentCollection::updateSegments( RimEclipseCase* eclipseCase ) return; } - constexpr int timeStep = 0; - auto tableDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( eclipseCase, wellPath, timeStep ); + auto exportDate = RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( eclipseCase, 0 ); + auto tableDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( eclipseCase, + wellPath, + true, + RicWellPathExportMswTableData::CompletionType::ALL, + exportDate ); if ( !tableDataResult.has_value() ) { diff --git a/ApplicationLibCode/ProjectDataModel/Jobs/RimOpmFlowJob.cpp b/ApplicationLibCode/ProjectDataModel/Jobs/RimOpmFlowJob.cpp index cd7e0b44a1..148f12ee37 100644 --- a/ApplicationLibCode/ProjectDataModel/Jobs/RimOpmFlowJob.cpp +++ b/ApplicationLibCode/ProjectDataModel/Jobs/RimOpmFlowJob.cpp @@ -1093,7 +1093,12 @@ int RimOpmFlowJob::mergeMswData( int mergePosition ) { const int failure = -1; - auto mswDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( m_eclipseCase(), m_wellPath(), 0 ); + auto exportDate = RicWellPathExportCompletionDataFeatureImpl::exportDateForTimeStep( m_eclipseCase(), 0 ); + auto mswDataResult = RicWellPathExportMswTableData::extractSingleWellMswData( m_eclipseCase(), + m_wellPath(), + true, + RicWellPathExportMswTableData::CompletionType::ALL, + exportDate ); if ( !mswDataResult.has_value() ) { RiaLogging::error( QString::fromStdString( mswDataResult.error() ) );