From 3fa4986f37d1e6078f72a71d57de33551e96a689 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 30 Apr 2021 13:51:15 +0200 Subject: [PATCH] #6878 Export Completion: Add custom file name --- .../RicExportCompletionDataSettingsUi.cpp | 21 ++ .../RicExportCompletionDataSettingsUi.h | 11 +- .../RicMswTableFormatterTools.cpp | 115 +++------ .../RicMswTableFormatterTools.h | 2 +- ...ellPathExportCompletionDataFeatureImpl.cpp | 4 +- .../RicWellPathExportMswCompletionsImpl.cpp | 219 +++++++++++++----- .../RicWellPathExportMswCompletionsImpl.h | 3 + 7 files changed, 235 insertions(+), 140 deletions(-) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 35f3a7b00e..653582a1af 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -123,6 +123,9 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() "", "" ); + CAF_PDM_InitField( &m_useCustomFileName, "UseCustomFileName", false, "Use Custom Filename", "", "", "" ); + CAF_PDM_InitField( &m_customFileName, "CustomFileName", {}, "Custom Filename", "", "", "" ); + m_displayForSimWell = true; m_fracturesEnabled = true; @@ -226,6 +229,16 @@ bool RicExportCompletionDataSettingsUi::exportCompletionWelspecAfterMainBore() c return m_completionWelspecAfterMainBore(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicExportCompletionDataSettingsUi::customFileName() const +{ + if ( m_useCustomFileName ) return m_customFileName(); + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -349,6 +362,14 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering( QString uiConfigName, group->add( &fileSplit ); group->add( &m_reportCompletionTypesSeparately ); group->add( &folder ); + + if ( fileSplit() == UNIFIED_FILE ) + { + group->add( &m_useCustomFileName ); + + group->add( &m_customFileName ); + m_customFileName.uiCapability()->setUiReadOnly( !m_useCustomFileName ); + } } { diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 973cd9b152..75d0da3963 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -100,6 +100,8 @@ public: bool exportWelspec() const; bool exportCompletionWelspecAfterMainBore() const; + QString customFileName() const; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; protected: @@ -111,9 +113,12 @@ protected: private: caf::PdmField m_reportCompletionTypesSeparately; - caf::PdmField m_exportDataSourceAsComment; - caf::PdmField m_exportWelspec; - caf::PdmField m_completionWelspecAfterMainBore; + + caf::PdmField m_exportDataSourceAsComment; + caf::PdmField m_exportWelspec; + caf::PdmField m_completionWelspecAfterMainBore; + caf::PdmField m_useCustomFileName; + caf::PdmField m_customFileName; bool m_displayForSimWell; bool m_fracturesEnabled; diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.cpp index b622693e63..ceb8124022 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.cpp @@ -220,7 +220,9 @@ void RicMswTableFormatterTools::writeWelsegsCompletionCommentHeader( RifTextData //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicMswTableFormatterTools::generateCompsegTables( RifTextDataTableFormatter& formatter, RicMswExportInfo& exportInfo ) +void RicMswTableFormatterTools::generateCompsegTables( RifTextDataTableFormatter& formatter, + RicMswExportInfo& exportInfo, + bool exportLgrData ) { /* * TODO: Creating the regular perforation COMPSEGS table should come in here, before the others @@ -229,94 +231,43 @@ void RicMswTableFormatterTools::generateCompsegTables( RifTextDataTableFormatter std::set intersectedCells; - { - std::set perforationTypes = { RigCompletionData::PERFORATION, - RigCompletionData::PERFORATION_ICD, - RigCompletionData::PERFORATION_ICV, - RigCompletionData::PERFORATION_AICD }; + std::set perforationTypes = { RigCompletionData::PERFORATION, + RigCompletionData::PERFORATION_ICD, + RigCompletionData::PERFORATION_ICV, + RigCompletionData::PERFORATION_AICD }; - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - false, - perforationTypes, - &headerGenerated, - &intersectedCells ); + std::set fishbonesTypes = { RigCompletionData::FISHBONES_ICD, + RigCompletionData::FISHBONES }; - if ( headerGenerated ) formatter.tableCompleted(); - } - - if ( exportInfo.hasSubGridIntersections() ) - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - true, - perforationTypes, - &headerGenerated, - &intersectedCells ); - if ( headerGenerated ) formatter.tableCompleted(); - } - } + std::set fractureTypes = { RigCompletionData::FRACTURE }; { - std::set fishbonesTypes = { RigCompletionData::FISHBONES_ICD, - RigCompletionData::FISHBONES }; - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - false, - fishbonesTypes, - &headerGenerated, - &intersectedCells ); - if ( headerGenerated ) formatter.tableCompleted(); - } - if ( exportInfo.hasSubGridIntersections() ) - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - true, - fishbonesTypes, - &headerGenerated, - &intersectedCells ); - if ( headerGenerated ) formatter.tableCompleted(); - } - } + bool headerGenerated = false; + generateCompsegTable( formatter, + exportInfo, + exportInfo.mainBoreBranch(), + exportLgrData, + perforationTypes, + &headerGenerated, + &intersectedCells ); - { - std::set fractureTypes = { RigCompletionData::FRACTURE }; + generateCompsegTable( formatter, + exportInfo, + exportInfo.mainBoreBranch(), + exportLgrData, + fishbonesTypes, + &headerGenerated, + &intersectedCells ); - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - false, - fractureTypes, - &headerGenerated, - &intersectedCells ); - if ( headerGenerated ) formatter.tableCompleted(); - } + generateCompsegTable( formatter, + exportInfo, + exportInfo.mainBoreBranch(), + exportLgrData, + fractureTypes, + &headerGenerated, + &intersectedCells ); - if ( exportInfo.hasSubGridIntersections() ) - { - bool headerGenerated = false; - generateCompsegTable( formatter, - exportInfo, - exportInfo.mainBoreBranch(), - true, - fractureTypes, - &headerGenerated, - &intersectedCells ); - if ( headerGenerated ) formatter.tableCompleted(); - } + if ( headerGenerated ) formatter.tableCompleted(); } } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.h index 7512b1dc1a..6b73014f09 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicMswTableFormatterTools.h @@ -97,7 +97,7 @@ void writeCompletionsForSegment( gsl::not_null outletSegme void writeWelsegsCompletionCommentHeader( RifTextDataTableFormatter& formatter, RigCompletionData::CompletionType completionType ); -void generateCompsegTables( RifTextDataTableFormatter& formatter, RicMswExportInfo& exportInfo ); +void generateCompsegTables( RifTextDataTableFormatter& formatter, RicMswExportInfo& exportInfo, bool exportLgrData ); void generateCompsegTable( RifTextDataTableFormatter& formatter, RicMswExportInfo& exportInfo, diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 26cff6eb29..5c5aadcbcd 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -287,7 +287,9 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v progress.setProgressDescription( "Write Export Files" ); if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE ) { - QString fileName = QString( "UnifiedCompletions_%1" ).arg( eclipseCaseName ); + QString fileName = exportSettings.customFileName(); + if ( fileName.isEmpty() ) fileName = QString( "UnifiedCompletions_%1" ).arg( eclipseCaseName ); + sortAndExportCompletionsToFile( exportSettings.caseToApply, exportSettings.folder, fileName, diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index c0523052ce..10838be58d 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -66,17 +66,27 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( const std::vector& wellPaths ) { std::shared_ptr unifiedExportFile; + std::shared_ptr unifiedLgrExportFile; if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::UNIFIED_FILE ) { - QString unifiedFileName = - QString( "UnifiedCompletions_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() ); - unifiedExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, unifiedFileName ); + QString fileName; + + if ( !exportSettings.customFileName().isEmpty() ) + fileName = exportSettings.customFileName() + "_MSW"; + else + fileName = QString( "UnifiedCompletions_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() ); + + unifiedExportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + + QString lgrFileName = fileName + "_LGR"; + unifiedLgrExportFile = + RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, lgrFileName ); } for ( const auto& wellPath : wellPaths ) { std::shared_ptr unifiedWellPathFile; + std::shared_ptr unifiedLgrWellPathFile; auto allCompletions = wellPath->allCompletionsRecursively(); @@ -98,17 +108,27 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( .arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() ); unifiedWellPathFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, wellFileName ); + unifiedLgrWellPathFile = + RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, wellFileName + "_LGR" ); } { // Always use perforation functions to export well segments along well path. // If no perforations are present, skip Perforation from file name - std::shared_ptr perforationsExportFile; + std::shared_ptr exportFile; + std::shared_ptr lgrExportFile; + if ( unifiedExportFile ) - perforationsExportFile = unifiedExportFile; + { + exportFile = unifiedExportFile; + lgrExportFile = unifiedLgrExportFile; + } else if ( unifiedWellPathFile ) - perforationsExportFile = unifiedWellPathFile; + { + exportFile = unifiedWellPathFile; + lgrExportFile = unifiedLgrWellPathFile; + } else { bool anyPerforationsPresent = @@ -122,11 +142,13 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( QString fileName = QString( "%1_%2MSW_%3" ) .arg( wellPath->name(), perforationText, exportSettings.caseToApply->caseUserDescription() ); - perforationsExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + lgrExportFile = + RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" ); } exportWellSegmentsForPerforations( exportSettings.caseToApply, - perforationsExportFile, + exportFile, + lgrExportFile, wellPath, exportSettings.timeStep, exportSettings.exportDataSourceAsComment(), @@ -135,20 +157,30 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( if ( exportFractures ) { - std::shared_ptr fractureExportFile; + std::shared_ptr exportFile; + std::shared_ptr lgrExportFile; + if ( unifiedExportFile ) - fractureExportFile = unifiedExportFile; + { + exportFile = unifiedExportFile; + lgrExportFile = unifiedLgrExportFile; + } else if ( unifiedWellPathFile ) - fractureExportFile = unifiedWellPathFile; + { + exportFile = unifiedWellPathFile; + lgrExportFile = unifiedLgrWellPathFile; + } else { QString fileName = QString( "%1_Fracture_MSW_%2" ).arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() ); - fractureExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + lgrExportFile = + RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" ); } exportWellSegmentsForFractures( exportSettings.caseToApply, - fractureExportFile, + exportFile, + lgrExportFile, wellPath, exportSettings.exportDataSourceAsComment(), exportSettings.exportCompletionWelspecAfterMainBore() ); @@ -156,20 +188,30 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( if ( exportFishbones ) { - std::shared_ptr fishbonesExportFile; + std::shared_ptr exportFile; + std::shared_ptr lgrExportFile; + if ( unifiedExportFile ) - fishbonesExportFile = unifiedExportFile; + { + exportFile = unifiedExportFile; + lgrExportFile = unifiedLgrExportFile; + } else if ( unifiedWellPathFile ) - fishbonesExportFile = unifiedWellPathFile; + { + exportFile = unifiedWellPathFile; + lgrExportFile = unifiedLgrWellPathFile; + } else { QString fileName = QString( "%1_Fishbones_MSW_%2" ).arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() ); - fishbonesExportFile = - RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); + lgrExportFile = + RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" ); } exportWellSegmentsForFishbones( exportSettings.caseToApply, - fishbonesExportFile, + exportFile, + lgrExportFile, wellPath, exportSettings.exportDataSourceAsComment(), exportSettings.exportCompletionWelspecAfterMainBore() ); @@ -182,6 +224,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, int timeStep, bool exportDataSourceAsComment, @@ -193,8 +236,8 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( Rim if ( !mswParameters ) return; - double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first intersection - // with active grid, or user defined value. + double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first + // intersection with active grid, or user defined value. auto cellIntersections = generateCellSegments( eclipseCase, wellPath, mswParameters, &initialMD ); @@ -216,18 +259,36 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( Rim assignBranchNumbersToBranch( eclipseCase, &exportInfo, exportInfo.mainBoreBranch(), &branchNumber ); - QTextStream stream( exportFile.get() ); - RifTextDataTableFormatter formatter( stream ); + { + QTextStream stream( exportFile.get() ); + RifTextDataTableFormatter formatter( stream ); - double maxSegmentLength = mswParameters->maxSegmentLength(); + double maxSegmentLength = mswParameters->maxSegmentLength(); - RicMswTableFormatterTools::generateWelsegsTable( formatter, - exportInfo, - maxSegmentLength, - completionSegmentsAfterMainBore ); - RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo ); - RicMswTableFormatterTools::generateWsegvalvTable( formatter, exportInfo ); - RicMswTableFormatterTools::generateWsegAicdTable( formatter, exportInfo ); + RicMswTableFormatterTools::generateWelsegsTable( formatter, + exportInfo, + maxSegmentLength, + completionSegmentsAfterMainBore ); + bool exportLgrData = false; + RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo, exportLgrData ); + RicMswTableFormatterTools::generateWsegvalvTable( formatter, exportInfo ); + RicMswTableFormatterTools::generateWsegAicdTable( formatter, exportInfo ); + } + + if ( exportInfo.hasSubGridIntersections() ) + { + QTextStream stream( lgrExportFile.get() ); + RifTextDataTableFormatter formatter( stream ); + + double maxSegmentLength = mswParameters->maxSegmentLength(); + + RicMswTableFormatterTools::generateWelsegsTable( formatter, + exportInfo, + maxSegmentLength, + completionSegmentsAfterMainBore ); + bool exportLgrData = true; + RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo, exportLgrData ); + } } } @@ -236,6 +297,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( Rim //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, bool exportDataSourceAsComment, bool completionSegmentsAfterMainBore ) @@ -253,8 +315,8 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEcl if ( !mswParameters ) return; - double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first intersection - // with active grid, or user defined value. + double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first + // intersection with active grid, or user defined value. auto cellIntersections = generateCellSegments( eclipseCase, wellPath, mswParameters, &initialMD ); @@ -274,14 +336,40 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEcl int branchNumber = 1; assignBranchNumbersToBranch( eclipseCase, &exportInfo, exportInfo.mainBoreBranch(), &branchNumber ); - QTextStream stream( exportFile.get() ); - RifTextDataTableFormatter formatter( stream ); - formatter.setOptionalComment( exportDataSourceAsComment ); + auto doExport = []( RifTextDataTableFormatter& formatter, + bool exportDataSourceAsComment, + RicMswExportInfo& exportInfo, + const RimWellPath* wellPath, + bool completionSegmentsAfterMainBore, + bool exportLgrData ) { + formatter.setOptionalComment( exportDataSourceAsComment ); - double maxSegmentLength = wellPath->mswCompletionParameters()->maxSegmentLength(); + double maxSegmentLength = wellPath->mswCompletionParameters()->maxSegmentLength(); - RicMswTableFormatterTools::generateWelsegsTable( formatter, exportInfo, maxSegmentLength, completionSegmentsAfterMainBore ); - RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo ); + RicMswTableFormatterTools::generateWelsegsTable( formatter, + exportInfo, + maxSegmentLength, + completionSegmentsAfterMainBore ); + + RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo, exportLgrData ); + }; + + { + QTextStream stream( exportFile.get() ); + RifTextDataTableFormatter formatter( stream ); + bool exportLgrData = false; + + doExport( formatter, exportDataSourceAsComment, exportInfo, wellPath, completionSegmentsAfterMainBore, exportLgrData ); + } + + if ( exportInfo.hasSubGridIntersections() ) + { + QTextStream stream( lgrExportFile.get() ); + RifTextDataTableFormatter formatter( stream ); + + bool exportLgrData = true; + doExport( formatter, exportDataSourceAsComment, exportInfo, wellPath, completionSegmentsAfterMainBore, exportLgrData ); + } } //-------------------------------------------------------------------------------------------------- @@ -289,6 +377,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEcl //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, bool exportDataSourceAsComment, bool completionSegmentsAfterMainBore ) @@ -301,8 +390,8 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEcl return; } - double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first intersection - // with active grid, or user defined value. + double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first + // intersection with active grid, or user defined value. auto mswParameters = wellPath->mswCompletionParameters(); auto cellIntersections = generateCellSegments( eclipseCase, wellPath, mswParameters, &initialMD ); @@ -328,15 +417,39 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEcl assignBranchNumbersToBranch( eclipseCase, &exportInfo, exportInfo.mainBoreBranch(), &branchNumber ); - QTextStream stream( exportFile.get() ); - RifTextDataTableFormatter formatter( stream ); - formatter.setOptionalComment( exportDataSourceAsComment ); + { + QTextStream stream( exportFile.get() ); + RifTextDataTableFormatter formatter( stream ); + formatter.setOptionalComment( exportDataSourceAsComment ); - double maxSegmentLength = wellPath->mswCompletionParameters()->maxSegmentLength(); + double maxSegmentLength = wellPath->mswCompletionParameters()->maxSegmentLength(); - RicMswTableFormatterTools::generateWelsegsTable( formatter, exportInfo, maxSegmentLength, completionSegmentsAfterMainBore ); - RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo ); - RicMswTableFormatterTools::generateWsegvalvTable( formatter, exportInfo ); + RicMswTableFormatterTools::generateWelsegsTable( formatter, + exportInfo, + maxSegmentLength, + completionSegmentsAfterMainBore ); + bool exportLgrData = false; + RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo, exportLgrData ); + + RicMswTableFormatterTools::generateWsegvalvTable( formatter, exportInfo ); + } + + if ( exportInfo.hasSubGridIntersections() ) + { + QTextStream stream( lgrExportFile.get() ); + RifTextDataTableFormatter formatter( stream ); + formatter.setOptionalComment( exportDataSourceAsComment ); + + double maxSegmentLength = wellPath->mswCompletionParameters()->maxSegmentLength(); + + RicMswTableFormatterTools::generateWelsegsTable( formatter, + exportInfo, + maxSegmentLength, + completionSegmentsAfterMainBore ); + + bool exportLgr = true; + RicMswTableFormatterTools::generateCompsegTables( formatter, exportInfo, exportLgr ); + } } //-------------------------------------------------------------------------------------------------- @@ -546,8 +659,8 @@ void RicWellPathExportMswCompletionsImpl::generateFishbonesMswExportInfoForWell( gsl::not_null exportInfo, gsl::not_null branch ) { - double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first intersection - // with active grid, or user defined value. + double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first + // intersection with active grid, or user defined value. auto mswParameters = wellPath->mswCompletionParameters(); auto cellIntersections = generateCellSegments( eclipseCase, wellPath, mswParameters, &initialMD ); diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index d87232be90..bf41d245c3 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -50,18 +50,21 @@ public: static void exportWellSegmentsForFractures( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, bool exportDataSourceAsComment, bool completionSegmentsAfterMainBore ); static void exportWellSegmentsForFishbones( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, bool exportDataSourceAsComment, bool completionSegmentsAfterMainBore ); static void exportWellSegmentsForPerforations( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, + std::shared_ptr lgrExportFile, const RimWellPath* wellPath, int timeStep, bool exportDataSourceAsComment,