From dcc88a4703f8a7a13cd701b1715de1cfac167844 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 12 Oct 2020 13:38:45 +0200 Subject: [PATCH] #6735 Fix compsegs end length and make valve branch segments use mid points --- .../RicMswSegment.cpp | 34 +++++ .../CompletionExportCommands/RicMswSegment.h | 6 + .../RicWellPathExportMswCompletionsImpl.cpp | 136 ++++++++---------- .../RicWellPathExportMswCompletionsImpl.h | 18 ++- 4 files changed, 110 insertions(+), 84 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp index fb2bfb9bee..47ba450da5 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.cpp @@ -38,6 +38,8 @@ RicMswSegment::RicMswSegment( const QString& label, , m_endMD( endMD ) , m_startTVD( startTVD ) , m_endTVD( endTVD ) + , m_outputMD( 0.0 ) + , m_outputTVD( 0.0 ) , m_effectiveDiameter( 0.15 ) , m_holeDiameter( RicMswExportInfo::defaultDoubleValue() ) , m_openHoleRoughnessFactor( 5.0e-5 ) @@ -71,6 +73,22 @@ double RicMswSegment::endMD() const return m_endMD; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicMswSegment::setOutputMD( double outputMD ) +{ + m_outputMD = outputMD; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicMswSegment::outputMD() const +{ + return m_outputMD; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -103,6 +121,22 @@ double RicMswSegment::endTVD() const return m_endTVD; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicMswSegment::setOutputTVD( double outputTVD ) +{ + m_outputTVD = outputTVD; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicMswSegment::outputTVD() const +{ + return m_outputTVD; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h index 3918f32f61..7c0eb1cd3e 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswSegment.h @@ -41,11 +41,15 @@ public: double startMD() const; double endMD() const; + void setOutputMD( double outputMD ); + double outputMD() const; double length() const; double deltaMD() const; double startTVD() const; double endTVD() const; + void setOutputTVD( double outputTVD ); + double outputTVD() const; double deltaTVD() const; double effectiveDiameter() const; @@ -79,6 +83,8 @@ private: double m_endMD; double m_startTVD; double m_endTVD; + double m_outputMD; + double m_outputTVD; double m_effectiveDiameter; double m_holeDiameter; double m_openHoleRoughnessFactor; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 85980d993b..f4b62491d3 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -308,9 +308,8 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable int segmentNumber = 2; // There's an implicit segment number 1. { - double prevMD = exportInfo.initialMD(); - double prevTVD = exportInfo.initialTVD(); formatter.comment( "Main Stem Segments" ); + std::shared_ptr previousSegment; for ( std::shared_ptr segment : exportInfo.segments() ) { segment->setSegmentNumber( segmentNumber ); @@ -321,7 +320,8 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable formatter.comment( comment ); } - writeMainBoreWelsegsSegment( segment, formatter, exportInfo, maxSegmentLength, &segmentNumber, &prevMD, &prevTVD ); + writeMainBoreWelsegsSegment( segment, previousSegment, formatter, exportInfo, maxSegmentLength, &segmentNumber ); + previousSegment = segment; } } @@ -371,22 +371,16 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsSegments( if ( RigCompletionData::isValve( completion->completionType() ) ) { - writeValveWelsegsSegment( std::dynamic_pointer_cast( completion ), + writeValveWelsegsSegment( segment, + std::dynamic_pointer_cast( completion ), formatter, exportInfo, maxSegmentLength, - mainSegmentNumber, segmentNumber ); } else { - writeCompletionWelsegsSegment( segment, - completion, - formatter, - exportInfo, - maxSegmentLength, - mainSegmentNumber, - segmentNumber ); + writeCompletionWelsegsSegment( segment, completion, formatter, exportInfo, maxSegmentLength, segmentNumber ); } } } @@ -479,7 +473,8 @@ void RicWellPathExportMswCompletionsImpl::generateCompsegTable( for ( std::shared_ptr segment : exportInfo.segments() ) { - double startMD = segment->startMD(); + double segmentStartMD = segment->startMD(); + double segmentEndMD = segment->endMD(); for ( std::shared_ptr completion : segment->completions() ) { @@ -493,9 +488,17 @@ void RicWellPathExportMswCompletionsImpl::generateCompsegTable( for ( const std::shared_ptr& subSegment : completion->subSegments() ) { + double subSegmentStartMD = segmentStartMD; + double subSegmentEndMD = segmentEndMD; if ( completion->completionType() == RigCompletionData::FISHBONES_ICD ) { - startMD = subSegment->startMD(); + subSegmentStartMD = subSegment->startMD(); + subSegmentEndMD = subSegment->endMD(); + } + + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) && completion->branchNumber() != 1 ) + { + subSegmentStartMD -= segmentStartMD; } for ( const std::shared_ptr& intersection : @@ -513,13 +516,8 @@ void RicWellPathExportMswCompletionsImpl::generateCompsegTable( ijk.z() ); formatter.add( completion->branchNumber() ); - double startLength = subSegment->startMD(); - if ( exportInfo.lengthAndDepthText() == QString( "INC" ) && completion->branchNumber() != 1 ) - { - startLength -= startMD; - } - formatter.add( startLength ); - formatter.add( startLength + subSegment->deltaMD() ); + formatter.add( subSegmentStartMD ); + formatter.add( subSegmentEndMD ); formatter.rowCompleted(); } @@ -1347,26 +1345,30 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( for ( size_t nSubValve = 0u; nSubValve < valve->valveLocations().size(); ++nSubValve ) { - double valveMD = valve->valveLocations()[nSubValve]; - double valveStartTVD = RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, valveMD ); - - double valveLengthMD = 0.1; - double valveEndTVD = - RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, valveMD + valveLengthMD ); + double valveMD = valve->valveLocations()[nSubValve]; std::pair valveSegment = valve->valveSegments()[nSubValve]; double overlapStart = std::max( valveSegment.first, segment->startMD() ); double overlapEnd = std::min( valveSegment.second, segment->endMD() ); double overlap = std::max( 0.0, overlapEnd - overlapStart ); + // "Dummy" values for the new branch created for the valve. + // Will be added to the main segments start MD, + double exportStartMD = 0.0; + double exportEndMD = 0.1; + + double overlapStartTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, overlapStart ); + double overlapEndTVD = + RicWellPathExportMswCompletionsImpl::tvdFromMeasuredDepth( wellPath, overlapEnd ); + if ( segment->startMD() <= valveMD && valveMD < segment->endMD() ) { if ( valve->componentType() == RiaDefines::WellPathComponentType::AICD ) { QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); - std::shared_ptr subSegment( - new RicMswSubSegment( valveMD, valveMD + valveLengthMD, valveStartTVD, valveEndTVD ) ); + auto subSegment = std::make_shared( exportStartMD, exportEndMD, 0.0, 0.0 ); superAICD = std::make_shared( valveLabel, valve ); superAICD->addSubSegment( subSegment ); @@ -1375,8 +1377,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 + valveLengthMD, valveStartTVD, valveEndTVD ) ); + auto subSegment = std::make_shared( exportStartMD, exportEndMD, 0.0, 0.0 ); superICD = std::make_shared( valveLabel, valve ); superICD->addSubSegment( subSegment ); @@ -1385,8 +1386,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 + valveLengthMD, valveStartTVD, valveEndTVD ) ); + auto subSegment = std::make_shared( exportStartMD, exportEndMD, 0.0, 0.0 ); ICV = std::make_shared( valveLabel, valve ); ICV->addSubSegment( subSegment ); @@ -1401,17 +1401,8 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); - 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 ); + auto subSegment = std::make_shared( exportStartMD, exportEndMD, 0.0, 0.0 ); + superICD = std::make_shared( valveLabel, valve ); superICD->addSubSegment( subSegment ); } else if ( overlap > 0.0 && @@ -1420,17 +1411,8 @@ void RicWellPathExportMswCompletionsImpl::createValveCompletions( QString valveLabel = QString( "%1 #%2" ).arg( "Combined Valve for segment" ).arg( nMainSegment + 2 ); - 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 ); + auto subSegment = std::make_shared( exportStartMD, exportEndMD, 0.0, 0.0 ); + superAICD = std::make_shared( valveLabel, valve ); superAICD->addSubSegment( subSegment ); } @@ -1648,20 +1630,27 @@ void RicWellPathExportMswCompletionsImpl::moveIntersectionsToICVs( /// //-------------------------------------------------------------------------------------------------- void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shared_ptr segment, + std::shared_ptr previousSegment, RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo, double maxSegmentLength, - int* segmentNumber, - double* prevMD, - double* prevTVD ) + int* segmentNumber ) { - CVF_ASSERT( segment && segmentNumber && prevMD && prevTVD ); + CVF_ASSERT( segment && segmentNumber ); double startMD = segment->startMD(); double endMD = segment->endMD(); std::vector> subSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); + double prevOutMD = exportInfo.initialMD(); + double prevOutTVD = exportInfo.initialTVD(); + if ( previousSegment ) + { + prevOutMD = previousSegment->outputMD(); + prevOutTVD = previousSegment->outputTVD(); + } + for ( auto mdPair : subSegments ) { double subStartMD = mdPair.first; @@ -1681,14 +1670,16 @@ void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shar if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) { - depth = midPointTVD - *prevTVD; - length = midPointMD - *prevMD; + depth = midPointTVD - prevOutTVD; + length = midPointMD - prevOutMD; } else { depth = midPointTVD; length = midPointMD; } + segment->setOutputMD( length ); + segment->setOutputTVD( depth ); formatter.add( *segmentNumber ).add( *segmentNumber ); formatter.add( 1 ); // All segments on main stem are branch 1 @@ -1699,8 +1690,6 @@ void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shar formatter.add( exportInfo.linerDiameter() ); formatter.add( exportInfo.roughnessFactor() ); formatter.rowCompleted(); - *prevMD = midPointMD; - *prevTVD = midPointTVD; ( *segmentNumber )++; } } @@ -1708,12 +1697,12 @@ void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shar //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ptr valve, - RifTextDataTableFormatter& formatter, - const RicMswExportInfo& exportInfo, - double maxSegmentLength, - int mainSegmentNumber, - int* segmentNumber ) +void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ptr segment, + std::shared_ptr valve, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + int* segmentNumber ) { CVF_ASSERT( valve ); @@ -1722,8 +1711,8 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ auto subSegment = valve->subSegments().front(); subSegment->setSegmentNumber( *segmentNumber ); - double startMD = subSegment->startMD(); - double endMD = subSegment->endMD(); + double startMD = segment->outputMD() + subSegment->startMD(); + double endMD = segment->outputMD() + subSegment->endMD(); std::vector> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength ); @@ -1756,7 +1745,7 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ formatter.add( subSegmentNumber ); formatter.add( subSegmentNumber ); formatter.add( valve->branchNumber() ); - formatter.add( mainSegmentNumber ); + formatter.add( segment->segmentNumber() ); formatter.add( length ); formatter.add( depth ); @@ -1774,7 +1763,6 @@ void RicWellPathExportMswCompletionsImpl::writeCompletionWelsegsSegment( std::sh RifTextDataTableFormatter& formatter, const RicMswExportInfo& exportInfo, double maxSegmentLength, - int mainSegmentNumber, int* segmentNumber ) { if ( completion->completionType() == RigCompletionData::FISHBONES ) @@ -1824,7 +1812,7 @@ void RicWellPathExportMswCompletionsImpl::writeCompletionWelsegsSegment( std::sh formatter.add( subSegmentNumber ); formatter.add( subSegmentNumber ); formatter.add( completion->branchNumber() ); - formatter.add( mainSegmentNumber ); + formatter.add( segment->segmentNumber() ); formatter.add( length ); formatter.add( depth ); formatter.add( diameter ); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h index 61694c1247..60a7d16902 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h @@ -91,24 +91,22 @@ private: double maxSegmentLength ); static void writeMainBoreWelsegsSegment( std::shared_ptr segment, + std::shared_ptr previousSegment, 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 ); + int* segmentNumber ); + static void writeValveWelsegsSegment( std::shared_ptr segment, + std::shared_ptr valve, + RifTextDataTableFormatter& formatter, + const RicMswExportInfo& exportInfo, + double maxSegmentLength, + 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,