From 52e9f54801444fcd2fae933b83ac06a314739df1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 28 May 2020 09:50:00 +0200 Subject: [PATCH 01/24] Bundling of HDF5 : Include symlinks in addition to binary file --- CMakeLists.txt | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a76a8a0207..1d054a81cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -474,25 +474,16 @@ endif (RESINSIGHT_PRIVATE_INSTALL) if (RESINSIGHT_HDF5_BUNDLE_LIBRARIES) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - foreach (FILE_TO_COPY ${HDF5_LIBRARIES}) - - # find all files containing the string "hdf" - STRING( FIND ${FILE_TO_COPY} "hdf5" POS_IN_STRING ) - if(${POS_IN_STRING} GREATER -1) - get_filename_component(ABS_DIR ${FILE_TO_COPY} REALPATH) - message (STATUS "HDF5 bundle file - ${ABS_DIR}") - - # as part of install, rename file with the extension ResInsight reports when running "ldd" - get_filename_component(FILE_NAME_WE ${FILE_TO_COPY} NAME_WE) - set(FILE_NAME_FOR_INSTALL "${FILE_NAME_WE}.so.6") - message (STATUS "HDF5 file FILE_NAME_FOR_INSTALL - ${FILE_NAME_FOR_INSTALL}") - - install(FILES ${ABS_DIR} DESTINATION ${RESINSIGHT_INSTALL_FOLDER} RENAME ${FILE_NAME_FOR_INSTALL} ) - endif() - endforeach() - + # find all file names with text hdf5 + # use file globbing to also copy the symlinks to make sure the dependencies from ResInsight runtime is correct + foreach (FILE_TO_COPY ${HDF5_LIBRARIES}) + STRING( FIND ${FILE_TO_COPY} "hdf5" POS_IN_STRING ) + if(${POS_IN_STRING} GREATER -1) + file(GLOB FILE_AND_SYMLINKS ${FILE_TO_COPY}*) + install(FILES ${FILE_AND_SYMLINKS} DESTINATION ${RESINSIGHT_INSTALL_FOLDER} ) + endif() + endforeach() endif() - endif (RESINSIGHT_HDF5_BUNDLE_LIBRARIES) From 4395ee899c9a2ed2b558693ed6f3664cc45b4174 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Jun 2020 11:33:23 +0200 Subject: [PATCH 02/24] #6071 MSW export : Use minimum MD of grid entry point and completions --- .../RicWellPathExportMswCompletionsImpl.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 7f15902f68..5f01a09600 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -958,6 +958,21 @@ RicMswExportInfo break; } } + + double startOfFirstCompletion = std::numeric_limits::infinity(); + { + for ( auto* fracture : fractures ) + { + if ( fracture->isEnabled() && fracture->startMD() < startOfFirstCompletion ) + { + startOfFirstCompletion = fracture->startMD(); + } + } + } + + // Initial MD is the lowest MD based on grid intersection and start of fracture completions + // https://github.com/OPM/ResInsight/issues/6071 + initialMD = std::min( initialMD, startOfFirstCompletion ); } RicMswExportInfo exportInfo( wellPath, @@ -1111,6 +1126,23 @@ std::vector break; } } + + double startOfFirstCompletion = std::numeric_limits::infinity(); + { + std::vector allCompletions = wellPath->completions()->allCompletions(); + + for ( const RimWellPathComponentInterface* completion : allCompletions ) + { + if ( completion->isEnabled() && completion->startMD() < startOfFirstCompletion ) + { + startOfFirstCompletion = completion->startMD(); + } + } + } + + // Initial MD is the lowest MD based on grid intersection and start of fracture completions + // https://github.com/OPM/ResInsight/issues/6071 + initialMD = std::min( initialMD, startOfFirstCompletion ); } std::vector filteredIntersections = From 31ebeba0a3b92b3697595307f2230bc3b1e8ecae Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jun 2020 15:36:27 +0200 Subject: [PATCH 03/24] #6072 Well Completions : Make sure valves are included if they are located outside grid cells --- .../RicWellPathExportMswCompletionsImpl.cpp | 24 +++++-- .../RigWellPathIntersectionTools.cpp | 71 +++++++++++++++++++ .../RigWellPathIntersectionTools.h | 10 +++ 3 files changed, 99 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 5f01a09600..0c86af6f23 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -1108,9 +1108,13 @@ std::vector const std::vector& mds = wellPathGeometry->measureDepths(); CVF_ASSERT( !coords.empty() && !mds.empty() ); - std::vector intersections = + std::vector intersectionsA = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( eclipseCase->eclipseCaseData(), coords, mds ); + const RigMainGrid* mainGrid = eclipseCase->mainGrid(); + std::vector intersections = + RigWellPathIntersectionTools::buildContinuousIntersections( intersectionsA, mainGrid ); + if ( wellPath->perforationIntervalCollection()->mswParameters()->referenceMDType() == RimMswCompletionParameters::MANUAL_REFERENCE_MD ) { @@ -1219,11 +1223,19 @@ std::vector const RigMainGrid* grid = eclipseCase->mainGrid(); - extraIntersection.intersectionLengthsInCellCS = - RigWellPathIntersectionTools::calculateLengthInCell( grid, - intersection.globCellIndex, - intersectionPoint, - intersection.endPoint ); + if ( intersection.globCellIndex < grid->cellCount() ) + { + extraIntersection.intersectionLengthsInCellCS = + RigWellPathIntersectionTools::calculateLengthInCell( grid, + intersection.globCellIndex, + intersectionPoint, + intersection.endPoint ); + } + else + { + extraIntersection.intersectionLengthsInCellCS = cvf::Vec3d::ZERO; + } + filteredIntersections.push_back( extraIntersection ); } } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index bc446e3085..b893fe402f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -150,3 +150,74 @@ cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell( const RigMainGri return calculateLengthInCell( hexCorners, startPoint, endPoint ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellPathIntersectionTools::buildContinuousIntersections( + const std::vector& originalIntersections, + const cvf::StructGridInterface* grid ) +{ + std::vector intersectionsNoGap; + + for ( size_t i = 0; i < originalIntersections.size() - 1; i++ ) + { + const WellPathCellIntersectionInfo& current = originalIntersections[i]; + const WellPathCellIntersectionInfo& next = originalIntersections[i + 1]; + + double distance = std::fabs( current.endMD - next.startMD ); + double gapInGridThreshold = 0.1; + if ( distance > gapInGridThreshold ) + { + WellPathCellIntersectionInfo extraIntersection; + + QString ijkTextCurrent; + { + size_t i = 0, j = 0, k = 0; + if ( grid ) + { + grid->ijkFromCellIndex( current.globCellIndex, &i, &j, &k ); + } + ijkTextCurrent = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); + } + QString ijkTextNext; + { + size_t i = 0, j = 0, k = 0; + if ( grid ) + { + grid->ijkFromCellIndex( next.globCellIndex, &i, &j, &k ); + } + ijkTextNext = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); + } + + QString text = QString( "Gap detected : Distance diff : %1, epsilon = %2\n Global Cell Index 1 : %3, " + "IJK=%4, endMD : %5\n Global Cell Index 2 : %6, IJK=%7, startMD : %8" ) + .arg( distance ) + .arg( gapInGridThreshold ) + .arg( current.globCellIndex ) + .arg( ijkTextCurrent ) + .arg( current.endMD ) + .arg( next.globCellIndex ) + .arg( ijkTextNext ) + .arg( next.startMD ); + + RiaLogging::info( text ); + + extraIntersection.globCellIndex = std::numeric_limits::max(); + extraIntersection.startPoint = current.endPoint; + extraIntersection.endPoint = next.startPoint; + extraIntersection.startMD = current.endMD; + extraIntersection.endMD = next.startMD; + extraIntersection.intersectedCellFaceIn = + cvf::StructGridInterface::oppositeFace( current.intersectedCellFaceOut ); + extraIntersection.intersectedCellFaceOut = cvf::StructGridInterface::oppositeFace( next.intersectedCellFaceIn ); + extraIntersection.intersectionLengthsInCellCS = cvf::Vec3d::ZERO; + + intersectionsNoGap.push_back( extraIntersection ); + } + + intersectionsNoGap.push_back( current ); + } + + return intersectionsNoGap; +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index c565d74620..bea8ce77f8 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -29,6 +29,11 @@ class RigEclipseCaseData; struct HexIntersectionInfo; struct WellPathCellIntersectionInfo; +namespace cvf +{ +class StructGridInterface; +}; + //================================================================================================== /// //================================================================================================== @@ -55,4 +60,9 @@ public: size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint ); + + // Insert dummy intersections used to represent gap in grid + static std::vector + buildContinuousIntersections( const std::vector& originalIntersections, + const cvf::StructGridInterface* grid ); }; From 59e5edc282330f3ce219a7c2c189f2d09e92319d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 15 Jun 2020 16:18:45 +0200 Subject: [PATCH 04/24] #6072 Well Completions : Disable debug output --- .../RigWellPathIntersectionTools.cpp | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index b893fe402f..30134ad9f5 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -171,38 +171,42 @@ std::vector RigWellPathIntersectionTools::buildCon { WellPathCellIntersectionInfo extraIntersection; - QString ijkTextCurrent; + bool showDebugInfo = false; + if ( showDebugInfo ) { - size_t i = 0, j = 0, k = 0; - if ( grid ) + QString ijkTextCurrent; { - grid->ijkFromCellIndex( current.globCellIndex, &i, &j, &k ); + size_t i = 0, j = 0, k = 0; + if ( grid ) + { + grid->ijkFromCellIndex( current.globCellIndex, &i, &j, &k ); + } + ijkTextCurrent = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); } - ijkTextCurrent = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); - } - QString ijkTextNext; - { - size_t i = 0, j = 0, k = 0; - if ( grid ) + QString ijkTextNext; { - grid->ijkFromCellIndex( next.globCellIndex, &i, &j, &k ); + size_t i = 0, j = 0, k = 0; + if ( grid ) + { + grid->ijkFromCellIndex( next.globCellIndex, &i, &j, &k ); + } + ijkTextNext = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); } - ijkTextNext = QString( "(%1 %2 %3)" ).arg( i + 1 ).arg( j + 1 ).arg( k + 1 ); + + QString text = QString( "Gap detected : Distance diff : %1, epsilon = %2\n Global Cell Index 1 : %3, " + "IJK=%4, endMD : %5\n Global Cell Index 2 : %6, IJK=%7, startMD : %8" ) + .arg( distance ) + .arg( gapInGridThreshold ) + .arg( current.globCellIndex ) + .arg( ijkTextCurrent ) + .arg( current.endMD ) + .arg( next.globCellIndex ) + .arg( ijkTextNext ) + .arg( next.startMD ); + + RiaLogging::info( text ); } - QString text = QString( "Gap detected : Distance diff : %1, epsilon = %2\n Global Cell Index 1 : %3, " - "IJK=%4, endMD : %5\n Global Cell Index 2 : %6, IJK=%7, startMD : %8" ) - .arg( distance ) - .arg( gapInGridThreshold ) - .arg( current.globCellIndex ) - .arg( ijkTextCurrent ) - .arg( current.endMD ) - .arg( next.globCellIndex ) - .arg( ijkTextNext ) - .arg( next.startMD ); - - RiaLogging::info( text ); - extraIntersection.globCellIndex = std::numeric_limits::max(); extraIntersection.startPoint = current.endPoint; extraIntersection.endPoint = next.startPoint; From f255161b642d2577c9c52c0ee2239a4401d98dca Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jun 2020 07:27:28 +0200 Subject: [PATCH 05/24] #6093 Wells: Toggling Off a well path leaves perforations visible --- .../ModelVisualization/RivWellPathPartMgr.cpp | 62 ++++++++++--------- .../ModelVisualization/RivWellPathPartMgr.h | 2 + 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 1e6905f564..959601dd1d 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -129,6 +129,26 @@ bool RivWellPathPartMgr::isWellPathWithinBoundingBox( const cvf::BoundingBox& we return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivWellPathPartMgr::isWellPathEnabled( const cvf::BoundingBox& wellPathClipBoundingBox ) const +{ + RimWellPathCollection* wellPathCollection = this->wellPathCollection(); + if ( !wellPathCollection ) return false; + + if ( !wellPathCollection->isActive() ) return false; + + if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF ) return false; + + if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::ALL_ON && m_rimWellPath->showWellPath() == false ) + return false; + + if ( !isWellPathWithinBoundingBox( wellPathClipBoundingBox ) ) return false; + + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -770,16 +790,7 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel( cvf::ModelBasicList* double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox ) { - RimWellPathCollection* wellPathCollection = this->wellPathCollection(); - if ( !wellPathCollection ) return; - - if ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF ) return; - - if ( wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && - m_rimWellPath->showWellPath() == false ) - return; - - if ( !isWellPathWithinBoundingBox( wellPathClipBoundingBox ) ) return; + if ( !isWellPathEnabled( wellPathClipBoundingBox ) ) return; // The pipe geometry needs to be rebuilt on scale change to keep the pipes round buildWellPathParts( displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, false ); @@ -804,9 +815,11 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel( cvf::ModelBasicList* appendWellPathAttributesToModel( model, displayCoordTransform, characteristicCellSize ); RimGridView* gridView = dynamic_cast( m_rimView.p() ); - if ( !gridView ) return; - m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr( m_rimWellPath, gridView ); - m_3dWellLogPlanePartMgr->appendPlaneToModel( model, displayCoordTransform, wellPathClipBoundingBox, true ); + if ( gridView ) + { + m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr( m_rimWellPath, gridView ); + m_3dWellLogPlanePartMgr->appendPlaneToModel( model, displayCoordTransform, wellPathClipBoundingBox, true ); + } } //-------------------------------------------------------------------------------------------------- @@ -849,17 +862,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* { CVF_ASSERT( model ); - RimWellPathCollection* wellPathCollection = this->wellPathCollection(); - if ( !wellPathCollection ) return; - - if ( m_rimWellPath.isNull() ) return; - - bool showWellPath = ( wellPathCollection->isActive() && - ( ( wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_OFF ) || - ( wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_ON && - m_rimWellPath->showWellPath() ) ) ); - - if ( !isWellPathWithinBoundingBox( wellPathClipBoundingBox ) ) return; + bool showWellPath = isWellPathEnabled( wellPathClipBoundingBox ); if ( showWellPath ) { @@ -874,13 +877,14 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* if ( showWellPath ) { RimGridView* gridView = dynamic_cast( m_rimView.p() ); - if ( !gridView ) return; - - if ( m_3dWellLogPlanePartMgr.isNull() ) + if ( gridView ) { - m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr( m_rimWellPath, gridView ); + if ( m_3dWellLogPlanePartMgr.isNull() ) + { + m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr( m_rimWellPath, gridView ); + } + m_3dWellLogPlanePartMgr->appendPlaneToModel( model, displayCoordTransform, wellPathClipBoundingBox, false ); } - m_3dWellLogPlanePartMgr->appendPlaneToModel( model, displayCoordTransform, wellPathClipBoundingBox, false ); } } diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index a52b1c23e5..df6c82bf06 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -135,6 +135,8 @@ private: static cvf::Color3f mapWellMeasurementToColor( const QString& measurementKind, double value ); + bool isWellPathEnabled( const cvf::BoundingBox& wellPathClipBoundingBox ) const; + private: caf::PdmPointer m_rimWellPath; caf::PdmPointer m_rimView; From 9ffabcb9bc8ca6b234a8f83392cf36befd54f4ce Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jun 2020 08:51:54 +0200 Subject: [PATCH 06/24] #6124 Valve export : Add missing -- in header of AICD export --- ApplicationCode/FileInterface/RifTextDataTableFormatter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/FileInterface/RifTextDataTableFormatter.cpp b/ApplicationCode/FileInterface/RifTextDataTableFormatter.cpp index 03ea8af0ab..5610dac8a4 100644 --- a/ApplicationCode/FileInterface/RifTextDataTableFormatter.cpp +++ b/ApplicationCode/FileInterface/RifTextDataTableFormatter.cpp @@ -48,6 +48,7 @@ RifTextDataTableFormatter::RifTextDataTableFormatter( const RifTextDataTableForm , m_tableRowPrependText( rhs.m_tableRowPrependText ) , m_tableRowAppendText( rhs.m_tableRowAppendText ) , m_commentPrefix( rhs.m_commentPrefix ) + , m_headerPrefix( rhs.m_headerPrefix ) , m_maxDataRowWidth( rhs.m_maxDataRowWidth ) , m_defaultMarker( rhs.m_defaultMarker ) { From 99c40df08e7c8fd72afef95301987047a1df1d54 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jun 2020 10:14:31 +0200 Subject: [PATCH 07/24] #6074 MSW: Add helper function to compute TVD --- .../RicWellPathExportMswCompletionsImpl.cpp | 18 +++++++++++++++--- .../RicWellPathExportMswCompletionsImpl.h | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 0c86af6f23..a6fa478841 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -849,17 +849,17 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generateFishbonesMswExport for ( auto& sub : subs->installedLateralIndices() ) { double subEndMD = subs->measuredDepth( sub.subIndex ); - double subEndTVD = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD ).z(); + double subEndTVD = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, subEndMD ); int subSegCount = SubSegmentIntersectionInfo::numberOfSplittedSegments( subStartMD, subEndMD, maxSegmentLength ); double subSegLen = ( subEndMD - subStartMD ) / subSegCount; double startMd = subStartMD; - double startTvd = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( startMd ).z(); + double startTvd = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, startMd ); for ( int ssi = 0; ssi < subSegCount; ssi++ ) { double endMd = startMd + subSegLen; - double endTvd = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( endMd ).z(); + double endTvd = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, endMd ); std::shared_ptr location( new RicMswSegment( subs->generatedName(), startMd, endMd, startTvd, endTvd, sub.subIndex ) ); @@ -1905,6 +1905,18 @@ void RicWellPathExportMswCompletionsImpl::assignBranchAndSegmentNumbers( const R } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( const RimWellPath* wellPath, double measuredDepth ) +{ + CVF_ASSERT( wellPath && wellPath->wellPathGeometry() ); + + double tvdValue = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( measuredDepth ).z(); + + return tvdValue; +} + SubSegmentIntersectionInfo::SubSegmentIntersectionInfo( size_t globCellIndex, double startTVD, double endTVD, diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index ad343b1f44..f2e7211022 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -163,4 +163,6 @@ private: int* branchNum, int* segmentNum ); static void assignBranchAndSegmentNumbers( const RimEclipseCase* caseToApply, RicMswExportInfo* exportInfo ); + + static double tvdFromMeasuredDepth( const RimWellPath* wellPath, double measuredDepth ); }; From 6ee877a568cd62932a019aa3fbfffc5d824ca797 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jun 2020 11:13:36 +0200 Subject: [PATCH 08/24] #6074 MSW: Add export of both ABS and INC for valves --- .../RicWellPathExportMswCompletionsImpl.cpp | 67 +++++++++++++++---- .../RicWellPathExportMswCompletionsImpl.h | 1 + 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index a6fa478841..fb58952255 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -382,12 +382,29 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsSegments( { formatter.comment( completion->label() ); - formatter.add( completion->subSegments().front()->segmentNumber() ); - formatter.add( completion->subSegments().front()->segmentNumber() ); + auto firstSubSegment = completion->subSegments().front(); + + formatter.add( firstSubSegment->segmentNumber() ); + formatter.add( firstSubSegment->segmentNumber() ); formatter.add( completion->branchNumber() ); formatter.add( segment->segmentNumber() ); - formatter.add( 0.1 ); // ICDs have 0.1 length - formatter.add( 0 ); // Depth change + + double length = 0.0; + double depth = 0.0; + + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) + { + length = firstSubSegment->deltaMD(); + depth = firstSubSegment->deltaTVD(); + } + else + { + length = firstSubSegment->endMD(); + depth = firstSubSegment->endTVD(); + } + + formatter.add( length ); + formatter.add( depth ); formatter.add( exportInfo.linerDiameter() ); formatter.add( exportInfo.roughnessFactor() ); formatter.rowCompleted(); @@ -1077,7 +1094,7 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp eclipseCase, &foundSubGridIntersections ); - createValveCompletions( mainBoreSegments, perforationIntervals, unitSystem ); + createValveCompletions( mainBoreSegments, perforationIntervals, wellPath, unitSystem ); assignValveContributionsToSuperICDsOrAICDs( mainBoreSegments, perforationIntervals, unitSystem ); moveIntersectionsToICVs( mainBoreSegments, perforationIntervals, unitSystem ); moveIntersectionsToSuperICDsOrAICDs( mainBoreSegments ); @@ -1309,6 +1326,7 @@ RicWellPathExportMswCompletionsImpl::MainBoreSegments void RicWellPathExportMswCompletionsImpl::createValveCompletions( std::vector>& mainBoreSegments, const std::vector& perforationIntervals, + const RimWellPath* wellPath, RiaEclipseUnitTools::UnitSystem unitSystem ) { for ( size_t nMainSegment = 0u; nMainSegment < mainBoreSegments.size(); ++nMainSegment ) @@ -1335,7 +1353,12 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( for ( size_t nSubValve = 0u; nSubValve < valve->valveLocations().size(); ++nSubValve ) { - double valveMD = valve->valveLocations()[nSubValve]; + double valveMD = valve->valveLocations()[nSubValve]; + double valveStartTVD = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, valveMD ); + + double valveLengthMD = 0.1; + double valveEndTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, valveMD + valveLengthMD ); std::pair valveSegment = valve->valveSegments()[nSubValve]; double overlapStart = std::max( valveSegment.first, segment->startMD() ); @@ -1349,7 +1372,7 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); std::shared_ptr subSegment( - new RicMswSubSegment( valveMD, valveMD + 0.1, 0.0, 0.0 ) ); + new RicMswSubSegment( valveMD, valveMD + valveLengthMD, valveStartTVD, valveEndTVD ) ); superAICD = std::make_shared( valveLabel, valve ); superAICD->addSubSegment( subSegment ); @@ -1359,7 +1382,7 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); std::shared_ptr subSegment( - new RicMswSubSegment( valveMD, valveMD + 0.1, 0.0, 0.0 ) ); + new RicMswSubSegment( valveMD, valveMD + valveLengthMD, valveStartTVD, valveEndTVD ) ); superICD = std::make_shared( valveLabel, valve ); superICD->addSubSegment( subSegment ); @@ -1369,7 +1392,7 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( QString valveLabel = QString( "ICV %1 at segment #%2" ).arg( valve->name() ).arg( nMainSegment + 2 ); std::shared_ptr subSegment( - new RicMswSubSegment( valveMD, valveMD + 0.1, 0.0, 0.0 ) ); + new RicMswSubSegment( valveMD, valveMD + valveLengthMD, valveStartTVD, valveEndTVD ) ); ICV = std::make_shared( valveLabel, valve ); ICV->addSubSegment( subSegment ); @@ -1382,8 +1405,17 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( { QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); - std::shared_ptr subSegment( - new RicMswSubSegment( overlapStart, overlapStart + 0.1, 0.0, 0.0 ) ); + + double overlapValveStartTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, overlapStart ); + double overlapEndTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, + overlapStart + valveLengthMD ); + + std::shared_ptr subSegment( new RicMswSubSegment( overlapStart, + overlapStart + valveLengthMD, + overlapValveStartTVD, + overlapEndTVD ) ); superICD = std::make_shared( valveLabel, valve ); superICD->addSubSegment( subSegment ); } @@ -1391,8 +1423,17 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( { QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); - std::shared_ptr subSegment( - new RicMswSubSegment( overlapStart, overlapStart + 0.1, 0.0, 0.0 ) ); + + double overlapValveStartTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, overlapStart ); + double overlapEndTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, + overlapStart + valveLengthMD ); + + std::shared_ptr subSegment( new RicMswSubSegment( overlapStart, + overlapStart + valveLengthMD, + overlapValveStartTVD, + overlapEndTVD ) ); superAICD = std::make_shared( valveLabel, valve ); superAICD->addSubSegment( subSegment ); } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index f2e7211022..4bfa71116e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -121,6 +121,7 @@ private: static void createValveCompletions( std::vector>& mainBoreSegments, const std::vector& perforationIntervals, + const RimWellPath* wellPath, RiaEclipseUnitTools::UnitSystem unitSystem ); static void From 57459072506e8b41a2d0424fffbd0849bf053695 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Jun 2020 12:32:04 +0200 Subject: [PATCH 09/24] #6128 WELSEGS export : Missing last segment --- .../ReservoirDataModel/RigWellPathIntersectionTools.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index 30134ad9f5..7312ed10cc 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -223,5 +223,10 @@ std::vector RigWellPathIntersectionTools::buildCon intersectionsNoGap.push_back( current ); } + if ( !originalIntersections.empty() ) + { + intersectionsNoGap.push_back( originalIntersections.back() ); + } + return intersectionsNoGap; } From 1dcec6df6b9b9c37b93fdbfc5e9155335f7f5aad Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jun 2020 11:58:59 +0200 Subject: [PATCH 10/24] #6138 Valve Export : Make sure the valves always use the valve interval, not perforation interval --- .../ProjectDataModel/Completions/RimWellPathValve.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp index 53b28ea0c0..d6c4573bd8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp @@ -264,8 +264,9 @@ std::vector> RimWellPathValve::valveSegments() const RimPerforationInterval* perforationInterval = nullptr; this->firstAncestorOrThisOfType( perforationInterval ); - double startMD = perforationInterval->startMD(); - double endMD = perforationInterval->endMD(); + double startMD = this->startMD(); + double endMD = this->endMD(); + std::vector valveMDs = valveLocations(); std::vector> segments; @@ -381,7 +382,7 @@ double RimWellPathValve::startMD() const { return m_measuredDepth; } - else if ( m_multipleValveLocations()->valveLocations().empty() ) + else if ( m_multipleValveLocations()->valveLocations().size() < 2 ) { return m_multipleValveLocations->rangeStart(); } @@ -400,7 +401,7 @@ double RimWellPathValve::endMD() const { return m_measuredDepth + 0.5; } - else if ( m_multipleValveLocations()->valveLocations().empty() ) + else if ( m_multipleValveLocations()->valveLocations().size() < 2 ) { return m_multipleValveLocations->rangeEnd(); } From 53f519614a698d8d0428d99ee91ae6241ebc4ed8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jun 2020 12:35:51 +0200 Subject: [PATCH 11/24] #6126 MSW AICDs: Fix computation of flow scaling factor --- .../RicMswCompletions.cpp | 17 +++++++++ .../RicMswCompletions.h | 3 ++ .../RicMswValveAccumulators.cpp | 38 +++++++++++++++---- .../RicMswValveAccumulators.h | 14 ++++--- .../RicWellPathExportMswCompletionsImpl.cpp | 33 ++++++++++------ 5 files changed, 80 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp index 21c7fa0819..53c0b08419 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp @@ -246,6 +246,7 @@ RicMswPerforationAICD::RicMswPerforationAICD( const QString& label, const RimWel , m_valid( false ) , m_deviceOpen( false ) , m_length( 0.0 ) + , m_flowScalingFactor( 0.0 ) { } @@ -305,6 +306,22 @@ void RicMswPerforationAICD::setLength( double length ) m_length = length; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicMswPerforationAICD::flowScalingFactor() const +{ + return m_flowScalingFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicMswPerforationAICD::setflowScalingFactor( double scalingFactor ) +{ + m_flowScalingFactor = scalingFactor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h index d5d6a92f82..6fa140ae6a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h @@ -170,6 +170,8 @@ public: void setIsOpen( bool deviceOpen ); double length() const; void setLength( double length ); + double flowScalingFactor() const; + void setflowScalingFactor( double scalingFactor ); const std::array& values() const; std::array& values(); @@ -179,4 +181,5 @@ private: bool m_deviceOpen; std::array m_parameters; double m_length; + double m_flowScalingFactor; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp index 294d5751d7..07d539542f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp @@ -38,7 +38,8 @@ RicMswICDAccumulator::RicMswICDAccumulator( RiaEclipseUnitTools::UnitSystem unit //-------------------------------------------------------------------------------------------------- bool RicMswICDAccumulator::accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, - double contributionFraction ) + double contributionFraction, + double totalValveLengthOpenForFlow ) { CVF_ASSERT( wellPathValve ); if ( wellPathValve->componentType() == RiaDefines::ICV || wellPathValve->componentType() == RiaDefines::ICD ) @@ -75,6 +76,7 @@ RicMswAICDAccumulator::RicMswAICDAccumulator( RiaEclipseUnitTools::UnitSystem un , m_valid( false ) , m_deviceOpen( false ) , m_accumulatedLength( 0.0 ) + , m_accumulatedFlowScalingFactorDivisor( 0.0 ) { } @@ -83,7 +85,8 @@ RicMswAICDAccumulator::RicMswAICDAccumulator( RiaEclipseUnitTools::UnitSystem un //-------------------------------------------------------------------------------------------------- bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, - double contributionFraction ) + double contributionFraction, + double totalValveLengthOpenForFlow ) { CVF_ASSERT( wellPathValve ); if ( wellPathValve->componentType() == RiaDefines::AICD ) @@ -103,16 +106,26 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w m_meanCalculators[i].addValueAndWeight( values[i], contributionFraction ); } } + std::pair valveSegment = wellPathValve->valveSegments()[subValve]; double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); - const RimPerforationInterval* perfInterval = nullptr; - wellPathValve->firstAncestorOrThisOfTypeAsserted( perfInterval ); - double perfIntervalLength = std::fabs( perfInterval->endMD() - perfInterval->startMD() ); - double lengthFraction = 1.0; - if ( perfIntervalLength > 1.0e-8 ) + double lengthFraction = 1.0; + if ( totalValveLengthOpenForFlow > 1.0e-8 ) { - lengthFraction = valveSegmentLength / perfIntervalLength; + lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; } + + // https://github.com/OPM/ResInsight/issues/6126 + // + // flowScalingFactor = 1 / (length_fraction * N_AICDs) + // where: + // length_fraction = length_COMPSEGS / Sum_lenght_COMPSEGS_for_valve + // N_AICDs = number of AICDs in perforation interval + + double divisor = wellPathValve->valveLocations().size() * lengthFraction * contributionFraction; + + m_accumulatedFlowScalingFactorDivisor += divisor; + m_accumulatedLength += lengthFraction * contributionFraction; } } @@ -147,6 +160,15 @@ void RicMswAICDAccumulator::applyToSuperValve( std::shared_ptr valv aicd->setIsOpen( m_deviceOpen ); aicd->setLength( m_accumulatedLength ); + // See https://github.com/OPM/ResInsight/issues/6126 + double flowScalingFactor = 0.0; + if ( m_accumulatedFlowScalingFactorDivisor > 1.0e-8 ) + { + flowScalingFactor = 1.0 / m_accumulatedFlowScalingFactorDivisor; + } + + aicd->setflowScalingFactor( flowScalingFactor ); + aicd->values() = values; } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h index f3a68bf806..549436c2d8 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h @@ -39,8 +39,9 @@ public: } virtual bool accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, - double contributionFraction ) = 0; - virtual void applyToSuperValve( std::shared_ptr valve ) = 0; + double contributionFraction, + double totalValveLengthOpenForFlow ) = 0; + virtual void applyToSuperValve( std::shared_ptr valve ) = 0; protected: RiaEclipseUnitTools::UnitSystem m_unitSystem; @@ -55,7 +56,8 @@ public: RicMswICDAccumulator( RiaEclipseUnitTools::UnitSystem unitSystem ); bool accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, - double contributionFraction ) override; + double contributionFraction, + double totalValveLengthOpenForFlow ) override; void applyToSuperValve( std::shared_ptr valve ) override; private: @@ -72,7 +74,8 @@ public: RicMswAICDAccumulator( RiaEclipseUnitTools::UnitSystem unitSystem ); bool accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, - double contributionFraction ) override; + double contributionFraction, + double totalValveLengthOpenForFlow ) override; void applyToSuperValve( std::shared_ptr valve ) override; private: @@ -80,4 +83,5 @@ private: bool m_deviceOpen; std::array, AICD_NUM_PARAMS> m_meanCalculators; double m_accumulatedLength; -}; \ No newline at end of file + double m_accumulatedFlowScalingFactorDivisor; +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index fb58952255..e869313b3b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -737,7 +737,7 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl "Segment Number", "Segment Number", "Strength of AICD", - "Length of AICD", + "Flow Scaling Factor for AICD", "Density of Calibration Fluid", "Viscosity of Calibration Fluid", "Critical water in liquid fraction for emulsions viscosity model", @@ -781,13 +781,16 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl { CVF_ASSERT( aicd->subSegments().size() == 1u ); tighterFormatter.comment( aicd->label() ); - tighterFormatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); // 1 + tighterFormatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); // #1 tighterFormatter.add( aicd->subSegments().front()->segmentNumber() ); tighterFormatter.add( aicd->subSegments().front()->segmentNumber() ); std::array values = aicd->values(); tighterFormatter.add( values[AICD_STRENGTH] ); - tighterFormatter.add( aicd->length() ); // 5 + + tighterFormatter.add( aicd->flowScalingFactor() ); // #5 Flow scaling factor used when item #11 is + // set to '1' + tighterFormatter.add( values[AICD_DENSITY_CALIB_FLUID] ); tighterFormatter.add( values[AICD_VISCOSITY_CALIB_FLUID] ); tighterFormatter.addValueOrDefaultMarker( values[AICD_CRITICAL_WATER_IN_LIQUID_FRAC], @@ -795,13 +798,16 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl tighterFormatter.addValueOrDefaultMarker( values[AICD_EMULSION_VISC_TRANS_REGION], RicMswExportInfo::defaultDoubleValue() ); tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_RATIO_EMULSION_VISC], - RicMswExportInfo::defaultDoubleValue() ); // 10 - tighterFormatter.add( 1 ); + RicMswExportInfo::defaultDoubleValue() ); // #10 + + tighterFormatter.add( 1 ); // #11 : Always use method "b. Scale factor". The value of the scale + // factor is given in item #5 + tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_FLOW_RATE], RicMswExportInfo::defaultDoubleValue() ); tighterFormatter.add( values[AICD_VOL_FLOW_EXP] ); tighterFormatter.add( values[AICD_VISOSITY_FUNC_EXP] ); - tighterFormatter.add( aicd->isOpen() ? "OPEN" : "SHUT" ); // 15 + tighterFormatter.add( aicd->isOpen() ? "OPEN" : "SHUT" ); // #15 tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_DENSITY], RicMswExportInfo::defaultDoubleValue() ); tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_DENSITY], @@ -811,7 +817,7 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_VISCOSITY], RicMswExportInfo::defaultDoubleValue() ); tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_VISCOSITY], - RicMswExportInfo::defaultDoubleValue() ); // 20 + RicMswExportInfo::defaultDoubleValue() ); // #20 tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_GAS_FRAC_VISCOSITY], RicMswExportInfo::defaultDoubleValue() ); tighterFormatter.rowCompleted(); @@ -1274,9 +1280,9 @@ RicWellPathExportMswCompletionsImpl::MainBoreSegments { MainBoreSegments mainBoreSegments; - // Intersections along the well path with grid geometry is handled by well log extraction tools. The threshold in - // RigWellLogExtractionTools::isEqualDepth is currently set to 0.1m, and this is a pretty large threshold based on - // the indicated threshold of 0.001m for MSW segments + // Intersections along the well path with grid geometry is handled by well log extraction tools. + // The threshold in RigWellLogExtractionTools::isEqualDepth is currently set to 0.1m, and this + // is a pretty large threshold based on the indicated threshold of 0.001m for MSW segments const double segmentLengthThreshold = 1.0e-3; for ( const auto& cellIntInfo : subSegIntersections ) @@ -1511,7 +1517,6 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperICDsOrA std::vector perforationValves; interval->descendantsIncludingThisOfType( perforationValves ); - for ( const RimWellPathValve* valve : perforationValves ) { if ( !valve->isChecked() ) continue; @@ -1526,7 +1531,11 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperICDsOrA if ( overlap > 0.0 && accumulator ) { - if ( accumulator->accumulateValveParameters( valve, nSubValve, overlap / valveSegmentLength ) ) + double lengthOpenForFlow = std::fabs( valve->endMD() - valve->startMD() ); + if ( accumulator->accumulateValveParameters( valve, + nSubValve, + overlap / valveSegmentLength, + lengthOpenForFlow ) ) { assignedRegularValves[superValve].insert( std::make_pair( valve, nSubValve ) ); } From 5deaddf327a5fd2f03df07a9117306826a3a2f1a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jun 2020 15:53:51 +0200 Subject: [PATCH 12/24] #6139 MSW IDC : Use length fraction for calculation of parameters Fix typo --- .../RicMswValveAccumulators.cpp | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp index 07d539542f..6a3dd73c6b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp @@ -44,11 +44,25 @@ bool RicMswICDAccumulator::accumulateValveParameters( const RimWellPathValve* we CVF_ASSERT( wellPathValve ); if ( wellPathValve->componentType() == RiaDefines::ICV || wellPathValve->componentType() == RiaDefines::ICD ) { + double lengthFraction = 1.0; + + if ( wellPathValve->componentType() == RiaDefines::WellPathComponentType::ICD ) + { + std::pair valveSegment = wellPathValve->valveSegments()[subValve]; + double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); + if ( totalValveLengthOpenForFlow > 1.0e-8 ) + { + lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; + } + } + + double combinedFraction = contributionFraction * lengthFraction; + double icdOrificeRadius = wellPathValve->orificeDiameter( m_unitSystem ) / 2; double icdArea = icdOrificeRadius * icdOrificeRadius * cvf::PI_D; - m_areaSum += icdArea * contributionFraction; - m_coefficientCalculator.addValueAndWeight( wellPathValve->flowCoefficient(), icdArea * contributionFraction ); + m_areaSum += icdArea * combinedFraction; + m_coefficientCalculator.addValueAndWeight( wellPathValve->flowCoefficient(), icdArea * combinedFraction ); return true; } return false; @@ -98,15 +112,6 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w m_deviceOpen = m_deviceOpen || params->isOpen(); if ( params->isOpen() ) { - std::array values = params->doubleValues(); - for ( size_t i = 0; i < (size_t)AICD_NUM_PARAMS; ++i ) - { - if ( RiaStatisticsTools::isValidNumber( values[i] ) ) - { - m_meanCalculators[i].addValueAndWeight( values[i], contributionFraction ); - } - } - std::pair valveSegment = wellPathValve->valveSegments()[subValve]; double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); double lengthFraction = 1.0; @@ -115,6 +120,17 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; } + double combinedFraction = contributionFraction * lengthFraction; + + std::array values = params->doubleValues(); + for ( size_t i = 0; i < (size_t)AICD_NUM_PARAMS; ++i ) + { + if ( RiaStatisticsTools::isValidNumber( values[i] ) ) + { + m_meanCalculators[i].addValueAndWeight( values[i], combinedFraction ); + } + } + // https://github.com/OPM/ResInsight/issues/6126 // // flowScalingFactor = 1 / (length_fraction * N_AICDs) @@ -122,11 +138,11 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w // length_fraction = length_COMPSEGS / Sum_lenght_COMPSEGS_for_valve // N_AICDs = number of AICDs in perforation interval - double divisor = wellPathValve->valveLocations().size() * lengthFraction * contributionFraction; + double divisor = wellPathValve->valveLocations().size() * combinedFraction; m_accumulatedFlowScalingFactorDivisor += divisor; - m_accumulatedLength += lengthFraction * contributionFraction; + m_accumulatedLength += combinedFraction; } } return true; From 277ff167a3886b97fc32f87651e30b1aa6287b26 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 24 Jun 2020 15:51:19 +0200 Subject: [PATCH 13/24] #6142 MSW valve export : Guard export if two valve intervals overlap --- .../RicWellPathExportMswCompletionsImpl.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index e869313b3b..4108b134a9 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -241,6 +241,36 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( return; } + // Check if there exist overlap between valves in a perforation interval + for ( const auto& perfInterval : perforationIntervals ) + { + for ( const auto& valve : perfInterval->valves() ) + { + for ( const auto& otherValve : perfInterval->valves() ) + { + if ( otherValve != valve ) + { + bool hasIntersection = + !( ( valve->endMD() < otherValve->startMD() ) || ( otherValve->endMD() < valve->startMD() ) ); + + if ( hasIntersection ) + { + RiaLogging::error( + QString( "Valve overlap detected for perforation interval : %1" ).arg( perfInterval->name() ) ); + + RiaLogging::error( "Name of valves" ); + RiaLogging::error( valve->name() ); + RiaLogging::error( otherValve->name() ); + + RiaLogging::error( "Failed to export well segments" ); + + return; + } + } + } + } + } + RicMswExportInfo exportInfo = generatePerforationsMswExportInfo( eclipseCase, wellPath, timeStep, perforationIntervals ); From 63f964da8268011dbd0a5009a17a8fae0ba18ded Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 26 Jun 2020 12:29:07 +0200 Subject: [PATCH 14/24] MSW : Make sure the ICV is using the full perforation interval #6152 --- .../Completions/RimWellPathValve.cpp | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp index d6c4573bd8..e5287f11ce 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp @@ -264,28 +264,39 @@ std::vector> RimWellPathValve::valveSegments() const RimPerforationInterval* perforationInterval = nullptr; this->firstAncestorOrThisOfType( perforationInterval ); - double startMD = this->startMD(); - double endMD = this->endMD(); - - std::vector valveMDs = valveLocations(); - std::vector> segments; - segments.reserve( valveMDs.size() ); - - for ( size_t i = 0; i < valveMDs.size(); ++i ) + if ( componentType() == RiaDefines::WellPathComponentType::ICV ) { - double segmentStart = startMD; - double segmentEnd = endMD; - if ( i > 0 ) - { - segmentStart = 0.5 * ( valveMDs[i - 1] + valveMDs[i] ); - } - if ( i < valveMDs.size() - 1u ) - { - segmentEnd = 0.5 * ( valveMDs[i] + valveMDs[i + 1] ); - } - segments.push_back( std::make_pair( segmentStart, segmentEnd ) ); + // Flow for ICV is defined as the complete perforation interval + + segments.push_back( std::make_pair( perforationInterval->startMD(), perforationInterval->endMD() ) ); } + else + { + // ICD/AICD : Use the valve start/end, can be a subset of perforation interval + + double startMD = this->startMD(); + double endMD = this->endMD(); + + std::vector valveMDs = valveLocations(); + segments.reserve( valveMDs.size() ); + + for ( size_t i = 0; i < valveMDs.size(); ++i ) + { + double segmentStart = startMD; + double segmentEnd = endMD; + if ( i > 0 ) + { + segmentStart = 0.5 * ( valveMDs[i - 1] + valveMDs[i] ); + } + if ( i < valveMDs.size() - 1u ) + { + segmentEnd = 0.5 * ( valveMDs[i] + valveMDs[i + 1] ); + } + segments.push_back( std::make_pair( segmentStart, segmentEnd ) ); + } + } + return segments; } From c50ace8a01813c8f53d20fd2e13c2a02cbdd0bcd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 26 Jun 2020 12:58:15 +0200 Subject: [PATCH 15/24] #6153 MSW: Do not report WSEGVALV for inactive cells --- .../RicWellPathExportMswCompletionsImpl.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 4108b134a9..13ccc3b825 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -714,16 +714,21 @@ void RicWellPathExportMswCompletionsImpl::generateWsegvalvTable( RifTextDataTabl if ( !icd->subSegments().empty() ) { CVF_ASSERT( icd->subSegments().size() == 1u ); - if ( icd->completionType() == RigCompletionData::PERFORATION_ICD || - icd->completionType() == RigCompletionData::PERFORATION_ICV ) + + auto firstSubSegment = icd->subSegments().front(); + if ( !firstSubSegment->intersections().empty() ) { - formatter.comment( icd->label() ); + if ( icd->completionType() == RigCompletionData::PERFORATION_ICD || + icd->completionType() == RigCompletionData::PERFORATION_ICV ) + { + formatter.comment( icd->label() ); + } + formatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); + formatter.add( firstSubSegment->segmentNumber() ); + formatter.add( icd->flowCoefficient() ); + formatter.add( QString( "%1" ).arg( icd->area(), 8, 'g', 4 ) ); + formatter.rowCompleted(); } - formatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); - formatter.add( icd->subSegments().front()->segmentNumber() ); - formatter.add( icd->flowCoefficient() ); - formatter.add( QString( "%1" ).arg( icd->area(), 8, 'g', 4 ) ); - formatter.rowCompleted(); } } } From 396a71da37b0813e19787e265d95947e26a2d1e4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Jun 2020 20:16:42 +0200 Subject: [PATCH 16/24] #6039 Well Allocation Plot: Update flow rate curves after change of visibility --- .../Flow/RimWellFlowRateCurve.cpp | 32 ++++++++++++++----- .../Flow/RimWellFlowRateCurve.h | 1 + 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index b21101b617..25dedf64b1 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -161,16 +161,13 @@ void RimWellFlowRateCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() ) - { - m_qwtPlotCurve->setTitle( createCurveAutoName() ); + m_qwtPlotCurve->setTitle( createCurveAutoName() ); - updateStackedPlotData(); + updateStackedPlotData(); - updateZoomInParentPlot(); + updateZoomInParentPlot(); - if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); - } + if ( m_parentQwtPlot ) m_parentQwtPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -186,7 +183,11 @@ void RimWellFlowRateCurve::updateCurveAppearance() firstAncestorOrThisOfTypeAsserted( wellLogTrack ); std::map> stackedCurveGroups = wellLogTrack->visibleStackedCurves(); const std::vector& curveGroup = stackedCurveGroups[this->m_groupId]; - isLastCurveInGroup = ( curveGroup.back() == this ); + + if ( !curveGroup.empty() ) + { + isLastCurveInGroup = ( curveGroup.back() == this ); + } } if ( isUsingConnectionNumberDepthType() ) @@ -241,6 +242,21 @@ void RimWellFlowRateCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd uiOrdering.skipRemainingFields(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellFlowRateCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( changedField == &m_showCurve ) + { + loadDataAndUpdate( true ); + } + + RimWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h index d4fed7d0f6..7f1ff70405 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h @@ -61,6 +61,7 @@ protected: void updateCurveAppearance() override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); private: bool isUsingConnectionNumberDepthType() const; From 9b7e83fbf9d3e7b7c2abf2e0612421cb4e95b786 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 1 Jul 2020 12:59:12 +0200 Subject: [PATCH 17/24] Set version to 2020.04.2-patch.01 --- ResInsightVersion.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index e592ffef24..83b1926838 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,16 +1,16 @@ set(RESINSIGHT_MAJOR_VERSION 2020) set(RESINSIGHT_MINOR_VERSION 04) -set(RESINSIGHT_PATCH_VERSION 1) +set(RESINSIGHT_PATCH_VERSION 2) # Opional text with no restrictions -#set(RESINSIGHT_VERSION_TEXT "-RC03") +set(RESINSIGHT_VERSION_TEXT "-patch") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -#set(RESINSIGHT_DEV_VERSION ".05") +set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") From 2188a33d4ed7c06a6fd4b68f4f07896a8359310f Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 11 Aug 2020 13:56:08 +0200 Subject: [PATCH 18/24] #6157 Move splitting of MSW segments to just before WELSEGS output * this is to avoid it impacting on COMPSEGS and other output --- ...sTransmissibilityCalculationFeatureImp.cpp | 2 +- .../RicMswExportInfo.cpp | 18 +- .../RicMswExportInfo.h | 10 +- .../RicMswSegment.cpp | 8 + .../CompletionExportCommands/RicMswSegment.h | 2 + .../RicMswSubSegment.cpp | 18 - .../RicMswSubSegment.h | 6 +- .../RicWellPathExportMswCompletionsImpl.cpp | 761 +++++++++--------- .../RicWellPathExportMswCompletionsImpl.h | 83 +- .../ReservoirDataModel/RigWellLogExtractor.h | 3 + 10 files changed, 462 insertions(+), 449 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 0577247615..d2335f93bf 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -208,7 +208,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell RiaEclipseUnitTools::UnitSystem unitSystem = caseData->unitsType(); bool isMainBore = false; - for ( std::shared_ptr location : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr location : exportInfo.segments() ) { for ( std::shared_ptr completion : location->completions() ) { diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.cpp index 2305349629..5cb04a8d84 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.cpp @@ -75,18 +75,18 @@ void RicMswExportInfo::setHasSubGridIntersections( bool subGridIntersections ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicMswExportInfo::addWellSegment( std::shared_ptr location ) +void RicMswExportInfo::addSegment( std::shared_ptr location ) { - m_wellSegmentLocations.push_back( location ); + m_segments.push_back( location ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicMswExportInfo::sortLocations() +void RicMswExportInfo::sortSegments() { - std::sort( m_wellSegmentLocations.begin(), - m_wellSegmentLocations.end(), + std::sort( m_segments.begin(), + m_segments.end(), []( std::shared_ptr lhs, std::shared_ptr rhs ) { return *lhs < *rhs; } ); } @@ -181,15 +181,15 @@ double RicMswExportInfo::defaultDoubleValue() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector>& RicMswExportInfo::wellSegmentLocations() const +const std::vector>& RicMswExportInfo::segments() const { - return m_wellSegmentLocations; + return m_segments; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector>& RicMswExportInfo::wellSegmentLocations() +std::vector>& RicMswExportInfo::segments() { - return m_wellSegmentLocations; + return m_segments; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.h index 2ed79debee..ecf320ea85 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswExportInfo.h @@ -45,8 +45,8 @@ public: void setRoughnessFactor( double roughnessFactor ); void setHasSubGridIntersections( bool subGridIntersections ); - void addWellSegment( std::shared_ptr location ); - void sortLocations(); + void addSegment( std::shared_ptr location ); + void sortSegments(); const RimWellPath* wellPath() const; RiaEclipseUnitTools::UnitSystem unitSystem() const; @@ -60,8 +60,8 @@ public: bool hasSubGridIntersections() const; static double defaultDoubleValue(); - const std::vector>& wellSegmentLocations() const; - std::vector>& wellSegmentLocations(); + const std::vector>& segments() const; + std::vector>& segments(); private: const RimWellPath* m_wellPath; @@ -74,5 +74,5 @@ private: QString m_pressureDropText; bool m_hasSubGridIntersections; - std::vector> m_wellSegmentLocations; + std::vector> m_segments; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp index e78e7f261d..fb2bfb9bee 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp @@ -71,6 +71,14 @@ double RicMswSegment::endMD() const return m_endMD; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicMswSegment::length() const +{ + return m_endMD - m_startMD; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h index 3e12e874e6..3918f32f61 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h @@ -41,6 +41,8 @@ public: double startMD() const; double endMD() const; + double length() const; + double deltaMD() const; double startTVD() const; double endTVD() const; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.cpp index 827f6ba114..ecf45989f7 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.cpp @@ -73,7 +73,6 @@ RicMswSubSegment::RicMswSubSegment( double startMD, double endMD, double startTV , m_startTVD( startTVD ) , m_endTVD( endTVD ) , m_segmentNumber( -1 ) - , m_attachedSegmentNumber( -1 ) { } @@ -133,14 +132,6 @@ int RicMswSubSegment::segmentNumber() const return m_segmentNumber; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RicMswSubSegment::attachedSegmentNumber() const -{ - return m_attachedSegmentNumber; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -148,15 +139,6 @@ void RicMswSubSegment::setSegmentNumber( int segmentNumber ) { m_segmentNumber = segmentNumber; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicMswSubSegment::setAttachedSegmentNumber( int attachedSegmentNumber ) -{ - m_attachedSegmentNumber = attachedSegmentNumber; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.h index 2dbeac75bb..a3f6cf8b04 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSubSegment.h @@ -60,11 +60,8 @@ public: double endTVD() const; double deltaTVD() const; - int segmentNumber() const; - int attachedSegmentNumber() const; - + int segmentNumber() const; void setSegmentNumber( int segmentNumber ); - void setAttachedSegmentNumber( int attachedSegmentNumber ); void addIntersection( std::shared_ptr intersection ); const std::vector>& intersections() const; @@ -76,7 +73,6 @@ private: double m_startTVD; double m_endTVD; int m_segmentNumber; - int m_attachedSegmentNumber; std::vector> m_intersections; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 13ccc3b825..76602b3691 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -53,32 +53,6 @@ #include -//-------------------------------------------------------------------------------------------------- -/// Internal definitions -//-------------------------------------------------------------------------------------------------- -class SubSegmentIntersectionInfo -{ -public: - SubSegmentIntersectionInfo( size_t globCellIndex, - double startTVD, - double endTVD, - double startMD, - double endMD, - cvf::Vec3d lengthsInCell ); - static std::vector - spiltIntersectionSegmentsToMaxLength( const RigWellPath* pathGeometry, - const std::vector& intersections, - double maxSegmentLength ); - static int numberOfSplittedSegments( double startMd, double endMd, double maxSegmentLength ); - - size_t globCellIndex; - double startTVD; - double endTVD; - double startMD; - double endMD; - cvf::Vec3d intersectionLengthsInCellCS; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -129,10 +103,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( fractureExportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); } - exportWellSegmentsForFractures( exportSettings.caseToApply, - fractureExportFile, - wellPath, - wellPath->fractureCollection()->activeFractures() ); + exportWellSegmentsForFractures( exportSettings.caseToApply, fractureExportFile, wellPath ); } if ( exportPerforations ) @@ -152,8 +123,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( exportWellSegmentsForPerforations( exportSettings.caseToApply, perforationsExportFile, wellPath, - exportSettings.timeStep, - wellPath->perforationIntervalCollection()->activePerforations() ); + exportSettings.timeStep ); } if ( exportFishbones ) @@ -170,10 +140,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( fishbonesExportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName ); } - exportWellSegmentsForFishbones( exportSettings.caseToApply, - fishbonesExportFile, - wellPath, - wellPath->fishbonesCollection()->activeFishbonesSubs() ); + exportWellSegmentsForFishbones( exportSettings.caseToApply, fishbonesExportFile, wellPath ); } } } @@ -183,9 +150,10 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, - const RimWellPath* wellPath, - const std::vector& fractures ) + const RimWellPath* wellPath ) { + auto fractures = wellPath->fractureCollection()->activeFractures(); + if ( eclipseCase == nullptr ) { RiaLogging::error( @@ -197,7 +165,10 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEcl QTextStream stream( exportFile.get() ); RifTextDataTableFormatter formatter( stream ); - generateWelsegsTable( formatter, exportInfo ); + + double maxSegmentLength = wellPath->fractureCollection()->mswParameters()->maxSegmentLength(); + + generateWelsegsTable( formatter, exportInfo, maxSegmentLength ); generateCompsegTables( formatter, exportInfo ); } @@ -206,9 +177,10 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFractures( RimEcl //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEclipseCase* eclipseCase, std::shared_ptr exportFile, - const RimWellPath* wellPath, - const std::vector& fishbonesSubs ) + const RimWellPath* wellPath ) { + auto fishbonesSubs = wellPath->fishbonesCollection()->activeFishbonesSubs(); + if ( eclipseCase == nullptr ) { RiaLogging::error( "Export Well Segments: Cannot export completions data without specified eclipse case" ); @@ -220,7 +192,9 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEcl QTextStream stream( exportFile.get() ); RifTextDataTableFormatter formatter( stream ); - generateWelsegsTable( formatter, exportInfo ); + double maxSegmentLength = wellPath->fishbonesCollection()->mswParameters()->maxSegmentLength(); + + generateWelsegsTable( formatter, exportInfo, maxSegmentLength ); generateCompsegTables( formatter, exportInfo ); generateWsegvalvTable( formatter, exportInfo ); } @@ -228,13 +202,13 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForFishbones( RimEcl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( - RimEclipseCase* eclipseCase, - std::shared_ptr exportFile, - const RimWellPath* wellPath, - int timeStep, - const std::vector& perforationIntervals ) +void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( RimEclipseCase* eclipseCase, + std::shared_ptr exportFile, + const RimWellPath* wellPath, + int timeStep ) { + auto perforationIntervals = wellPath->perforationIntervalCollection()->activePerforations(); + if ( eclipseCase == nullptr ) { RiaLogging::error( "Export Well Segments: Cannot export completions data without specified eclipse case" ); @@ -277,7 +251,9 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( QTextStream stream( exportFile.get() ); RifTextDataTableFormatter formatter( stream ); - generateWelsegsTable( formatter, exportInfo ); + double maxSegmentLength = wellPath->perforationIntervalCollection()->mswParameters()->maxSegmentLength(); + + generateWelsegsTable( formatter, exportInfo, maxSegmentLength ); generateCompsegTables( formatter, exportInfo ); generateWsegvalvTable( formatter, exportInfo ); generateWsegAicdTable( formatter, exportInfo ); @@ -287,7 +263,8 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForPerforations( /// //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTableFormatter& formatter, - const RicMswExportInfo& exportInfo ) + const RicMswExportInfo& exportInfo, + double maxSegmentLength ) { formatter.keyword( "WELSEGS" ); @@ -329,57 +306,39 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable formatter.header( header ); } + int segmentNumber = 2; // There's an implicit segment number 1. { double prevMD = exportInfo.initialMD(); double prevTVD = exportInfo.initialTVD(); formatter.comment( "Main Stem Segments" ); - for ( std::shared_ptr location : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr segment : exportInfo.segments() ) { - double depth = 0; - double length = 0; + segment->setSegmentNumber( segmentNumber ); - double midPointMD = 0.5 * ( location->startMD() + location->endMD() ); - double midPointTVD = 0.5 * ( location->startTVD() + location->endTVD() ); - - if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) + if ( segment->subIndex() != cvf::UNDEFINED_SIZE_T ) { - depth = midPointTVD - prevTVD; - length = midPointMD - prevMD; - } - else - { - depth = midPointTVD; - length = midPointMD; - } - - if ( location->subIndex() != cvf::UNDEFINED_SIZE_T ) - { - QString comment = location->label() + QString( ", sub %1" ).arg( location->subIndex() ); + QString comment = segment->label() + QString( ", sub %1" ).arg( segment->subIndex() ); formatter.comment( comment ); } - formatter.add( location->segmentNumber() ).add( location->segmentNumber() ); - formatter.add( 1 ); // All segments on main stem are branch 1 - formatter.add( location->segmentNumber() - 1 ); // All main stem segments are connected to the segment below - // them - formatter.add( length ); - formatter.add( depth ); - formatter.add( exportInfo.linerDiameter() ); - formatter.add( exportInfo.roughnessFactor() ); - formatter.rowCompleted(); - prevMD = midPointMD; - prevTVD = midPointTVD; + writeMainBoreWelsegsSegment( segment, formatter, exportInfo, maxSegmentLength, &segmentNumber, &prevMD, &prevTVD ); } } { - generateWelsegsSegments( formatter, exportInfo, {RigCompletionData::FISHBONES_ICD, RigCompletionData::FISHBONES} ); - generateWelsegsSegments( formatter, exportInfo, {RigCompletionData::FRACTURE} ); + generateWelsegsSegments( formatter, + exportInfo, + {RigCompletionData::FISHBONES_ICD, RigCompletionData::FISHBONES}, + maxSegmentLength, + &segmentNumber ); + generateWelsegsSegments( formatter, exportInfo, {RigCompletionData::FRACTURE}, maxSegmentLength, &segmentNumber ); generateWelsegsSegments( formatter, exportInfo, {RigCompletionData::PERFORATION_ICD, RigCompletionData::PERFORATION_ICV, - RigCompletionData::PERFORATION_AICD} ); + RigCompletionData::PERFORATION_AICD}, + maxSegmentLength, + &segmentNumber ); } formatter.tableCompleted(); @@ -391,11 +350,15 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable void RicWellPathExportMswCompletionsImpl::generateWelsegsSegments( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo, - const std::set& exportCompletionTypes ) + const std::set& exportCompletionTypes, + double maxSegmentLength, + int* segmentNumber ) { bool generatedHeader = false; - for ( std::shared_ptr segment : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr segment : exportInfo.segments() ) { + int mainSegmentNumber = segment->segmentNumber(); + segment->setSegmentNumber( mainSegmentNumber ); for ( std::shared_ptr completion : segment->completions() ) { if ( exportCompletionTypes.count( completion->completionType() ) ) @@ -408,79 +371,22 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsSegments( if ( RigCompletionData::isValve( completion->completionType() ) ) { - if ( !completion->subSegments().empty() ) - { - formatter.comment( completion->label() ); - - auto firstSubSegment = completion->subSegments().front(); - - formatter.add( firstSubSegment->segmentNumber() ); - formatter.add( firstSubSegment->segmentNumber() ); - formatter.add( completion->branchNumber() ); - formatter.add( segment->segmentNumber() ); - - double length = 0.0; - double depth = 0.0; - - if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) - { - length = firstSubSegment->deltaMD(); - depth = firstSubSegment->deltaTVD(); - } - else - { - length = firstSubSegment->endMD(); - depth = firstSubSegment->endTVD(); - } - - formatter.add( length ); - formatter.add( depth ); - formatter.add( exportInfo.linerDiameter() ); - formatter.add( exportInfo.roughnessFactor() ); - formatter.rowCompleted(); - } + writeValveWelsegsSegment( std::dynamic_pointer_cast( completion ), + formatter, + exportInfo, + maxSegmentLength, + mainSegmentNumber, + segmentNumber ); } else { - if ( completion->completionType() == RigCompletionData::FISHBONES ) - { - formatter.comment( QString( "%1 : Sub index %2 - %3" ) - .arg( segment->label() ) - .arg( segment->subIndex() ) - .arg( completion->label() ) ); - } - else if ( completion->completionType() == RigCompletionData::FRACTURE ) - { - formatter.comment( - QString( "%1 connected to %2" ).arg( completion->label() ).arg( segment->label() ) ); - } - - for ( std::shared_ptr subSegment : completion->subSegments() ) - { - double depth = 0; - double length = 0; - - if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) - { - depth = subSegment->deltaTVD(); - length = subSegment->deltaMD(); - } - else - { - depth = subSegment->endTVD(); - length = subSegment->endMD(); - } - double diameter = segment->effectiveDiameter(); - formatter.add( subSegment->segmentNumber() ); - formatter.add( subSegment->segmentNumber() ); - formatter.add( completion->branchNumber() ); - formatter.add( subSegment->attachedSegmentNumber() ); - formatter.add( length ); - formatter.add( depth ); - formatter.add( diameter ); - formatter.add( segment->openHoleRoughnessFactor() ); - formatter.rowCompleted(); - } + writeCompletionWelsegsSegment( segment, + completion, + formatter, + exportInfo, + maxSegmentLength, + mainSegmentNumber, + segmentNumber ); } } } @@ -571,11 +477,11 @@ void RicWellPathExportMswCompletionsImpl::generateCompsegTable( { bool generatedHeader = false; - for ( std::shared_ptr location : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr segment : exportInfo.segments() ) { - double startMD = location->startMD(); + double startMD = segment->startMD(); - for ( std::shared_ptr completion : location->completions() ) + for ( std::shared_ptr completion : segment->completions() ) { if ( !completion->subSegments().empty() && exportCompletionTypes.count( completion->completionType() ) ) { @@ -690,9 +596,9 @@ void RicWellPathExportMswCompletionsImpl::generateWsegvalvTable( RifTextDataTabl { bool foundValve = false; - for ( std::shared_ptr location : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr segment : exportInfo.segments() ) { - for ( std::shared_ptr completion : location->completions() ) + for ( std::shared_ptr completion : segment->completions() ) { if ( RigCompletionData::isWsegValveTypes( completion->completionType() ) ) { @@ -751,9 +657,9 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl bool foundValve = false; - for ( std::shared_ptr location : exportInfo.wellSegmentLocations() ) + for ( std::shared_ptr segment : exportInfo.segments() ) { - for ( std::shared_ptr completion : location->completions() ) + for ( std::shared_ptr completion : segment->completions() ) { if ( completion->completionType() == RigCompletionData::PERFORATION_AICD ) { @@ -866,6 +772,29 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> + RicWellPathExportMswCompletionsImpl::createSubSegmentMDPairs( double startMD, double endMD, double maxSegmentLength ) +{ + int subSegmentCount = (int)( std::trunc( ( endMD - startMD ) / maxSegmentLength ) + 1 ); + + double subSegmentLength = ( endMD - startMD ) / subSegmentCount; + + std::vector> subSegmentMDPairs; + + double subStartMD = startMD; + double subEndMD = startMD + subSegmentLength; + for ( int i = 0; i < subSegmentCount; ++i ) + { + subSegmentMDPairs.push_back( std::make_pair( subStartMD, subEndMD ) ); + subStartMD += subSegmentLength; + subEndMD += std::min( subSegmentLength, endMD ); + } + return subSegmentMDPairs; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -900,67 +829,56 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generateFishbonesMswExport double maxSegmentLength = enableSegmentSplitting ? wellPath->fishbonesCollection()->mswParameters()->maxSegmentLength() : std::numeric_limits::infinity(); - bool foundSubGridIntersections = false; - double subStartMD = wellPath->fishbonesCollection()->startMD(); + bool foundSubGridIntersections = false; + + double subStartMD = wellPath->fishbonesCollection()->startMD(); + double subStartTVD = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, subStartMD ); + for ( RimFishbonesMultipleSubs* subs : fishbonesSubs ) { for ( auto& sub : subs->installedLateralIndices() ) { double subEndMD = subs->measuredDepth( sub.subIndex ); double subEndTVD = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, subEndMD ); - int subSegCount = - SubSegmentIntersectionInfo::numberOfSplittedSegments( subStartMD, subEndMD, maxSegmentLength ); - double subSegLen = ( subEndMD - subStartMD ) / subSegCount; - double startMd = subStartMD; - double startTvd = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, startMd ); - for ( int ssi = 0; ssi < subSegCount; ssi++ ) { - double endMd = startMd + subSegLen; - double endTvd = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, endMd ); + std::shared_ptr segment( + new RicMswSegment( subs->generatedName(), subStartMD, subEndMD, subStartTVD, subEndTVD, sub.subIndex ) ); + segment->setEffectiveDiameter( subs->effectiveDiameter( unitSystem ) ); + segment->setHoleDiameter( subs->holeDiameter( unitSystem ) ); + segment->setOpenHoleRoughnessFactor( subs->openHoleRoughnessFactor( unitSystem ) ); + segment->setSkinFactor( subs->skinFactor() ); + segment->setSourcePdmObject( subs ); - std::shared_ptr location( - new RicMswSegment( subs->generatedName(), startMd, endMd, startTvd, endTvd, sub.subIndex ) ); - location->setEffectiveDiameter( subs->effectiveDiameter( unitSystem ) ); - location->setHoleDiameter( subs->holeDiameter( unitSystem ) ); - location->setOpenHoleRoughnessFactor( subs->openHoleRoughnessFactor( unitSystem ) ); - location->setSkinFactor( subs->skinFactor() ); - location->setSourcePdmObject( subs ); + // Add completion for ICD + std::shared_ptr icdCompletion( new RicMswFishbonesICD( QString( "ICD" ), nullptr ) ); + std::shared_ptr icdSegment( + new RicMswSubSegment( subEndMD, subEndMD + 0.1, subEndTVD, subEndTVD ) ); + icdCompletion->setFlowCoefficient( subs->icdFlowCoefficient() ); + double icdOrificeRadius = subs->icdOrificeDiameter( unitSystem ) / 2; + icdCompletion->setArea( icdOrificeRadius * icdOrificeRadius * cvf::PI_D * subs->icdCount() ); - if ( ssi == 0 ) + icdCompletion->addSubSegment( icdSegment ); + segment->addCompletion( icdCompletion ); + + for ( size_t lateralIndex : sub.lateralIndices ) { - // Add completion for ICD - std::shared_ptr icdCompletion( new RicMswFishbonesICD( QString( "ICD" ), nullptr ) ); - std::shared_ptr icdSegment( - new RicMswSubSegment( subEndMD, subEndMD + 0.1, subEndTVD, subEndTVD ) ); - icdCompletion->setFlowCoefficient( subs->icdFlowCoefficient() ); - double icdOrificeRadius = subs->icdOrificeDiameter( unitSystem ) / 2; - icdCompletion->setArea( icdOrificeRadius * icdOrificeRadius * cvf::PI_D * subs->icdCount() ); - - icdCompletion->addSubSegment( icdSegment ); - location->addCompletion( icdCompletion ); - - for ( size_t lateralIndex : sub.lateralIndices ) - { - QString label = QString( "Lateral %1" ).arg( lateralIndex ); - location->addCompletion( std::make_shared( label, lateralIndex ) ); - } - assignFishbonesLateralIntersections( caseToApply, subs, location, &foundSubGridIntersections, maxSegmentLength ); + QString label = QString( "Lateral %1" ).arg( lateralIndex ); + segment->addCompletion( std::make_shared( label, lateralIndex ) ); } + assignFishbonesLateralIntersections( caseToApply, subs, segment, &foundSubGridIntersections, maxSegmentLength ); - exportInfo.addWellSegment( location ); - - startMd = endMd; - startTvd = endTvd; + exportInfo.addSegment( segment ); } - subStartMD = subEndMD; + subStartMD = subEndMD; + subStartTVD = subEndTVD; } } exportInfo.setHasSubGridIntersections( foundSubGridIntersections ); - exportInfo.sortLocations(); + exportInfo.sortSegments(); - assignBranchAndSegmentNumbers( caseToApply, &exportInfo ); + assignBranchNumbers( caseToApply, &exportInfo ); return exportInfo; } @@ -996,10 +914,6 @@ RicMswExportInfo std::vector intersections = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( caseToApply->eclipseCaseData(), coords, mds ); - double maxSegmentLength = wellPath->fractureCollection()->mswParameters()->maxSegmentLength(); - std::vector subSegIntersections = - SubSegmentIntersectionInfo::spiltIntersectionSegmentsToMaxLength( wellPathGeometry, intersections, maxSegmentLength ); - double initialMD = 0.0; if ( wellPath->fractureCollection()->mswParameters()->referenceMDType() == RimMswCompletionParameters::MANUAL_REFERENCE_MD ) @@ -1046,11 +960,8 @@ RicMswExportInfo // Main bore int mainBoreSegment = 1; - for ( const auto& cellIntInfo : subSegIntersections ) + for ( const auto& cellIntInfo : intersections ) { - double startTVD = cellIntInfo.startTVD; - double endTVD = cellIntInfo.endTVD; - size_t localGridIdx = 0u; const RigGridBase* localGrid = grid->gridAndGridLocalIdxFromGlobalCellIdx( cellIntInfo.globCellIndex, &localGridIdx ); @@ -1064,8 +975,8 @@ RicMswExportInfo size_t i = 0u, j = 0u, k = 0u; localGrid->ijkFromCellIndex( localGridIdx, &i, &j, &k ); QString label = QString( "Main stem segment %1" ).arg( ++mainBoreSegment ); - std::shared_ptr location( - new RicMswSegment( label, cellIntInfo.startMD, cellIntInfo.endMD, startTVD, endTVD ) ); + std::shared_ptr segment( + new RicMswSegment( label, cellIntInfo.startMD, cellIntInfo.endMD, cellIntInfo.startTVD(), cellIntInfo.endTVD() ) ); // Check if fractures are to be assigned to current main bore segment for ( RimWellPathFracture* fracture : fractures ) @@ -1087,15 +998,15 @@ RicMswExportInfo nullptr, nullptr ); - assignFractureIntersections( caseToApply, fracture, completionData, location, &foundSubGridIntersections ); + assignFractureCompletionsToCellSegment( caseToApply, fracture, completionData, segment, &foundSubGridIntersections ); } } - exportInfo.addWellSegment( location ); + exportInfo.addSegment( segment ); } exportInfo.setHasSubGridIntersections( foundSubGridIntersections ); - exportInfo.sortLocations(); - assignBranchAndSegmentNumbers( caseToApply, &exportInfo ); + exportInfo.sortSegments(); + assignBranchNumbers( caseToApply, &exportInfo ); return exportInfo; } @@ -1111,10 +1022,12 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp { RiaEclipseUnitTools::UnitSystem unitSystem = eclipseCase->eclipseCaseData()->unitsType(); - double initialMD = 0.0; // Start measured depth location to export MSW data for. Either based on first intersection + double initialMD = 0.0; // Start measured depth segment to export MSW data for. Either based on first intersection // with active grid, or user defined value. - std::vector subSegIntersections = generateSubSegments( eclipseCase, wellPath, initialMD ); + std::vector intersections = generateCellSegments( eclipseCase, wellPath, initialMD ); + std::vector filteredIntersections = + filterIntersections( intersections, initialMD, wellPath->wellPathGeometry(), eclipseCase ); RicMswExportInfo exportInfo( wellPath, unitSystem, @@ -1128,7 +1041,7 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp bool foundSubGridIntersections = false; - MainBoreSegments mainBoreSegments = createMainBoreSegmentsForPerforations( subSegIntersections, + MainBoreSegments mainBoreSegments = createMainBoreSegmentsForPerforations( filteredIntersections, perforationIntervals, wellPath, timeStep, @@ -1142,12 +1055,12 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp for ( std::shared_ptr segment : mainBoreSegments ) { - exportInfo.addWellSegment( segment ); + exportInfo.addSegment( segment ); } exportInfo.setHasSubGridIntersections( foundSubGridIntersections ); - exportInfo.sortLocations(); - assignBranchAndSegmentNumbers( eclipseCase, &exportInfo ); + exportInfo.sortSegments(); + assignBranchNumbers( eclipseCase, &exportInfo ); return exportInfo; } @@ -1155,10 +1068,10 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector - RicWellPathExportMswCompletionsImpl::generateSubSegments( const RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - double& initialMD ) +std::vector + RicWellPathExportMswCompletionsImpl::generateCellSegments( const RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + double& initialMD ) { const RigActiveCellInfo* activeCellInfo = eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::MATRIX_MODEL ); const RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); @@ -1166,12 +1079,12 @@ std::vector const std::vector& mds = wellPathGeometry->measureDepths(); CVF_ASSERT( !coords.empty() && !mds.empty() ); - std::vector intersectionsA = - RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( eclipseCase->eclipseCaseData(), coords, mds ); + const RigMainGrid* mainGrid = eclipseCase->mainGrid(); - const RigMainGrid* mainGrid = eclipseCase->mainGrid(); - std::vector intersections = - RigWellPathIntersectionTools::buildContinuousIntersections( intersectionsA, mainGrid ); + std::vector allIntersections = + RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( eclipseCase->eclipseCaseData(), coords, mds ); + std::vector continuousIntersections = + RigWellPathIntersectionTools::buildContinuousIntersections( allIntersections, mainGrid ); if ( wellPath->perforationIntervalCollection()->mswParameters()->referenceMDType() == RimMswCompletionParameters::MANUAL_REFERENCE_MD ) @@ -1180,7 +1093,7 @@ std::vector } else { - for ( const WellPathCellIntersectionInfo& intersection : intersections ) + for ( const WellPathCellIntersectionInfo& intersection : continuousIntersections ) { if ( activeCellInfo->isActive( intersection.globCellIndex ) ) { @@ -1207,14 +1120,7 @@ std::vector initialMD = std::min( initialMD, startOfFirstCompletion ); } - std::vector filteredIntersections = - filterIntersections( intersections, initialMD, wellPathGeometry, eclipseCase ); - - const double maxSegmentLength = wellPath->perforationIntervalCollection()->mswParameters()->maxSegmentLength(); - - return SubSegmentIntersectionInfo::spiltIntersectionSegmentsToMaxLength( wellPathGeometry, - filteredIntersections, - maxSegmentLength ); + return continuousIntersections; } //-------------------------------------------------------------------------------------------------- @@ -1306,7 +1212,7 @@ std::vector //-------------------------------------------------------------------------------------------------- RicWellPathExportMswCompletionsImpl::MainBoreSegments RicWellPathExportMswCompletionsImpl::createMainBoreSegmentsForPerforations( - const std::vector& subSegIntersections, + const std::vector& cellSegmentIntersections, const std::vector& perforationIntervals, const RimWellPath* wellPath, int timeStep, @@ -1320,15 +1226,18 @@ RicWellPathExportMswCompletionsImpl::MainBoreSegments // is a pretty large threshold based on the indicated threshold of 0.001m for MSW segments const double segmentLengthThreshold = 1.0e-3; - for ( const auto& cellIntInfo : subSegIntersections ) + for ( const auto& cellIntInfo : cellSegmentIntersections ) { const double segmentLength = std::fabs( cellIntInfo.endMD - cellIntInfo.startMD ); if ( segmentLength > segmentLengthThreshold ) { QString label = QString( "Main stem segment %1" ).arg( mainBoreSegments.size() + 2 ); - std::shared_ptr segment( - new RicMswSegment( label, cellIntInfo.startMD, cellIntInfo.endMD, cellIntInfo.startTVD, cellIntInfo.endTVD ) ); + std::shared_ptr segment( new RicMswSegment( label, + cellIntInfo.startMD, + cellIntInfo.endMD, + cellIntInfo.startTVD(), + cellIntInfo.endTVD() ) ); for ( const RimPerforationInterval* interval : perforationIntervals ) { @@ -1676,6 +1585,204 @@ void RicWellPathExportMswCompletionsImpl::moveIntersectionsToICVs( } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shared_ptr segment, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int* segmentNumber, + double* prevMD, + double* prevTVD ) +{ + CVF_ASSERT( segment && segmentNumber && prevMD && prevTVD ); + + double startMD = segment->startMD(); + double endMD = segment->endMD(); + + double startTVD = segment->startTVD(); + double endTVD = segment->endTVD(); + + std::vector> subSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); + + for ( auto mdPair : subSegments ) + { + double subStartMD = mdPair.first; + double subEndMD = mdPair.second; + + auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD ); + auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD ); + + double subStartTVD = -startPoint.z(); + double subEndTVD = -endPoint.z(); + + double depth = 0; + double length = 0; + + double midPointMD = 0.5 * ( subStartMD + subEndMD ); + double midPointTVD = 0.5 * ( subStartTVD + subEndTVD ); + + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) + { + depth = midPointTVD - *prevTVD; + length = midPointMD - *prevMD; + } + else + { + depth = midPointTVD; + length = midPointMD; + } + + formatter.add( *segmentNumber ).add( *segmentNumber ); + formatter.add( 1 ); // All segments on main stem are branch 1 + formatter.add( *segmentNumber - 1 ); // All main stem segments are connected to the segment below + // them + formatter.add( length ); + formatter.add( depth ); + formatter.add( exportInfo.linerDiameter() ); + formatter.add( exportInfo.roughnessFactor() ); + formatter.rowCompleted(); + *prevMD = midPointMD; + *prevTVD = midPointTVD; + ( *segmentNumber )++; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ptr valve, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int mainSegmentNumber, + int* segmentNumber ) +{ + CVF_ASSERT( valve ); + + formatter.comment( valve->label() ); + + auto subSegment = valve->subSegments().front(); + + double startMD = subSegment->startMD(); + double endMD = subSegment->endMD(); + + double startTVD = subSegment->startTVD(); + double endTVD = subSegment->endTVD(); + + std::vector> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); + + for ( auto mdPair : splitSegments ) + { + int subSegmentNumber = ( *segmentNumber )++; + + double subStartMD = mdPair.first; + double subEndMD = mdPair.second; + + auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD ); + auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD ); + + double subStartTVD = -startPoint.z(); + double subEndTVD = -endPoint.z(); + + double depth = 0; + double length = 0; + + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) + { + depth = subEndTVD - subStartTVD; + length = subEndMD - subStartMD; + } + else + { + depth = subEndTVD; + length = subEndMD; + } + formatter.add( subSegmentNumber ); + formatter.add( subSegmentNumber ); + formatter.add( valve->branchNumber() ); + formatter.add( mainSegmentNumber ); + + formatter.add( length ); + formatter.add( depth ); + formatter.add( exportInfo.linerDiameter() ); + formatter.add( exportInfo.roughnessFactor() ); + formatter.rowCompleted(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportMswCompletionsImpl::writeCompletionWelsegsSegment( std::shared_ptr segment, + std::shared_ptr completion, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int mainSegmentNumber, + int* segmentNumber ) +{ + if ( completion->completionType() == RigCompletionData::FISHBONES ) + { + formatter.comment( + QString( "%1 : Sub index %2 - %3" ).arg( segment->label() ).arg( segment->subIndex() ).arg( completion->label() ) ); + } + else if ( completion->completionType() == RigCompletionData::FRACTURE ) + { + formatter.comment( QString( "%1 connected to %2" ).arg( completion->label() ).arg( segment->label() ) ); + } + + for ( std::shared_ptr subSegment : completion->subSegments() ) + { + double startMD = subSegment->startMD(); + double endMD = subSegment->endMD(); + + double startTVD = subSegment->startTVD(); + double endTVD = subSegment->endTVD(); + + std::vector> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); + + for ( auto mdPair : splitSegments ) + { + int subSegmentNumber = ( *segmentNumber )++; + + double subStartMD = mdPair.first; + double subEndMD = mdPair.second; + + auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD ); + auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD ); + + double subStartTVD = -startPoint.z(); + double subEndTVD = -endPoint.z(); + + double depth = 0; + double length = 0; + + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) + { + depth = subEndTVD - subStartTVD; + length = subEndMD - subStartMD; + } + else + { + depth = subEndTVD; + length = subEndMD; + } + double diameter = segment->effectiveDiameter(); + formatter.add( subSegmentNumber ); + formatter.add( subSegmentNumber ); + formatter.add( completion->branchNumber() ); + formatter.add( mainSegmentNumber ); + formatter.add( length ); + formatter.add( depth ); + formatter.add( diameter ); + formatter.add( segment->openHoleRoughnessFactor() ); + formatter.rowCompleted(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1721,7 +1828,7 @@ void RicWellPathExportMswCompletionsImpl::moveIntersectionsToSuperICDsOrAICDs( M //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( const RimEclipseCase* caseToApply, const RimFishbonesMultipleSubs* fishbonesSubs, - std::shared_ptr location, + std::shared_ptr segment, bool* foundSubGridIntersections, double maxSegmentLength ) { @@ -1729,7 +1836,7 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c const RigMainGrid* grid = caseToApply->eclipseCaseData()->mainGrid(); - for ( std::shared_ptr completion : location->completions() ) + for ( std::shared_ptr completion : segment->completions() ) { if ( completion->completionType() != RigCompletionData::FISHBONES ) { @@ -1737,7 +1844,7 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c } std::vector> lateralCoordMDPairs = - fishbonesSubs->coordsAndMDForLateral( location->subIndex(), completion->index() ); + fishbonesSubs->coordsAndMDForLateral( segment->subIndex(), completion->index() ); if ( lateralCoordMDPairs.empty() ) { @@ -1764,13 +1871,11 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c RigWellPath pathGeometry; pathGeometry.m_wellPathPoints = lateralCoords; pathGeometry.m_measuredDepths = lateralMDs; - std::vector subSegIntersections = - SubSegmentIntersectionInfo::spiltIntersectionSegmentsToMaxLength( &pathGeometry, intersections, maxSegmentLength ); double previousExitMD = lateralMDs.front(); double previousExitTVD = -lateralCoords.front().z(); - for ( const auto& cellIntInfo : subSegIntersections ) + for ( const auto& cellIntInfo : intersections ) { size_t localGridIdx = 0u; const RigGridBase* localGrid = @@ -1785,7 +1890,7 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c size_t i = 0u, j = 0u, k = 0u; localGrid->ijkFromCellIndex( localGridIdx, &i, &j, &k ); std::shared_ptr subSegment( - new RicMswSubSegment( previousExitMD, cellIntInfo.endMD, previousExitTVD, cellIntInfo.endTVD ) ); + new RicMswSubSegment( previousExitMD, cellIntInfo.endMD, previousExitTVD, cellIntInfo.endTVD() ) ); std::shared_ptr intersection( new RicMswSubSegmentCellIntersection( gridName, @@ -1796,7 +1901,7 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c completion->addSubSegment( subSegment ); previousExitMD = cellIntInfo.endMD; - previousExitTVD = cellIntInfo.endTVD; + previousExitTVD = cellIntInfo.endTVD(); } } } @@ -1804,11 +1909,11 @@ void RicWellPathExportMswCompletionsImpl::assignFishbonesLateralIntersections( c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportMswCompletionsImpl::assignFractureIntersections( const RimEclipseCase* caseToApply, - const RimWellPathFracture* fracture, - const std::vector& completionData, - std::shared_ptr location, - bool* foundSubGridIntersections ) +void RicWellPathExportMswCompletionsImpl::assignFractureCompletionsToCellSegment( const RimEclipseCase* caseToApply, + const RimWellPathFracture* fracture, + const std::vector& completionData, + std::shared_ptr segment, + bool* foundSubGridIntersections ) { CVF_ASSERT( foundSubGridIntersections != nullptr ); @@ -1834,7 +1939,7 @@ void RicWellPathExportMswCompletionsImpl::assignFractureIntersections( const Rim subSegment->addIntersection( intersection ); } fractureCompletion->addSubSegment( subSegment ); - location->addCompletion( fractureCompletion ); + segment->addCompletion( fractureCompletion ); } //-------------------------------------------------------------------------------------------------- @@ -1884,7 +1989,7 @@ std::vector void RicWellPathExportMswCompletionsImpl::assignPerforationIntersections( const std::vector& completionData, std::shared_ptr perforationCompletion, - const SubSegmentIntersectionInfo& cellIntInfo, + const WellPathCellIntersectionInfo& cellIntInfo, double overlapStart, double overlapEnd, bool* foundSubGridIntersections ) @@ -1892,7 +1997,7 @@ void RicWellPathExportMswCompletionsImpl::assignPerforationIntersections( size_t currCellId = cellIntInfo.globCellIndex; std::shared_ptr subSegment( - new RicMswSubSegment( overlapStart, overlapEnd, cellIntInfo.startTVD, cellIntInfo.endTVD ) ); + new RicMswSubSegment( overlapStart, overlapEnd, cellIntInfo.startTVD(), cellIntInfo.endTVD() ) ); for ( const RigCompletionData& compIntersection : completionData ) { const RigCompletionDataGridCell& cell = compIntersection.completionDataGridCell(); @@ -1918,13 +2023,11 @@ void RicWellPathExportMswCompletionsImpl::assignPerforationIntersections( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportMswCompletionsImpl::assignBranchAndSegmentNumbers( const RimEclipseCase* caseToApply, - std::shared_ptr location, - int* branchNum, - int* segmentNum ) +void RicWellPathExportMswCompletionsImpl::assignBranchNumbers( const RimEclipseCase* caseToApply, + std::shared_ptr segment, + int* branchNum ) { - int icdSegmentNumber = cvf::UNDEFINED_INT; - for ( std::shared_ptr completion : location->completions() ) + for ( std::shared_ptr completion : segment->completions() ) { if ( completion->completionType() == RigCompletionData::PERFORATION ) { @@ -1935,58 +2038,33 @@ void RicWellPathExportMswCompletionsImpl::assignBranchAndSegmentNumbers( const R ++( *branchNum ); completion->setBranchNumber( *branchNum ); } - - int attachedSegmentNumber = location->segmentNumber(); - if ( icdSegmentNumber != cvf::UNDEFINED_INT ) - { - attachedSegmentNumber = icdSegmentNumber; - } - - for ( auto subSegment : completion->subSegments() ) - { - if ( completion->completionType() == RigCompletionData::FISHBONES_ICD ) - { - subSegment->setSegmentNumber( location->segmentNumber() + 1 ); - icdSegmentNumber = subSegment->segmentNumber(); - } - else if ( completion->completionType() != RigCompletionData::PERFORATION ) - { - ++( *segmentNum ); - subSegment->setSegmentNumber( *segmentNum ); - } - subSegment->setAttachedSegmentNumber( attachedSegmentNumber ); - attachedSegmentNumber = *segmentNum; - } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportMswCompletionsImpl::assignBranchAndSegmentNumbers( const RimEclipseCase* caseToApply, - RicMswExportInfo* exportInfo ) +void RicWellPathExportMswCompletionsImpl::assignBranchNumbers( const RimEclipseCase* caseToApply, + RicMswExportInfo* exportInfo ) { - int segmentNumber = 1; - int branchNumber = 1; + int branchNumber = 1; - // First loop over the locations so that each segment on the main stem is an incremental number - for ( auto location : exportInfo->wellSegmentLocations() ) + // First loop over the segments so that each segment on the main stem is an incremental number + for ( auto segment : exportInfo->segments() ) { - location->setSegmentNumber( ++segmentNumber ); - for ( auto completion : location->completions() ) + for ( auto completion : segment->completions() ) { if ( completion->completionType() == RigCompletionData::FISHBONES_ICD ) { - ++segmentNumber; // Skip a segment number because we need one for the ICD completion->setBranchNumber( ++branchNumber ); } } } - // Then assign branch and segment numbers to each completion sub segment - for ( auto location : exportInfo->wellSegmentLocations() ) + // Then assign branch numbers to each completion sub segment + for ( auto segment : exportInfo->segments() ) { - assignBranchAndSegmentNumbers( caseToApply, location, &branchNumber, &segmentNumber ); + assignBranchNumbers( caseToApply, segment, &branchNumber ); } } @@ -2001,82 +2079,3 @@ double RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( const RimWellP return tvdValue; } - -SubSegmentIntersectionInfo::SubSegmentIntersectionInfo( size_t globCellIndex, - double startTVD, - double endTVD, - double startMD, - double endMD, - cvf::Vec3d lengthsInCell ) - : globCellIndex( globCellIndex ) - , startTVD( startTVD ) - , endTVD( endTVD ) - , startMD( startMD ) - , endMD( endMD ) - , intersectionLengthsInCellCS( lengthsInCell ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector SubSegmentIntersectionInfo::spiltIntersectionSegmentsToMaxLength( - const RigWellPath* pathGeometry, - const std::vector& intersections, - double maxSegmentLength ) -{ - std::vector out; - - if ( !pathGeometry ) return out; - - for ( const auto& intersection : intersections ) - { - double segLen = intersection.endMD - intersection.startMD; - int segCount = (int)std::trunc( segLen / maxSegmentLength ) + 1; - - // Calc effective max length - double effectiveMaxSegLen = segLen / segCount; - - if ( segCount == 1 ) - { - out.emplace_back( intersection.globCellIndex, - -intersection.startPoint.z(), - -intersection.endPoint.z(), - intersection.startMD, - intersection.endMD, - intersection.intersectionLengthsInCellCS ); - } - else - { - double currStartMd = intersection.startMD; - double currEndMd = currStartMd; - double lastTvd = -intersection.startPoint.z(); - - for ( int segIndex = 0; segIndex < segCount; segIndex++ ) - { - bool lasti = segIndex == ( segCount - 1 ); - currEndMd = currStartMd + effectiveMaxSegLen; - - cvf::Vec3d segEndPoint = pathGeometry->interpolatedPointAlongWellPath( currEndMd ); - out.emplace_back( intersection.globCellIndex, - lastTvd, - lasti ? -intersection.endPoint.z() : -segEndPoint.z(), - currStartMd, - lasti ? intersection.endMD : currEndMd, - intersection.intersectionLengthsInCellCS / segCount ); - - currStartMd = currEndMd; - lastTvd = -segEndPoint.z(); - } - } - } - return out; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int SubSegmentIntersectionInfo::numberOfSplittedSegments( double startMd, double endMd, double maxSegmentLength ) -{ - return (int)( std::trunc( ( endMd - startMd ) / maxSegmentLength ) + 1 ); -} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index 4bfa71116e..caeed014b2 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -41,21 +41,18 @@ public: static void exportWellSegmentsForAllCompletions( const RicExportCompletionDataSettingsUi& exportSettings, const std::vector& wellPaths ); - static void exportWellSegmentsForFractures( RimEclipseCase* eclipseCase, - std::shared_ptr exportFile, - const RimWellPath* wellPath, - const std::vector& fractures ); + static void exportWellSegmentsForFractures( RimEclipseCase* eclipseCase, + std::shared_ptr exportFile, + const RimWellPath* wellPath ); - static void exportWellSegmentsForFishbones( RimEclipseCase* eclipseCase, - std::shared_ptr exportFile, - const RimWellPath* wellPath, - const std::vector& fishbonesSubs ); + static void exportWellSegmentsForFishbones( RimEclipseCase* eclipseCase, + std::shared_ptr exportFile, + const RimWellPath* wellPath ); - static void exportWellSegmentsForPerforations( RimEclipseCase* eclipseCase, - std::shared_ptr exportFile, - const RimWellPath* wellPath, - int timeStep, - const std::vector& perforationIntervals ); + static void exportWellSegmentsForPerforations( RimEclipseCase* eclipseCase, + std::shared_ptr exportFile, + const RimWellPath* wellPath, + int timeStep ); static RicMswExportInfo generateFishbonesMswExportInfo( const RimEclipseCase* caseToApply, const RimWellPath* wellPath, @@ -79,8 +76,8 @@ private: int timeStep, const std::vector& perforationIntervals ); - static std::vector - generateSubSegments( const RimEclipseCase* eclipseCase, const RimWellPath* wellPath, double& initialMD ); + static std::vector + generateCellSegments( const RimEclipseCase* eclipseCase, const RimWellPath* wellPath, double& initialMD ); static std::vector filterIntersections( const std::vector& intersections, @@ -88,11 +85,36 @@ private: const RigWellPath* wellPathGeometry, const RimEclipseCase* eclipseCase ); - static void generateWelsegsTable( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo ); + static void generateWelsegsTable( RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength ); + + static void writeMainBoreWelsegsSegment( std::shared_ptr segment, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int* segmentNumber, + double* prevMD, + double* prevTVD ); + static void writeValveWelsegsSegment( std::shared_ptr valve, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int mainSegmentNumber, + int* segmentNumber ); + static void writeCompletionWelsegsSegment( std::shared_ptr segment, + std::shared_ptr completion, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int mainSegmentNumber, + int* segmentNumber ); static void generateWelsegsSegments( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo, - const std::set& exportCompletionTypes ); + const std::set& exportCompletionTypes, + double maxSegmentLength, + int* segmentNumber ); static void generateWelsegsCompletionCommentHeader( RifTextDataTableFormatter& formatter, RigCompletionData::CompletionType completionType ); static void generateCompsegTables( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo ); @@ -111,8 +133,11 @@ private: typedef std::vector> MainBoreSegments; typedef std::map, std::set>> ValveContributionMap; + static std::vector> + createSubSegmentMDPairs( double startMD, double endMD, double maxSegmentLength ); + static MainBoreSegments - createMainBoreSegmentsForPerforations( const std::vector& subSegIntersections, + createMainBoreSegmentsForPerforations( const std::vector& cellSegmentIntersections, const std::vector& perforationIntervals, const RimWellPath* wellPath, int timeStep, @@ -137,15 +162,15 @@ private: static void assignFishbonesLateralIntersections( const RimEclipseCase* caseToApply, const RimFishbonesMultipleSubs* fishbonesSubs, - std::shared_ptr location, + std::shared_ptr segment, bool* foundSubGridIntersections, double maxSegmentLength ); - static void assignFractureIntersections( const RimEclipseCase* caseToApply, - const RimWellPathFracture* fracture, - const std::vector& completionData, - std::shared_ptr location, - bool* foundSubGridIntersections ); + static void assignFractureCompletionsToCellSegment( const RimEclipseCase* caseToApply, + const RimWellPathFracture* fracture, + const std::vector& completionData, + std::shared_ptr segment, + bool* foundSubGridIntersections ); static std::vector generatePerforationIntersections( const RimWellPath* wellPath, const RimPerforationInterval* perforationInterval, @@ -154,16 +179,14 @@ private: static void assignPerforationIntersections( const std::vector& completionData, std::shared_ptr perforationCompletion, - const SubSegmentIntersectionInfo& cellIntInfo, + const WellPathCellIntersectionInfo& cellIntInfo, double overlapStart, double overlapEnd, bool* foundSubGridIntersections ); - static void assignBranchAndSegmentNumbers( const RimEclipseCase* caseToApply, - std::shared_ptr location, - int* branchNum, - int* segmentNum ); - static void assignBranchAndSegmentNumbers( const RimEclipseCase* caseToApply, RicMswExportInfo* exportInfo ); + static void + assignBranchNumbers( const RimEclipseCase* caseToApply, std::shared_ptr segment, int* branchNum ); + static void assignBranchNumbers( const RimEclipseCase* caseToApply, RicMswExportInfo* exportInfo ); static double tvdFromMeasuredDepth( const RimWellPath* wellPath, double measuredDepth ); }; diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.h b/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.h index 864aaeaaa7..dbb47fe86b 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.h @@ -45,6 +45,9 @@ struct WellPathCellIntersectionInfo cvf::StructGridInterface::FaceType intersectedCellFaceIn; cvf::StructGridInterface::FaceType intersectedCellFaceOut; + + double startTVD() const { return -startPoint.z(); } + double endTVD() const { return -endPoint.z(); } }; class RigWellPath; From c3829da41b0362e63968d9c8cc1ba8f201c20833 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Aug 2020 17:23:40 +0200 Subject: [PATCH 19/24] #6156 Handle gaps and inactive cells in MSW valve accumulation --- .../RicMswValveAccumulators.cpp | 14 ++-- .../RicMswValveAccumulators.h | 4 +- .../RicWellPathExportMswCompletionsImpl.cpp | 65 +++++++++++++++---- .../RicWellPathExportMswCompletionsImpl.h | 10 ++- 4 files changed, 72 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp index 6a3dd73c6b..9df3013c22 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp @@ -100,7 +100,7 @@ RicMswAICDAccumulator::RicMswAICDAccumulator( RiaEclipseUnitTools::UnitSystem un bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, double contributionFraction, - double totalValveLengthOpenForFlow ) + double totalValveCompsegsLength ) { CVF_ASSERT( wellPathValve ); if ( wellPathValve->componentType() == RiaDefines::AICD ) @@ -115,9 +115,9 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w std::pair valveSegment = wellPathValve->valveSegments()[subValve]; double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); double lengthFraction = 1.0; - if ( totalValveLengthOpenForFlow > 1.0e-8 ) + if ( totalValveCompsegsLength > 1.0e-8 ) { - lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; + lengthFraction = valveSegmentLength / totalValveCompsegsLength; } double combinedFraction = contributionFraction * lengthFraction; @@ -133,12 +133,12 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w // https://github.com/OPM/ResInsight/issues/6126 // - // flowScalingFactor = 1 / (length_fraction * N_AICDs) + // flowScalingFactor = 1 / (lengthFraction * aicdCount) // where: - // length_fraction = length_COMPSEGS / Sum_lenght_COMPSEGS_for_valve + // lengthFraction = length_COMPSEGS / Sum_length_COMPSEGS_for_valve // N_AICDs = number of AICDs in perforation interval - - double divisor = wellPathValve->valveLocations().size() * combinedFraction; + size_t aicdCount = wellPathValve->valveLocations().size(); + double divisor = aicdCount * combinedFraction; m_accumulatedFlowScalingFactorDivisor += divisor; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h index 549436c2d8..cf1b3ea25a 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h @@ -57,7 +57,7 @@ public: bool accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, double contributionFraction, - double totalValveLengthOpenForFlow ) override; + double totalValveCompsegsLength ) override; void applyToSuperValve( std::shared_ptr valve ) override; private: @@ -75,7 +75,7 @@ public: bool accumulateValveParameters( const RimWellPathValve* wellPathValve, size_t subValve, double contributionFraction, - double totalValveLengthOpenForFlow ) override; + double totalValveCompsegsLength ) override; void applyToSuperValve( std::shared_ptr valve ) override; private: diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 76602b3691..a46f1de39f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -795,6 +795,29 @@ std::vector> return subSegmentMDPairs; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportMswCompletionsImpl::calculateLengthThroughActiveCells( + double startMD, + double endMD, + const std::vector& wellPathIntersections, + const RigActiveCellInfo* activeCellInfo ) +{ + double totalOverlap = 0.0; + for ( const WellPathCellIntersectionInfo& intersection : wellPathIntersections ) + { + if ( activeCellInfo->isActive( intersection.globCellIndex ) ) + { + double overlapStart = std::max( startMD, intersection.startMD ); + double overlapEnd = std::min( endMD, intersection.endMD ); + double overlap = std::max( 0.0, overlapEnd - overlapStart ); + totalOverlap += overlap; + } + } + return totalOverlap; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1022,7 +1045,10 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp { RiaEclipseUnitTools::UnitSystem unitSystem = eclipseCase->eclipseCaseData()->unitsType(); - double initialMD = 0.0; // Start measured depth segment to export MSW data for. Either based on first intersection + const RigActiveCellInfo* activeCellInfo = + eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + + 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. std::vector intersections = generateCellSegments( eclipseCase, wellPath, initialMD ); @@ -1049,7 +1075,11 @@ RicMswExportInfo RicWellPathExportMswCompletionsImpl::generatePerforationsMswExp &foundSubGridIntersections ); createValveCompletions( mainBoreSegments, perforationIntervals, wellPath, unitSystem ); - assignValveContributionsToSuperICDsOrAICDs( mainBoreSegments, perforationIntervals, unitSystem ); + assignValveContributionsToSuperICDsOrAICDs( mainBoreSegments, + perforationIntervals, + filteredIntersections, + activeCellInfo, + unitSystem ); moveIntersectionsToICVs( mainBoreSegments, perforationIntervals, unitSystem ); moveIntersectionsToSuperICDsOrAICDs( mainBoreSegments ); @@ -1427,6 +1457,8 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperICDsOrAICDs( const std::vector>& mainBoreSegments, const std::vector& perforationIntervals, + const std::vector& wellPathIntersections, + const RigActiveCellInfo* activeCellInfo, RiaEclipseUnitTools::UnitSystem unitSystem ) { ValveContributionMap assignedRegularValves; @@ -1465,21 +1497,32 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperICDsOrA { if ( !valve->isChecked() ) continue; + double totalValveLength = calculateLengthThroughActiveCells( valve->startMD(), + valve->endMD(), + wellPathIntersections, + activeCellInfo ); + for ( size_t nSubValve = 0u; nSubValve < valve->valveSegments().size(); ++nSubValve ) { - std::pair valveSegment = valve->valveSegments()[nSubValve]; - double valveSegmentLength = valveSegment.second - valveSegment.first; - double overlapStart = std::max( valveSegment.first, segment->startMD() ); - double overlapEnd = std::min( valveSegment.second, segment->endMD() ); - double overlap = std::max( 0.0, overlapEnd - overlapStart ); + std::pair valveSegment = valve->valveSegments()[nSubValve]; - if ( overlap > 0.0 && accumulator ) + double valveSegmentLength = calculateLengthThroughActiveCells( valveSegment.first, + valveSegment.second, + wellPathIntersections, + activeCellInfo ); + + double overlapStart = std::max( valveSegment.first, segment->startMD() ); + double overlapEnd = std::min( valveSegment.second, segment->endMD() ); + + double overlapLength = + calculateLengthThroughActiveCells( overlapStart, overlapEnd, wellPathIntersections, activeCellInfo ); + + if ( overlapLength > 0.0 && valveSegmentLength > 0.0 && accumulator ) { - double lengthOpenForFlow = std::fabs( valve->endMD() - valve->startMD() ); if ( accumulator->accumulateValveParameters( valve, nSubValve, - overlap / valveSegmentLength, - lengthOpenForFlow ) ) + overlapLength / valveSegmentLength, + totalValveLength ) ) { assignedRegularValves[superValve].insert( std::make_pair( valve, nSubValve ) ); } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index caeed014b2..0eda14e9ae 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -22,6 +22,7 @@ class RicExportCompletionDataSettingsUi; class RifTextDataTableFormatter; +class RigActiveCellInfo; class RimEclipseCase; class RimFishbonesMultipleSubs; class RimPerforationInterval; @@ -129,6 +130,11 @@ private: static void generateWsegvalvTable( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo ); static void generateWsegAicdTable( RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo ); + static double calculateLengthThroughActiveCells( double startMD, + double endMD, + const std::vector& wellPathIntersections, + const RigActiveCellInfo* activeCellInfo ); + private: typedef std::vector> MainBoreSegments; typedef std::map, std::set>> ValveContributionMap; @@ -152,7 +158,9 @@ private: static void assignValveContributionsToSuperICDsOrAICDs( const std::vector>& mainBoreSegments, const std::vector& perforationIntervals, - RiaEclipseUnitTools::UnitSystem unitSystem ); + const std::vector& wellPathIntersections, + const RigActiveCellInfo* activeCellInfo, + RiaEclipseUnitTools::UnitSystem unitSystem ); static void moveIntersectionsToICVs( const std::vector>& mainBoreSegments, const std::vector& perforationIntervals, From e19cb1a45b0028ed1ec455330c081077220d1a85 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 18 Aug 2020 10:42:34 +0200 Subject: [PATCH 20/24] Fix build issues due to unused variables --- .../RicWellPathExportMswCompletionsImpl.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index a46f1de39f..a1c15e95eb 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -1644,9 +1644,6 @@ void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shar double startMD = segment->startMD(); double endMD = segment->endMD(); - double startTVD = segment->startTVD(); - double endTVD = segment->endTVD(); - std::vector> subSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); for ( auto mdPair : subSegments ) @@ -1711,9 +1708,6 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ double startMD = subSegment->startMD(); double endMD = subSegment->endMD(); - double startTVD = subSegment->startTVD(); - double endTVD = subSegment->endTVD(); - std::vector> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); for ( auto mdPair : splitSegments ) @@ -1781,9 +1775,6 @@ void RicWellPathExportMswCompletionsImpl::writeCompletionWelsegsSegment( std::sh double startMD = subSegment->startMD(); double endMD = subSegment->endMD(); - double startTVD = subSegment->startTVD(); - double endTVD = subSegment->endTVD(); - std::vector> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); for ( auto mdPair : splitSegments ) From 6a0a6e9836bd9e4eca33d0b6664102acb4c37e42 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Aug 2020 18:50:53 +0200 Subject: [PATCH 21/24] #6345 Add wrapper class for QFileDialog --- .../UserInterface/CMakeLists_files.cmake | 2 + .../UserInterface/RiuFileDialogTools.cpp | 87 +++++++++++++++++++ .../UserInterface/RiuFileDialogTools.h | 49 +++++++++++ 3 files changed, 138 insertions(+) create mode 100644 ApplicationCode/UserInterface/RiuFileDialogTools.cpp create mode 100644 ApplicationCode/UserInterface/RiuFileDialogTools.h diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 14e5001400..8ceec80770 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -92,6 +92,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractOverlayContentFrame.h ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractLegendFrame.h ${CMAKE_CURRENT_LIST_DIR}/RiuCategoryLegendFrame.h ${CMAKE_CURRENT_LIST_DIR}/RiuScalarMapperLegendFrame.h +${CMAKE_CURRENT_LIST_DIR}/RiuFileDialogTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -183,6 +184,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractOverlayContentFrame.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuAbstractLegendFrame.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuCategoryLegendFrame.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuScalarMapperLegendFrame.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFileDialogTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/UserInterface/RiuFileDialogTools.cpp b/ApplicationCode/UserInterface/RiuFileDialogTools.cpp new file mode 100644 index 0000000000..d20692bc78 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuFileDialogTools.cpp @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuFileDialogTools.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFileDialogTools::getSaveFileName( QWidget* parent /*= nullptr*/, + const QString& caption /*= QString()*/, + const QString& dir /*= QString()*/, + const QString& filter /*= QString()*/, + QString* selectedFilter /*= nullptr */ ) +{ +#ifdef WIN32 + return QFileDialog::getSaveFileName( parent, caption, dir, filter, selectedFilter, QFileDialog::DontUseNativeDialog ); +#else + auto options = QFileDialog::DontUseNativeDialog; + return QFileDialog::getSaveFileName( parent, caption, dir, filter, selectedFilter, options ); +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiuFileDialogTools::getOpenFileNames( QWidget* parent /*= nullptr*/, + const QString& caption /*= QString()*/, + const QString& dir /*= QString()*/, + const QString& filter /*= QString()*/, + QString* selectedFilter /*= nullptr */ ) +{ +#ifdef WIN32 + return QFileDialog::getOpenFileNames( parent, caption, dir, filter, selectedFilter ); +#else + auto options = QFileDialog::DontUseNativeDialog; + return QFileDialog::getOpenFileNames( parent, caption, dir, filter, selectedFilter, options ); +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFileDialogTools::getExistingDirectory( QWidget* parent /*= nullptr*/, + const QString& caption /*= QString()*/, + const QString& dir /*= QString() */ ) +{ +#ifdef WIN32 + return QFileDialog::getExistingDirectory( parent, caption, dir ); +#else + auto options = QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog; + return QFileDialog::getExistingDirectory( parent, caption, dir, options ); +#endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFileDialogTools::getOpenFileName( QWidget* parent /*= nullptr*/, + const QString& caption /*= QString()*/, + const QString& dir /*= QString()*/, + const QString& filter /*= QString()*/, + QString* selectedFilter /*= nullptr */ ) +{ +#ifdef WIN32 + return getOpenFileName( parent, caption, dir, filter, selectedFilter ); +#else + auto options = QFileDialog::DontUseNativeDialog; + return getOpenFileName( parent, caption, dir, filter, selectedFilter, options ); +#endif +} diff --git a/ApplicationCode/UserInterface/RiuFileDialogTools.h b/ApplicationCode/UserInterface/RiuFileDialogTools.h new file mode 100644 index 0000000000..9eb8abec05 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuFileDialogTools.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +class QWidget; + +namespace RiuFileDialogTools +{ +QString getSaveFileName( QWidget* parent = nullptr, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + QString* selectedFilter = nullptr ); + +QStringList getOpenFileNames( QWidget* parent = nullptr, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + QString* selectedFilter = nullptr ); + +QString + getExistingDirectory( QWidget* parent = nullptr, const QString& caption = QString(), const QString& dir = QString() ); + +QString getOpenFileName( QWidget* parent = nullptr, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + QString* selectedFilter = nullptr ); + +} // namespace RiuFileDialogTools From 1adf97b075823217b4e0a08ed8f97925293e8c2b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Aug 2020 18:56:12 +0200 Subject: [PATCH 22/24] #6345 Remove obsolete include of QFileDialog --- .../EclipseCommands/RicImportEclipseCasesFeature.cpp | 2 +- .../RicImportInputEclipseCaseFeature.cpp | 1 - .../RicExportSelectedWellPathsFeature.cpp | 11 ++++++----- .../ExportCommands/RicExportToLasFileFeature.cpp | 1 - .../RicExportVisibleWellPathsFeature.cpp | 1 - .../RicSnapshotAllPlotsToFileFeature.cpp | 2 +- .../RicSnapshotAllViewsToFileFeature.cpp | 2 +- .../RicSnapshotViewToClipboardFeature.cpp | 1 - .../RicCreatePlotFromSelectionFeature.cpp | 1 - .../Commands/RicConvertGroupToEnsembleFeature.cpp | 1 - .../Commands/RicExportContourMapToTextFeature.cpp | 2 +- .../Commands/RicImportEnsembleFeature.cpp | 1 - .../Commands/RicImportObservedDataInMenuFeature.cpp | 1 - .../RicImportObservedFmuDataInMenuFeature.cpp | 1 - .../Commands/RicImportSummaryCaseFeature.cpp | 1 - .../Commands/RicImportSummaryCasesFeature.cpp | 2 +- .../Commands/RicImportSummaryGroupFeature.cpp | 1 - ApplicationCode/Commands/RicResampleDialog.cpp | 1 - .../Commands/RicSummaryCaseRestartDialog.cpp | 3 ++- .../WellLogCommands/RicMoveWellLogFilesFeature.cpp | 1 - .../Summary/RimSummaryCaseCollection.cpp | 2 +- .../UserInterface/RiuMultiCaseImportDialog.cpp | 12 ++++++------ 22 files changed, 20 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp index 5f61596cbc..87f5738b17 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -32,7 +32,7 @@ #include "cafSelectionManager.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportEclipseCasesFeature, "RicImportEclipseCasesFeature" ); diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp index fefc1787bd..7614613f81 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp @@ -35,7 +35,6 @@ #include "cafSelectionManager.h" #include -#include CAF_CMD_SOURCE_INIT( RicImportInputEclipseCaseFeature, "RicImportInputEclipseCaseFeature" ); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp index c186d1bc5c..e7d3b4c9f5 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportSelectedWellPathsFeature.cpp @@ -37,7 +37,8 @@ #include "cafSelectionManagerTools.h" #include -#include +#include +#include #include @@ -124,10 +125,10 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream( QTextStre stream << "WELLNAME: '" << caf::Utils::makeValidFileBasename( exportName ) << "'" << endl; auto numberFormat = RifTextDataTableDoubleFormatting( RIF_FLOAT, 2 ); - formatter.header( { { "X", numberFormat, RIGHT }, - { "Y", numberFormat, RIGHT }, - { "TVDMSL", numberFormat, RIGHT }, - { useMdRkb ? "MDRKB" : "MDMSL", numberFormat, RIGHT } } ); + formatter.header( {{"X", numberFormat, RIGHT}, + {"Y", numberFormat, RIGHT}, + {"TVDMSL", numberFormat, RIGHT}, + {useMdRkb ? "MDRKB" : "MDMSL", numberFormat, RIGHT}} ); while ( currMd < endMd ) { diff --git a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp index f79eb8e15e..61c6949ea2 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp @@ -36,7 +36,6 @@ #include "cafSelectionManager.h" #include -#include CAF_CMD_SOURCE_INIT( RicExportToLasFileFeature, "RicExportToLasFileFeature" ); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportVisibleWellPathsFeature.cpp index e78efb064f..cf771bd412 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportVisibleWellPathsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportVisibleWellPathsFeature.cpp @@ -35,7 +35,6 @@ #include "cafSelectionManagerTools.h" #include -#include #include #include diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index d74f812dcf..1fc3cd6103 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index f9a7ba69df..ca2d822d18 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp index 22c51b3c8e..10022849ba 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp index a2705891e9..e16805e1ee 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicCreatePlotFromSelectionFeature.cpp @@ -31,7 +31,6 @@ #include "cafSelectionManager.h" #include -#include CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelectionFeature" ); diff --git a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp index ccef8259a0..b5f91cba6a 100644 --- a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp @@ -43,7 +43,6 @@ #include "cafSelectionManagerTools.h" #include -#include #include #include diff --git a/ApplicationCode/Commands/RicExportContourMapToTextFeature.cpp b/ApplicationCode/Commands/RicExportContourMapToTextFeature.cpp index 495b9d870e..f5c556d7f1 100644 --- a/ApplicationCode/Commands/RicExportContourMapToTextFeature.cpp +++ b/ApplicationCode/Commands/RicExportContourMapToTextFeature.cpp @@ -42,7 +42,7 @@ #include "cafUtils.h" #include -#include +#include #include diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp index c873a0c9d6..4a9a087f20 100644 --- a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -44,7 +44,6 @@ #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include -#include #include #include diff --git a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp index 1e055fcf7d..833370ff84 100644 --- a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp @@ -28,7 +28,6 @@ #include "RimSummaryObservedDataFile.h" #include -#include CAF_CMD_SOURCE_INIT( RicImportObservedDataInMenuFeature, "RicImportObservedDataInMenuFeature" ); diff --git a/ApplicationCode/Commands/RicImportObservedFmuDataInMenuFeature.cpp b/ApplicationCode/Commands/RicImportObservedFmuDataInMenuFeature.cpp index 59478bd5ba..1d145d846d 100644 --- a/ApplicationCode/Commands/RicImportObservedFmuDataInMenuFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedFmuDataInMenuFeature.cpp @@ -28,7 +28,6 @@ #include "RimSummaryObservedDataFile.h" #include -#include CAF_CMD_SOURCE_INIT( RicImportObservedFmuDataInMenuFeature, "RicImportObservedFmuDataInMenuFeature" ); diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index 79db055f29..af42681a94 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -34,7 +34,6 @@ #include "RiuPlotMainWindow.h" #include -#include CAF_CMD_SOURCE_INIT( RicImportSummaryCaseFeature, "RicImportSummaryCaseFeature" ); diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index f8fc862179..7e0d2b907d 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -51,7 +51,7 @@ #include "cafSelectionManagerTools.h" #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicImportSummaryCasesFeature, "RicImportSummaryCasesFeature" ); diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp index a04dd703bc..522e396a38 100644 --- a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp @@ -40,7 +40,6 @@ #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include -#include #include #include diff --git a/ApplicationCode/Commands/RicResampleDialog.cpp b/ApplicationCode/Commands/RicResampleDialog.cpp index d4ef02b774..729c4c1c67 100644 --- a/ApplicationCode/Commands/RicResampleDialog.cpp +++ b/ApplicationCode/Commands/RicResampleDialog.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 6278b5a47e..043272e0e3 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -41,7 +41,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/ApplicationCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp index 85f252470a..d9dade3012 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicMoveWellLogFilesFeature.cpp @@ -29,7 +29,6 @@ #include "cafSelectionManagerTools.h" #include -#include CAF_CMD_SOURCE_INIT( RicMoveWellLogFilesFeature, "RicMoveWellLogFilesFeature" ); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 0903337106..2641532ace 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -35,7 +35,7 @@ #include "cafPdmFieldIOScriptability.h" -#include +#include #include #include diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index f03076ef4b..42ca1d1797 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -20,11 +20,11 @@ #include "RiaApplication.h" +#include "RiuFileDialogTools.h" #include "RiuTools.h" #include "ui_RiuMultiCaseImportDialog.h" -#include #include #include #include @@ -101,11 +101,11 @@ RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog() //-------------------------------------------------------------------------------------------------- void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() { - QString selectedFolder = - QFileDialog::getExistingDirectory( this, - "Select an Eclipse case search folder", - RiaApplication::instance()->lastUsedDialogDirectory( "MULTICASEIMPORT" ) ); - QStringList folderNames = m_searchFolders->stringList(); + QString selectedFolder = RiuFileDialogTools::getExistingDirectory( this, + "Select an Eclipse case search folder", + RiaApplication::instance()->lastUsedDialogDirectory( + "MULTICASEIMPORT" ) ); + QStringList folderNames = m_searchFolders->stringList(); if ( !folderNames.contains( selectedFolder ) ) { From 665b475e9f7ebab39467ff73a3a14d0ccc515e97 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Aug 2020 18:56:44 +0200 Subject: [PATCH 23/24] #6345 Use wrapper class instead of QFileDialog --- .../Application/RiaGuiApplication.cpp | 8 +++++--- .../RicImportPolylinesAnnotationFeature.cpp | 14 ++++++++------ .../RicExportObjectAndFieldKeywordsFeature.cpp | 10 +++++----- .../RicOpenProjectFeature.cpp | 11 ++++++----- .../RicRunCommandFileFeature.cpp | 11 ++++++----- ...RicWellPathImportCompletionsFileFeature.cpp | 17 +++++++++-------- ...llPathImportPerforationIntervalsFeature.cpp | 11 ++++++----- .../RicAddEclipseInputPropertyFeature.cpp | 10 +++++----- .../RicImportEclipseCaseFeature.cpp | 11 ++++++----- ...cImportEclipseCaseTimeStepFilterFeature.cpp | 10 +++++----- .../ExportCommands/RicExportFaultsFeature.cpp | 5 +++-- .../RicSnapshotViewToFileFeature.cpp | 13 +++++++------ .../RicNewStimPlanFractureTemplateFeature.cpp | 11 ++++++----- .../RicAddScriptPathFeature.cpp | 4 ++-- .../RicSavePlotTemplateFeature.cpp | 13 ++++++++----- .../RicImportElementPropertyFeature.cpp | 6 ++++-- .../RicImportFormationNamesFeature.cpp | 11 ++++++----- .../Commands/RicImportGeneralDataFeature.cpp | 9 ++++++--- .../Commands/RicImportGeoMechCaseFeature.cpp | 6 ++++-- ...cImportGeoMechCaseTimeStepFilterFeature.cpp | 4 ++-- .../Commands/RicImportObservedDataFeature.cpp | 12 +++++++----- .../RicImportObservedFmuDataFeature.cpp | 9 ++++----- .../Commands/RicRecursiveFileSearchDialog.cpp | 5 +++-- .../RicAsciiExportSummaryPlotFeature.cpp | 18 +++++++++--------- .../RicImportSurfacesFeature.cpp | 11 ++++++----- .../RicAsciiExportWellLogPlotFeature.cpp | 11 ++++++----- .../RicWellLogsImportFileFeature.cpp | 11 ++++++----- .../RicImportWellMeasurementsFeature.cpp | 16 +++++++++------- .../WellPathCommands/RicImportWellPaths.cpp | 9 ++++++--- .../RicWellPathFormationsImportFileFeature.cpp | 16 +++++++++------- .../RiuAdvancedSnapshotExportWidget.cpp | 7 ++----- 31 files changed, 176 insertions(+), 144 deletions(-) diff --git a/ApplicationCode/Application/RiaGuiApplication.cpp b/ApplicationCode/Application/RiaGuiApplication.cpp index a6aa365275..a56f0e441a 100644 --- a/ApplicationCode/Application/RiaGuiApplication.cpp +++ b/ApplicationCode/Application/RiaGuiApplication.cpp @@ -93,6 +93,7 @@ #include "Riu3dSelectionManager.h" #include "RiuDockWidgetTools.h" +#include "RiuFileDialogTools.h" #include "RiuMainWindow.h" #include "RiuMainWindowTools.h" #include "RiuMdiMaximizeWindowGuard.h" @@ -120,7 +121,6 @@ #include #include #include -#include #include #include #include @@ -242,8 +242,10 @@ QString RiaGuiApplication::promptForProjectSaveAsFileName() const startPath += "/ResInsightProject.rsp"; } - QString fileName = - QFileDialog::getSaveFileName( nullptr, tr( "Save File" ), startPath, tr( "Project Files (*.rsp);;All files(*.*)" ) ); + QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, + tr( "Save File" ), + startPath, + tr( "Project Files (*.rsp);;All files(*.*)" ) ); return fileName; } diff --git a/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp b/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp index 75640d5b11..d651485bc9 100644 --- a/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp +++ b/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp @@ -27,11 +27,12 @@ #include "RimProject.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include -#include +#include "cafSelectionManagerTools.h" CAF_CMD_SOURCE_INIT( RicImportPolylinesAnnotationFeature, "RicImportPolylinesAnnotationFeature" ); @@ -55,10 +56,11 @@ void RicImportPolylinesAnnotationFeature::onActionTriggered( bool isChecked ) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Poly Lines Annotation", - defaultDir, - "Text Files (*.txt);;Polylines (*.dat);;All Files (*.*)" ); + QStringList fileNames = + RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Poly Lines Annotation", + defaultDir, + "Text Files (*.txt);;Polylines (*.dat);;All Files (*.*)" ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicExportObjectAndFieldKeywordsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicExportObjectAndFieldKeywordsFeature.cpp index 4c2d70a272..beb80a14a8 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicExportObjectAndFieldKeywordsFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicExportObjectAndFieldKeywordsFeature.cpp @@ -20,6 +20,7 @@ #include "RiaVersionInfo.h" +#include "RiuFileDialogTools.h" #include "RiuMainWindow.h" #include "cafClassTypeName.h" @@ -29,7 +30,7 @@ #include #include #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicExportObjectAndFieldKeywordsFeature, "RicExportObjectAndFieldKeywordsFeature" ); @@ -47,10 +48,9 @@ bool RicExportObjectAndFieldKeywordsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicExportObjectAndFieldKeywordsFeature::onActionTriggered( bool isChecked ) { - QString dir = QFileDialog::getExistingDirectory( RiuMainWindow::instance(), - tr( "Select Directory For Export" ), - "c:/temp", - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); + QString dir = RiuFileDialogTools::getExistingDirectory( RiuMainWindow::instance(), + tr( "Select Directory For Export" ), + "c:/temp" ); if ( !dir.isEmpty() ) { diff --git a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp index 069beff491..15183f874e 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp @@ -20,10 +20,11 @@ #include "RiaGuiApplication.h" +#include "RiuFileDialogTools.h" #include "RiuMainWindow.h" #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicOpenProjectFeature, "RicOpenProjectFeature" ); @@ -46,10 +47,10 @@ void RicOpenProjectFeature::onActionTriggered( bool isChecked ) if ( !app->askUserToSaveModifiedProject() ) return; QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QString fileName = QFileDialog::getOpenFileName( nullptr, - "Open ResInsight Project", - defaultDir, - "ResInsight project (*.rsp *.rip);;All files(*.*)" ); + QString fileName = RiuFileDialogTools::getOpenFileName( nullptr, + "Open ResInsight Project", + defaultDir, + "ResInsight project (*.rsp *.rip);;All files(*.*)" ); if ( fileName.isEmpty() ) return; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp index 0f84e5972a..80098c725d 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp @@ -20,10 +20,11 @@ #include "RiaApplication.h" #include "RicfCommandFileExecutor.h" +#include "RiuFileDialogTools.h" #include #include -#include +#include CAF_CMD_SOURCE_INIT( RicRunCommandFileFeature, "RicRunCommandFileFeature" ); @@ -43,10 +44,10 @@ void RicRunCommandFileFeature::onActionTriggered( bool isChecked ) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectoryWithFallbackToProjectFolder( "COMMAND_FILE" ); - QString fileName = QFileDialog::getOpenFileName( nullptr, - "Open ResInsight Command File", - defaultDir, - "ResInsight Command File (*.txt);;All files(*.*)" ); + QString fileName = RiuFileDialogTools::getOpenFileName( nullptr, + "Open ResInsight Command File", + defaultDir, + "ResInsight Command File (*.txt);;All files(*.*)" ); if ( !fileName.isEmpty() ) { diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp index 5f884e3a80..ba8efbce7c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -28,11 +28,12 @@ #include "RimWellPathCompletions.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafSelectionManager.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicWellPathImportCompletionsFileFeature, "RicWellPathImportCompletionsFileFeature" ); @@ -59,13 +60,13 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered( bool isChecked CVF_ASSERT( fishbonesWellPathCollection ); // Open dialog box to select well path files - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" ); - QStringList wellPathFilePaths = - QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Fishbone Laterals", - defaultDir, - "Well Path Laterals (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)" ); + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" ); + QStringList wellPathFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Fishbone Laterals", + defaultDir, + "Well Path Laterals (*.json *.asc *.asci " + "*.ascii *.dev);;All Files (*.*)" ); if ( wellPathFilePaths.size() < 1 ) return; diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp index 4c358548b6..056abfac36 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp @@ -30,11 +30,12 @@ #include "RifPerforationIntervalReader.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafSelectionManager.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicWellPathImportPerforationIntervalsFeature, "RicWellPathImportPerforationIntervalsFeature" ); @@ -63,10 +64,10 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered( bool isChe RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" ); QStringList wellPathFilePaths = - QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Well Path Perforation Intervals", - defaultDir, - "Well Path Perforation Intervals (*.ev);;All Files (*.*)" ); + RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Well Path Perforation Intervals", + defaultDir, + "Well Path Perforation Intervals (*.ev);;All Files (*.*)" ); if ( wellPathFilePaths.size() < 1 ) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp index b73faca782..4e6884ecb5 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp @@ -27,11 +27,11 @@ #include "RiaApplication.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafSelectionManager.h" #include -#include #include #include @@ -67,10 +67,10 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked ) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "INPUT_FILES", casePath ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Select Eclipse Input Property Files", - defaultDir, - "All Files (*.* *)" ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Select Eclipse Input Property Files", + defaultDir, + "All Files (*.* *)" ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index 169ac04be9..9f95b5124c 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -24,11 +24,12 @@ #include "RimEclipseCaseCollection.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafSelectionManager.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportEclipseCaseFeature, "RicImportEclipseCaseFeature" ); @@ -48,10 +49,10 @@ void RicImportEclipseCaseFeature::onActionTriggered( bool isChecked ) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Eclipse File", - defaultDir, - "Eclipse Grid Files (*.GRID *.EGRID)" ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Eclipse File", + defaultDir, + "Eclipse Grid Files (*.GRID *.EGRID)" ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp index 44f979a3cd..d3c4eabebd 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp @@ -22,9 +22,9 @@ #include "RiaImportEclipseCaseTools.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include #include CAF_CMD_SOURCE_INIT( RicImportEclipseCaseTimeStepFilterFeature, "RicImportEclipseCaseTimeStepFilterFeature" ); @@ -37,10 +37,10 @@ void RicImportEclipseCaseTimeStepFilterFeature::onActionTriggered( bool isChecke RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QString fileName = QFileDialog::getOpenFileName( Riu3DMainWindowTools::mainWindowWidget(), - "Import Eclipse File", - defaultDir, - "Eclipse Grid Files (*.GRID *.EGRID)" ); + QString fileName = RiuFileDialogTools::getOpenFileName( Riu3DMainWindowTools::mainWindowWidget(), + "Import Eclipse File", + defaultDir, + "Eclipse Grid Files (*.GRID *.EGRID)" ); if ( !fileName.isEmpty() ) { defaultDir = QFileInfo( fileName ).absolutePath(); diff --git a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp index 460ec534e7..22173839ba 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp @@ -31,11 +31,12 @@ #include "RimEclipseCase.h" #include "RimFaultInView.h" +#include "RiuFileDialogTools.h" + #include "cafSelectionManager.h" #include "cafUtils.h" #include -#include CAF_CMD_SOURCE_INIT( RicExportFaultsFeature, "RicExportFaultsFeature" ); @@ -66,7 +67,7 @@ void RicExportFaultsFeature::onActionTriggered( bool isChecked ) QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "FAULTS" ); - QString selectedDir = QFileDialog::getExistingDirectory( nullptr, tr( "Select Directory" ), defaultDir ); + QString selectedDir = RiuFileDialogTools::getExistingDirectory( nullptr, tr( "Select Directory" ), defaultDir ); if ( selectedDir.isNull() ) { diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index 59bc8be073..992e132698 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -27,6 +27,8 @@ #include "RimPlotWindow.h" #include "RimProject.h" #include "RimViewWindow.h" + +#include "RiuFileDialogTools.h" #include "RiuPlotMainWindow.h" #include "RicSnapshotFilenameGenerator.h" @@ -37,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -210,11 +211,11 @@ QString RicSnapshotViewToFileFeature::generateSaveFileName( const QString& defau { selectedExtension = pdfFilter; } - QString fileName = QFileDialog::getSaveFileName( nullptr, - tr( "Export to File" ), - defaultAbsFileName, - fileExtensionFilter, - &selectedExtension ); + QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, + tr( "Export to File" ), + defaultAbsFileName, + fileExtensionFilter, + &selectedExtension ); if ( !fileName.isEmpty() ) { // Remember the directory to next time diff --git a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index afee1ebc06..af286b98d8 100644 --- a/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -29,13 +29,14 @@ #include "RimWellPathFracture.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafSelectionManager.h" #include "cvfAssert.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFractureTemplateFeature" ); @@ -78,10 +79,10 @@ std::vector RicNewStimPlanFractureTemplateFeature: { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = QFileDialog::getOpenFileNames( nullptr, - "Open StimPlan XML File", - defaultDir, - "StimPlan XML File (*.xml);;All files(*.*)" ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, + "Open StimPlan XML File", + defaultDir, + "StimPlan XML File (*.xml);;All files(*.*)" ); if ( fileNames.isEmpty() ) return std::vector(); diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp index e20562400c..66e72c6322 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp @@ -27,11 +27,11 @@ #include "RimScriptCollection.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cvfAssert.h" #include -#include CAF_CMD_SOURCE_INIT( RicAddScriptPathFeature, "RicAddScriptPathFeature" ); @@ -50,7 +50,7 @@ bool RicAddScriptPathFeature::isCommandEnabled() void RicAddScriptPathFeature::onActionTriggered( bool isChecked ) { QString selectedFolder = - QFileDialog::getExistingDirectory( Riu3DMainWindowTools::mainWindowWidget(), "Select script folder" ); + RiuFileDialogTools::getExistingDirectory( Riu3DMainWindowTools::mainWindowWidget(), "Select script folder" ); if ( !selectedFolder.isEmpty() ) { QString filePathString = RiaApplication::instance()->preferences()->scriptDirectories(); diff --git a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp index 986f93321f..78947f3647 100644 --- a/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp +++ b/ApplicationCode/Commands/PlotTemplateCommands/RicSavePlotTemplateFeature.cpp @@ -32,12 +32,15 @@ #include "RimSummaryCurve.h" #include "RimSummaryPlot.h" +#include "RiuFileDialogTools.h" + #include "cafPdmObject.h" #include "cafSelectionManager.h" #include "cafUtils.h" #include -#include +#include +#include #include CAF_CMD_SOURCE_INIT( RicSavePlotTemplateFeature, "RicSavePlotTemplateFeature" ); @@ -75,10 +78,10 @@ void RicSavePlotTemplateFeature::onActionTriggered( bool isChecked ) startPath = startPath + "/" + templateCandidateName + ".rpt"; - QString fileName = QFileDialog::getSaveFileName( nullptr, - tr( "Save Plot Template To File" ), - startPath, - tr( "Plot Template Files (*.rpt);;All files(*.*)" ) ); + QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, + tr( "Save Plot Template To File" ), + startPath, + tr( "Plot Template Files (*.rpt);;All files(*.*)" ) ); if ( !fileName.isEmpty() ) { QFile exportFile( fileName ); diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp index 4acae520f9..f154d727a7 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -26,8 +26,10 @@ #include "RimGeoMechCase.h" #include "RimGeoMechView.h" +#include "RiuFileDialogTools.h" + #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportElementPropertyFeature, "RicImportElementPropertyFeature" ); @@ -48,7 +50,7 @@ void RicImportElementPropertyFeature::onActionTriggered( bool isChecked ) QString defaultDir = app->lastUsedDialogDirectory( "ELM_PROPS" ); QStringList fileNames = - QFileDialog::getOpenFileNames( nullptr, "Import Element Property Table", defaultDir, "Property Table (*.inp)" ); + RiuFileDialogTools::getOpenFileNames( nullptr, "Import Element Property Table", defaultDir, "Property Table (*.inp)" ); if ( !fileNames.empty() ) { diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 0ee7df9ef3..a48fe6dfee 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -34,9 +34,10 @@ #include "RigGeoMechCaseData.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportFormationNamesFeature, "RicImportFormationNamesFeature" ); @@ -80,10 +81,10 @@ void RicImportFormationNamesFeature::onActionTriggered( bool isChecked ) QString( "Formation Names description File (*.lyr);;FMU Layer Zone Table(%1);;All Files (*.*)" ) .arg( RimFormationNames::layerZoneTableFileName() ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Formation Names", - defaultDir, - filterText ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Formation Names", + defaultDir, + filterText ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/RicImportGeneralDataFeature.cpp b/ApplicationCode/Commands/RicImportGeneralDataFeature.cpp index 5c98e0ba26..3d2d9c94fc 100644 --- a/ApplicationCode/Commands/RicImportGeneralDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportGeneralDataFeature.cpp @@ -28,9 +28,10 @@ #include "RimSummaryCase.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include #include #include @@ -190,8 +191,10 @@ QStringList RicImportGeneralDataFeature::getEclipseFileNamesWithDialog( RiaDefin QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectory( defaultDirectoryLabel( fileTypes ) ); - QStringList fileNames = - QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), "Import Data File", defaultDir, fullPattern ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Data File", + defaultDir, + fullPattern ); return fileNames; } diff --git a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp index c7c4281195..bbb538bdc6 100644 --- a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp @@ -20,8 +20,10 @@ #include "RiaApplication.h" +#include "RiuFileDialogTools.h" + #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportGeoMechCaseFeature, "RicImportGeoMechCaseFeature" ); @@ -42,7 +44,7 @@ void RicImportGeoMechCaseFeature::onActionTriggered( bool isChecked ) QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" ); QStringList fileNames = - QFileDialog::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" ); + RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" ); if ( fileNames.size() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath(); app->setLastUsedDialogDirectory( "GEOMECH_MODEL", defaultDir ); diff --git a/ApplicationCode/Commands/RicImportGeoMechCaseTimeStepFilterFeature.cpp b/ApplicationCode/Commands/RicImportGeoMechCaseTimeStepFilterFeature.cpp index b60f5aeba6..7790f17924 100644 --- a/ApplicationCode/Commands/RicImportGeoMechCaseTimeStepFilterFeature.cpp +++ b/ApplicationCode/Commands/RicImportGeoMechCaseTimeStepFilterFeature.cpp @@ -22,9 +22,9 @@ #include "RiaImportEclipseCaseTools.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include #include CAF_CMD_SOURCE_INIT( RicImportGeoMechCaseTimeStepFilterFeature, "RicImportGeoMechCaseTimeStepFilterFeature" ); @@ -38,7 +38,7 @@ void RicImportGeoMechCaseTimeStepFilterFeature::onActionTriggered( bool isChecke QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" ); QStringList fileNames = - QFileDialog::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" ); + RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" ); if ( fileNames.size() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath(); for ( QString fileName : fileNames ) { diff --git a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp index f1d859f4fe..f83b001007 100644 --- a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp @@ -26,12 +26,13 @@ #include "RimProject.h" #include "RimSummaryObservedDataFile.h" +#include "RiuFileDialogTools.h" #include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicImportObservedDataFeature, "RicImportObservedDataFeature" ); @@ -43,10 +44,11 @@ void RicImportObservedDataFeature::selectObservedDataFileInDialog() { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "INPUT_FILES" ); - QStringList fileNames = QFileDialog::getOpenFileNames( nullptr, - "Import Observed Data", - defaultDir, - "Observed Data (*.RSM *.txt *.csv);;All Files (*.*)" ); + QStringList fileNames = + RiuFileDialogTools::getOpenFileNames( nullptr, + "Import Observed Data", + defaultDir, + "Observed Data (*.RSM *.txt *.csv);;All Files (*.*)" ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp index 877d4fc862..9556ea5d2f 100644 --- a/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedFmuDataFeature.cpp @@ -33,6 +33,7 @@ #include "RimOilField.h" #include "RimProject.h" +#include "RiuFileDialogTools.h" #include "RiuPlotMainWindowTools.h" #include "cafPdmObject.h" @@ -40,7 +41,6 @@ #include #include -#include #include #include @@ -53,10 +53,9 @@ void RicImportObservedFmuDataFeature::selectObservedDataPathInDialog() { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "SUMMARY_CASE_DIR" ); - QString directory = QFileDialog::getExistingDirectory( nullptr, - "Import Observed FMU Data Recursively from Directory", - defaultDir, - QFileDialog::ShowDirsOnly ); + QString directory = RiuFileDialogTools::getExistingDirectory( nullptr, + "Import Observed FMU Data Recursively from Directory", + defaultDir ); QStringList subDirsWithFmuData = RifReaderFmuRft::findSubDirectoriesWithFmuRftData( directory ); if ( subDirsWithFmuData.empty() ) diff --git a/ApplicationCode/Commands/RicRecursiveFileSearchDialog.cpp b/ApplicationCode/Commands/RicRecursiveFileSearchDialog.cpp index 61d8ac41a6..757675cd6c 100644 --- a/ApplicationCode/Commands/RicRecursiveFileSearchDialog.cpp +++ b/ApplicationCode/Commands/RicRecursiveFileSearchDialog.cpp @@ -21,13 +21,14 @@ #include "RiaFilePathTools.h" #include "RiaGuiApplication.h" +#include "RiuFileDialogTools.h" #include "RiuTools.h" #include #include #include #include -#include +#include #include #include #include @@ -711,7 +712,7 @@ void RicRecursiveFileSearchDialog::slotDialogCancelClicked() //-------------------------------------------------------------------------------------------------- void RicRecursiveFileSearchDialog::slotBrowseButtonClicked() { - QString folder = QFileDialog::getExistingDirectory( this, "Select folder", rootDirWithEndSeparator() ); + QString folder = RiuFileDialogTools::getExistingDirectory( this, "Select folder", rootDirWithEndSeparator() ); RiaFilePathTools::appendSeparatorIfNo( folder ); folder += "*"; if ( !folder.isEmpty() ) m_pathFilterField->setText( QDir::toNativeSeparators( folder ) ); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp index 403acaf41f..0c0d4c021f 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.cpp @@ -26,6 +26,7 @@ #include "RimSummaryPlot.h" +#include "RiuFileDialogTools.h" #include "RiuMainWindow.h" #include "cafPdmUiPropertyViewDialog.h" @@ -37,7 +38,6 @@ #include #include -#include #include CAF_CMD_SOURCE_INIT( RicAsciiExportSummaryPlotFeature, "RicAsciiExportSummaryPlotFeature" ); @@ -138,10 +138,10 @@ QString RicAsciiExportSummaryPlotFeature::getFileNameFromUserDialog( const QStri const QString& defaultDir ) { QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename( fileNameCandidate ) + ".ascii"; - QString fileName = QFileDialog::getSaveFileName( nullptr, - "Select File for Summary Plot Export", - defaultFileName, - "Text File(*.ascii);;All files(*.*)" ); + QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, + "Select File for Summary Plot Export", + defaultFileName, + "Text File(*.ascii);;All files(*.*)" ); return fileName; } @@ -170,10 +170,10 @@ bool RicAsciiExportSummaryPlotFeature::exportTextToFile( const QString& fileName //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName, - const RimSummaryPlot* summaryPlot, - RiaQDateTimeTools::DateTimePeriod resamplingPeriod, - bool showTimeAsLongString ) +bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName, + const RimSummaryPlot* summaryPlot, + RiaQDateTimeTools::DateTimePeriod resamplingPeriod, + bool showTimeAsLongString ) { QString text = summaryPlot->description(); text.append( summaryPlot->asciiDataForSummaryPlotExport( resamplingPeriod, showTimeAsLongString ) ); diff --git a/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp b/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp index 29cc55ed58..bbe5a439c7 100644 --- a/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp +++ b/ApplicationCode/Commands/SurfaceCommands/RicImportSurfacesFeature.cpp @@ -26,9 +26,10 @@ #include "RimSurfaceCollection.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportSurfacesFeature, "RicImportSurfacesFeature" ); @@ -47,10 +48,10 @@ void RicImportSurfacesFeature::onActionTriggered( bool isChecked ) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); - QStringList fileNames = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Surfaces", - defaultDir, - "Surface files (*.ptl *.ts);;All Files (*.*)" ); + QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Surfaces", + defaultDir, + "Surface files (*.ptl *.ts);;All Files (*.*)" ); if ( fileNames.isEmpty() ) return; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp index 6591d1f00b..d89a9839f9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAsciiExportWellLogPlotFeature.cpp @@ -23,6 +23,7 @@ #include "RimWellLogPlot.h" +#include "RiuFileDialogTools.h" #include "RiuMainWindow.h" #include "cafPdmUiPropertyViewDialog.h" @@ -33,7 +34,7 @@ #include #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicAsciiExportWellLogPlotFeature, "RicAsciiExportWellLogPlotFeature" ); @@ -66,10 +67,10 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered( bool isChecked ) RimWellLogPlot* wellLogPlot = selectedWellLogPlots.at( 0 ); QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename( ( wellLogPlot->description() ) ) + ".ascii"; - QString fileName = QFileDialog::getSaveFileName( nullptr, - "Select File for Plot Data Export", - defaultFileName, - "Text File(*.ascii);;All files(*.*)" ); + QString fileName = RiuFileDialogTools::getSaveFileName( nullptr, + "Select File for Plot Data Export", + defaultFileName, + "Text File(*.ascii);;All files(*.*)" ); if ( fileName.isEmpty() ) return; RicAsciiExportWellLogPlotFeature::exportAsciiForWellLogPlot( fileName, wellLogPlot ); diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp index b3a28f8755..be0fd556e4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp @@ -25,11 +25,12 @@ #include "RimProject.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafPdmUiObjectEditorHandle.h" #include -#include +#include #include CAF_CMD_SOURCE_INIT( RicWellLogsImportFileFeature, "RicWellLogsImportFileFeature" ); @@ -80,10 +81,10 @@ void RicWellLogsImportFileFeature::onActionTriggered( bool isChecked ) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "WELL_LOGS_DIR" ); QString nameFilterString = QString( "Well Logs (%1);;All Files (*.*)" ).arg( wellLogFileNameFilters().join( " " ) ); - QStringList wellLogFilePaths = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Well Logs", - defaultDir, - nameFilterString ); + QStringList wellLogFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Well Logs", + defaultDir, + nameFilterString ); if ( wellLogFilePaths.size() >= 1 ) { diff --git a/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp index 98c4b4083b..9fa870edf9 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicImportWellMeasurementsFeature.cpp @@ -25,9 +25,10 @@ #include "RicWellMeasurementImportTools.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicImportWellMeasurementsFeature, "RicImportWellMeasurementsFeature" ); @@ -48,12 +49,13 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked ) CVF_ASSERT( wellPathCollection ); // Open dialog box to select well path files - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" ); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Well Measurements", - defaultDir, - "Well Measurements (*.csv);;All Files (*.*)" ); + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory( "WELLPATH_DIR" ); + QStringList wellPathFilePaths = + RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Well Measurements", + defaultDir, + "Well Measurements (*.csv);;All Files (*.*)" ); if ( wellPathFilePaths.size() < 1 ) return; diff --git a/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp b/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp index 2f18f98d5a..2fb92bae54 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicImportWellPaths.cpp @@ -30,11 +30,12 @@ #include "RimWellPathCollection.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include "cafPdmFieldIOScriptability.h" #include -#include +#include #include //================================================================================================== @@ -216,8 +217,10 @@ void RicImportWellPaths::onActionTriggered( bool isChecked ) QString nameList = QString( "Well Paths (%1);;All Files (*.*)" ).arg( wellPathNameFilters().join( " " ) ); - QStringList wellPathFilePaths = - QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), "Import Well Paths", defaultDir, nameList ); + QStringList wellPathFilePaths = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Well Paths", + defaultDir, + nameList ); if ( wellPathFilePaths.size() >= 1 ) { diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp index b22692160e..d29dad3d70 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp @@ -27,9 +27,10 @@ #include "RimWellPathCollection.h" #include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" #include -#include +#include CAF_CMD_SOURCE_INIT( RicWellPathFormationsImportFileFeature, "RicWellPathFormationsImportFileFeature" ); @@ -47,12 +48,13 @@ bool RicWellPathFormationsImportFileFeature::isCommandEnabled() void RicWellPathFormationsImportFileFeature::onActionTriggered( bool isChecked ) { // Open dialog box to select well path formations files - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->lastUsedDialogDirectory( "WELLPATHFORMATIONS_DIR" ); - QStringList wellPathFormationsFilePaths = QFileDialog::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), - "Import Well Picks", - defaultDir, - "Well Picks (*.csv);;All Files (*.*)" ); + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory( "WELLPATHFORMATIONS_DIR" ); + QStringList wellPathFormationsFilePaths = + RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), + "Import Well Picks", + defaultDir, + "Well Picks (*.csv);;All Files (*.*)" ); if ( wellPathFormationsFilePaths.size() < 1 ) return; diff --git a/ApplicationCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp b/ApplicationCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp index fe938ada81..db91132a28 100644 --- a/ApplicationCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp +++ b/ApplicationCode/UserInterface/RiuAdvancedSnapshotExportWidget.cpp @@ -29,6 +29,7 @@ #include "RimEclipseView.h" #include "RimProject.h" +#include "RiuFileDialogTools.h" #include "RiuTools.h" #include "cafCmdFeatureManager.h" @@ -38,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -251,10 +251,7 @@ void RiuAdvancedSnapshotExportWidget::folderSelectionClicked() QString defaultPath = m_exportFolderLineEdit->text(); QString directoryPath = - QFileDialog::getExistingDirectory( m_exportFolderLineEdit, - tr( "Get existing directory" ), - defaultPath, - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); + RiuFileDialogTools::getExistingDirectory( m_exportFolderLineEdit, tr( "Get existing directory" ), defaultPath ); if ( !directoryPath.isEmpty() ) { From ff202014d75a7add3de70a51d403ee5c847ca24b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Aug 2020 19:12:46 +0200 Subject: [PATCH 24/24] #6345 Fix missing QFileDialog prefix --- ApplicationCode/UserInterface/RiuFileDialogTools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuFileDialogTools.cpp b/ApplicationCode/UserInterface/RiuFileDialogTools.cpp index d20692bc78..599f5d2582 100644 --- a/ApplicationCode/UserInterface/RiuFileDialogTools.cpp +++ b/ApplicationCode/UserInterface/RiuFileDialogTools.cpp @@ -79,9 +79,9 @@ QString RiuFileDialogTools::getOpenFileName( QWidget* parent /*= nullptr*/ QString* selectedFilter /*= nullptr */ ) { #ifdef WIN32 - return getOpenFileName( parent, caption, dir, filter, selectedFilter ); + return QFileDialog::getOpenFileName( parent, caption, dir, filter, selectedFilter ); #else auto options = QFileDialog::DontUseNativeDialog; - return getOpenFileName( parent, caption, dir, filter, selectedFilter, options ); + return QFileDialog::getOpenFileName( parent, caption, dir, filter, selectedFilter, options ); #endif }