From 4d38c2ea391ae30e592de997e18b648711473e98 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 19 Nov 2019 11:09:22 +0100 Subject: [PATCH 1/2] #5061 WAP: Trigger reload of Well Allocation Data when updating depth type --- .../ProjectDataModel/RimWellLogPlot.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 267217619b..7a7f675149 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -26,6 +26,7 @@ #include "RimEclipseCase.h" #include "RimGeoMechCase.h" +#include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" #include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogTrack.h" @@ -576,8 +577,17 @@ void RimWellLogPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, } else if ( changedField == &m_depthType ) { - m_isAutoScaleDepthEnabled = true; - loadDataAndUpdate(); + m_isAutoScaleDepthEnabled = true; + RimWellAllocationPlot* parentWellAllocation = nullptr; + this->firstAncestorOrThisOfType( parentWellAllocation ); + if ( parentWellAllocation ) + { + parentWellAllocation->loadDataAndUpdate(); + } + else + { + loadDataAndUpdate(); + } } else if ( changedField == &m_depthUnit ) { From 60b09d7bfd6e1c981991070ea2ab4e3bc47eba26 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 19 Nov 2019 13:19:56 +0100 Subject: [PATCH 2/2] #5061 WAP: fix update of well allocation data when changing depth type --- ApplicationCode/Application/RiaDefines.cpp | 10 ++ ApplicationCode/Application/RiaDefines.h | 9 + .../RicNewWellBoreStabilityPlotFeature.cpp | 2 +- .../Flow/RimWellAllocationPlot.cpp | 21 +-- .../Flow/RimWellAllocationPlot.h | 1 + .../Flow/RimWellFlowRateCurve.cpp | 14 +- .../Flow/RimWellFlowRateCurve.h | 1 + .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 4 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 6 +- .../ProjectDataModel/Rim3dWellLogRftCurve.cpp | 2 +- .../ProjectDataModel/RimWellLogCurve.cpp | 78 +++++---- .../ProjectDataModel/RimWellLogCurve.h | 21 ++- .../RimWellLogExtractionCurve.cpp | 27 ++- .../ProjectDataModel/RimWellLogFileCurve.cpp | 36 ++-- .../ProjectDataModel/RimWellLogPlot.cpp | 24 +-- .../ProjectDataModel/RimWellLogPlot.h | 15 +- .../ProjectDataModel/RimWellLogRftCurve.cpp | 8 +- .../ProjectDataModel/RimWellLogTrack.cpp | 24 +-- .../ReservoirDataModel/RigLasFileExporter.cpp | 20 ++- .../RigWellLogCurveData.cpp | 162 +++++++----------- .../ReservoirDataModel/RigWellLogCurveData.h | 44 ++--- .../RigWellPathFormations.cpp | 24 +-- .../RiuWellPathComponentPlotItem.cpp | 6 +- 23 files changed, 271 insertions(+), 288 deletions(-) diff --git a/ApplicationCode/Application/RiaDefines.cpp b/ApplicationCode/Application/RiaDefines.cpp index 47c3d44339..246f69ab56 100644 --- a/ApplicationCode/Application/RiaDefines.cpp +++ b/ApplicationCode/Application/RiaDefines.cpp @@ -48,6 +48,16 @@ void caf::AppEnum::setUp() setDefault( RiaDefines::UNIT_METER ); } +template <> +void caf::AppEnum::setUp() +{ + addItem( RiaDefines::MEASURED_DEPTH, "MEASURED_DEPTH", "Measured Depth" ); + addItem( RiaDefines::TRUE_VERTICAL_DEPTH, "TRUE_VERTICAL_DEPTH", "True Vertical Depth (MSL)" ); + addItem( RiaDefines::PSEUDO_LENGTH, "PSEUDO_LENGTH", "Pseudo Length" ); + addItem( RiaDefines::CONNECTION_NUMBER, "CONNECTION_NUMBER", "Connection Number" ); + setDefault( RiaDefines::MEASURED_DEPTH ); +} + template <> void caf::AppEnum::setUp() { diff --git a/ApplicationCode/Application/RiaDefines.h b/ApplicationCode/Application/RiaDefines.h index dc808d9d25..ffdc22f8f0 100644 --- a/ApplicationCode/Application/RiaDefines.h +++ b/ApplicationCode/Application/RiaDefines.h @@ -137,6 +137,15 @@ enum DepthUnitType UNIT_NONE }; +// Depth types used for well log plots +enum DepthTypeEnum +{ + MEASURED_DEPTH, + TRUE_VERTICAL_DEPTH, + PSEUDO_LENGTH, + CONNECTION_NUMBER +}; + // Defines relate to plotting enum PlotAxis { diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 7b53c3ce89..1e9b3fad9a 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -101,7 +101,7 @@ RimWellBoreStabilityPlot* plot->setPlotTitleVisible( true ); plot->setLegendsVisible( true ); plot->setLegendsHorizontal( true ); - plot->setDepthType( RimWellLogPlot::TRUE_VERTICAL_DEPTH ); + plot->setDepthType( RiaDefines::TRUE_VERTICAL_DEPTH ); plot->setAutoScaleYEnabled( true ); RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot ); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 3b4b882b07..69bab4bf77 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -99,7 +99,7 @@ RimWellAllocationPlot::RimWellAllocationPlot() m_accumulatedWellFlowPlot.uiCapability()->setUiHidden( true ); m_accumulatedWellFlowPlot = new RimWellLogPlot; m_accumulatedWellFlowPlot->setDepthUnit( RiaDefines::UNIT_NONE ); - m_accumulatedWellFlowPlot->setDepthType( RimWellLogPlot::CONNECTION_NUMBER ); + m_accumulatedWellFlowPlot->setDepthType( RiaDefines::CONNECTION_NUMBER ); m_accumulatedWellFlowPlot->setLegendsVisible( false ); m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" ); @@ -124,7 +124,7 @@ RimWellAllocationPlot::RimWellAllocationPlot() m_accumulatedWellFlowPlot->setAvailableDepthUnits( {} ); m_accumulatedWellFlowPlot->setAvailableDepthTypes( - {RimWellLogPlot::CONNECTION_NUMBER, RimWellLogPlot::TRUE_VERTICAL_DEPTH, RimWellLogPlot::PSEUDO_LENGTH} ); + {RiaDefines::CONNECTION_NUMBER, RiaDefines::TRUE_VERTICAL_DEPTH, RiaDefines::PSEUDO_LENGTH} ); m_accumulatedWellFlowPlot->setCommonDataSourceEnabled( false ); @@ -264,7 +264,7 @@ void RimWellAllocationPlot::updateFromWell() auto depthType = accumulatedWellFlowPlot()->depthType(); - if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) return; + if ( depthType == RiaDefines::MEASURED_DEPTH ) return; // Create tracks and curves from the calculated data @@ -282,11 +282,11 @@ void RimWellAllocationPlot::updateFromWell() accumulatedWellFlowPlot()->addPlot( plotTrack ); - const std::vector& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER + const std::vector& depthValues = depthType == RiaDefines::CONNECTION_NUMBER ? wfCalculator->connectionNumbersFromTop( brIdx ) - : depthType == RimWellLogPlot::PSEUDO_LENGTH + : depthType == RiaDefines::PSEUDO_LENGTH ? wfCalculator->pseudoLengthFromTop( brIdx ) - : depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH + : depthType == RiaDefines::TRUE_VERTICAL_DEPTH ? wfCalculator->trueVerticalDepth( brIdx ) : std::vector(); @@ -295,13 +295,13 @@ void RimWellAllocationPlot::updateFromWell() for ( const QString& tracerName : tracerNames ) { const std::vector* accFlow = nullptr; - if ( depthType == RimWellLogPlot::CONNECTION_NUMBER ) + if ( depthType == RiaDefines::CONNECTION_NUMBER ) { accFlow = &( m_flowType == ACCUMULATED ? wfCalculator->accumulatedTracerFlowPrConnection( tracerName, brIdx ) : wfCalculator->tracerFlowPrConnection( tracerName, brIdx ) ); } - else if ( depthType == RimWellLogPlot::PSEUDO_LENGTH || depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + else if ( depthType == RiaDefines::PSEUDO_LENGTH || depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { accFlow = &( m_flowType == ACCUMULATED ? wfCalculator->accumulatedTracerFlowPrPseudoLength( tracerName, brIdx ) @@ -310,7 +310,7 @@ void RimWellAllocationPlot::updateFromWell() if ( accFlow ) { - addStackedCurve( tracerName, depthValues, *accFlow, plotTrack ); + addStackedCurve( tracerName, depthType, depthValues, *accFlow, plotTrack ); // TODO: THIs is the data to be plotted... } } @@ -463,12 +463,13 @@ void RimWellAllocationPlot::updateWellFlowPlotXAxisTitle( RimWellLogTrack* plotT /// //-------------------------------------------------------------------------------------------------- void RimWellAllocationPlot::addStackedCurve( const QString& tracerName, + RiaDefines::DepthTypeEnum depthType, const std::vector& depthValues, const std::vector& accFlow, RimWellLogTrack* plotTrack ) { RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; - curve->setFlowValuesPrDepthValue( tracerName, depthValues, accFlow ); + curve->setFlowValuesPrDepthValue( tracerName, depthType, depthValues, accFlow ); if ( m_flowDiagSolution ) { diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index a6bf1c6504..8fe72ac89d 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -115,6 +115,7 @@ private: void updateWellFlowPlotXAxisTitle( RimWellLogTrack* plotTrack ); void addStackedCurve( const QString& tracerName, + RiaDefines::DepthTypeEnum depthType, const std::vector& depthValues, const std::vector& accFlow, RimWellLogTrack* plotTrack ); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index cff8accfe2..be43733c89 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -218,7 +218,8 @@ void RimWellFlowRateCurve::updateStackedPlotData() bool isFirstTrack = ( wellLogTrack == wellLogPlot->plotByIndex( 0 ) ); - RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_NONE; + RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType(); + RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_NONE; std::vector depthValues; std::vector stackedValues; @@ -236,7 +237,7 @@ void RimWellFlowRateCurve::updateStackedPlotData() stackedCurves = stackedCurveGroups[groupId()]; } - std::vector allDepthValues = curveData()->measuredDepths(); + std::vector allDepthValues = curveData()->depths( depthType ); std::vector allStackedValues( allDepthValues.size() ); for ( RimWellFlowRateCurve* stCurve : stackedCurves ) @@ -256,9 +257,9 @@ void RimWellFlowRateCurve::updateStackedPlotData() } RigWellLogCurveData tempCurveData; - tempCurveData.setValuesAndMD( allStackedValues, allDepthValues, RiaDefines::UNIT_NONE, false ); + tempCurveData.setValuesAndDepths( allStackedValues, allDepthValues, depthType, RiaDefines::UNIT_NONE, false ); - depthValues = tempCurveData.measuredDepthPlotValues( displayUnit ); + depthValues = tempCurveData.depthPlotValues( depthType, displayUnit ); stackedValues = tempCurveData.xPlotValues(); polyLineStartStopIndices = tempCurveData.polylineStartStopIndices(); } @@ -321,7 +322,7 @@ bool RimWellFlowRateCurve::isUsingConnectionNumberDepthType() const { RimWellLogPlot* wellLogPlot; firstAncestorOrThisOfType( wellLogPlot ); - if ( wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::CONNECTION_NUMBER ) + if ( wellLogPlot && wellLogPlot->depthType() == RiaDefines::CONNECTION_NUMBER ) { return true; } @@ -344,10 +345,11 @@ RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const /// //-------------------------------------------------------------------------------------------------- void RimWellFlowRateCurve::setFlowValuesPrDepthValue( const QString& curveName, + RiaDefines::DepthTypeEnum depthType, const std::vector& depthValues, const std::vector& flowRates ) { - this->setValuesAndMD( flowRates, depthValues, RiaDefines::UNIT_NONE, false ); + this->setValuesAndDepths( flowRates, depthValues, depthType, RiaDefines::UNIT_NONE, false ); m_curveAutoName = curveName; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h index 1b71168e1c..c6385d4eed 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.h @@ -39,6 +39,7 @@ public: ~RimWellFlowRateCurve() override; void setFlowValuesPrDepthValue( const QString& curveName, + RiaDefines::DepthTypeEnum depthType, const std::vector& depthValues, const std::vector& flowRates ); void updateStackedPlotData(); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 0bbf9a51da..c589c01dcb 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -139,7 +139,7 @@ RimWellPltPlot::RimWellPltPlot() m_doInitAfterLoad = false; m_isOnLoad = true; - setAvailableDepthTypes( {RimWellLogPlot::MEASURED_DEPTH} ); + setAvailableDepthTypes( {RiaDefines::MEASURED_DEPTH} ); } //-------------------------------------------------------------------------------------------------- @@ -725,7 +725,7 @@ void RimWellPltPlot::addStackedCurve( const QString& curveName, bool doFillCurve ) { RimWellFlowRateCurve* curve = new RimWellFlowRateCurve; - curve->setFlowValuesPrDepthValue( curveName, depthValues, accFlow ); + curve->setFlowValuesPrDepthValue( curveName, depthType(), depthValues, accFlow ); curve->setColor( color ); curve->setGroupId( curveGroupId ); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 384d3f7c88..15547e6692 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -88,7 +88,7 @@ RimWellRftPlot::RimWellRftPlot() m_wellLogPlot_OBSOLETE.uiCapability()->setUiHidden( true ); m_wellLogPlot_OBSOLETE.xmlCapability()->setIOWritable( false ); - m_depthType = RimWellLogPlot::TRUE_VERTICAL_DEPTH; + m_depthType = RiaDefines::TRUE_VERTICAL_DEPTH; CAF_PDM_InitFieldNoDefault( &m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", "" ); CAF_PDM_InitField( &m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "" ); @@ -620,7 +620,7 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set* values, std:: // These values are for a simulation well *values = curveData->xValues(); - *measuredDepthValues = curveData->measuredDepths(); + *measuredDepthValues = curveData->depths( RiaDefines::MEASURED_DEPTH ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp index 49dc5e4f5e..f7dc139592 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp @@ -52,12 +52,8 @@ RimWellLogCurve::RimWellLogCurve() m_curveData = new RigWellLogCurveData; - m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), + m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); - m_curveDataMDRange = std::make_pair( std::numeric_limits::infinity(), - -std::numeric_limits::infinity() ); - m_curveDataTVDRange = std::make_pair( std::numeric_limits::infinity(), - -std::numeric_limits::infinity() ); } //-------------------------------------------------------------------------------------------------- @@ -104,28 +100,19 @@ bool RimWellLogCurve::yValueRangeInData( double* minimumValue, double* maximumVa RimWellLogPlot* wellLogPlot = nullptr; firstAncestorOrThisOfTypeAsserted( wellLogPlot ); - if ( wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + auto depthRangeIt = m_curveDataDepthRange.find( wellLogPlot->depthType() ); + if ( depthRangeIt == m_curveDataDepthRange.end() ) { - if ( m_curveDataTVDRange.first == -std::numeric_limits::infinity() || - m_curveDataTVDRange.second == std::numeric_limits::infinity() ) - { - return false; - } - - *minimumValue = m_curveDataTVDRange.first; - *maximumValue = m_curveDataTVDRange.second; + return false; } - else // MD, Connection number and Pseudo length. + + if ( depthRangeIt->second.first == -std::numeric_limits::infinity() || + depthRangeIt->second.second == std::numeric_limits::infinity() ) { - if ( m_curveDataMDRange.first == -std::numeric_limits::infinity() || - m_curveDataMDRange.second == std::numeric_limits::infinity() ) - { - return false; - } - - *minimumValue = m_curveDataMDRange.first; - *maximumValue = m_curveDataMDRange.second; + return false; } + *minimumValue = depthRangeIt->second.first; + *maximumValue = depthRangeIt->second.second; return true; } @@ -133,12 +120,25 @@ bool RimWellLogCurve::yValueRangeInData( double* minimumValue, double* maximumVa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurve::setValuesAndMD( const std::vector& xValues, - const std::vector& measuredDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ) +void RimWellLogCurve::setValuesAndDepths( const std::vector& xValues, + const std::vector& measuredDepths, + RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ) { - m_curveData->setValuesAndMD( xValues, measuredDepths, depthUnit, isExtractionCurve ); + m_curveData->setValuesAndDepths( xValues, measuredDepths, depthType, depthUnit, isExtractionCurve ); + calculateCurveDataRanges(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurve::setValuesAndDepths( const std::vector& xValues, + const std::map>& depths, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ) +{ + m_curveData->setValuesAndDepths( xValues, depths, depthUnit, isExtractionCurve ); calculateCurveDataRanges(); } @@ -151,8 +151,9 @@ void RimWellLogCurve::setValuesWithTVD( const std::vector& xValues, RiaDefines::DepthUnitType depthUnit, bool isExtractionCurve ) { - m_curveData->setValuesWithTVD( xValues, measuredDepths, tvDepths, depthUnit, isExtractionCurve ); - calculateCurveDataRanges(); + std::map> depths = {{RiaDefines::MEASURED_DEPTH, measuredDepths}, + {RiaDefines::TRUE_VERTICAL_DEPTH, tvDepths}}; + setValuesAndDepths( xValues, depths, depthUnit, isExtractionCurve ); } //-------------------------------------------------------------------------------------------------- @@ -204,15 +205,18 @@ void RimWellLogCurve::setOverrideCurveDataXRange( double minimumValue, double ma void RimWellLogCurve::calculateCurveDataRanges() { // Invalidate range first - m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), + m_curveDataXRange = std::make_pair( std::numeric_limits::infinity(), -std::numeric_limits::infinity() ); - m_curveDataMDRange = std::make_pair( std::numeric_limits::infinity(), - -std::numeric_limits::infinity() ); - m_curveDataTVDRange = std::make_pair( std::numeric_limits::infinity(), - -std::numeric_limits::infinity() ); - m_curveData->calculateMDRange( &m_curveDataMDRange.first, &m_curveDataMDRange.second ); - m_curveData->calculateTVDRange( &m_curveDataTVDRange.first, &m_curveDataTVDRange.second ); + for ( auto depthType : m_curveData->availableDepthTypes() ) + { + m_curveDataDepthRange[depthType] = std::make_pair( std::numeric_limits::infinity(), + -std::numeric_limits::infinity() ); + + m_curveData->calculateDepthRange( depthType, + &m_curveDataDepthRange[depthType].first, + &m_curveDataDepthRange[depthType].second ); + } for ( double xValue : m_curveData->xValues() ) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h index 0f9beab563..b54e6de656 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h @@ -42,16 +42,20 @@ public: bool xValueRangeInData( double* minimumValue, double* maximumValue ) const; bool yValueRangeInData( double* minimumValue, double* maximumValue ) const; - void setValuesAndMD( const std::vector& xValues, - const std::vector& measuredDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ); - + void setValuesAndDepths( const std::vector& xValues, + const std::vector& depths, + RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ); void setValuesWithTVD( const std::vector& xValues, const std::vector& measuredDepths, const std::vector& tvDepths, RiaDefines::DepthUnitType depthUnit, bool isExtractionCurve ); + void setValuesAndDepths( const std::vector& xValues, + const std::map>& depths, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ); const RigWellLogCurveData* curveData() const; @@ -71,8 +75,7 @@ private: void calculateCurveDataRanges(); private: - cvf::ref m_curveData; - std::pair m_curveDataXRange; - std::pair m_curveDataMDRange; - std::pair m_curveDataTVDRange; + cvf::ref m_curveData; + std::pair m_curveDataXRange; + std::map> m_curveDataDepthRange; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 830d4596f9..4339ec8bb6 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -338,27 +338,16 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) bool isUsingPseudoLength = false; performDataExtraction( &isUsingPseudoLength ); - RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER; - RimWellLogPlot* wellLogPlot; firstAncestorOrThisOfType( wellLogPlot ); if ( !wellLogPlot ) return; - displayUnit = wellLogPlot->depthUnit(); + RiaDefines::DepthTypeEnum depthType = wellLogPlot->depthType(); + RiaDefines::DepthUnitType displayUnit = wellLogPlot->depthUnit(); - if ( wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) - { - m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(), - curveData()->trueDepthPlotValues( displayUnit ).data(), - static_cast( curveData()->xPlotValues().size() ) ); - isUsingPseudoLength = false; - } - else if ( wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ) - { - m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(), - curveData()->measuredDepthPlotValues( displayUnit ).data(), - static_cast( curveData()->xPlotValues().size() ) ); - } + m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(), + curveData()->depthPlotValues( depthType, displayUnit ).data(), + static_cast( curveData()->xPlotValues().size() ) ); m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() ); @@ -523,7 +512,11 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength, { if ( !tvDepthValues.size() ) { - this->setValuesAndMD( values, measuredDepthValues, depthUnit, !performDataSmoothing ); + this->setValuesAndDepths( values, + measuredDepthValues, + RiaDefines::MEASURED_DEPTH, + depthUnit, + !performDataSmoothing ); } else { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index 428d3d2a35..8b79e33b1d 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -89,7 +89,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) std::vector values = wellLogFile->values( m_wellLogChannnelName ); std::vector measuredDepthValues = wellLogFile->depthValues(); - if ( wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + if ( wellLogPlot && wellLogPlot->depthType() == RiaDefines::TRUE_VERTICAL_DEPTH ) { bool canUseTvd = false; if ( wellLogFile->hasTvdChannel() ) @@ -112,21 +112,21 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) RigWellPath* rigWellPath = m_wellPath->wellPathGeometry(); if ( rigWellPath ) { - std::vector trueVerticeldepthValues; + std::vector trueVerticalDepthValues; for ( double measuredDepthValue : measuredDepthValues ) { - trueVerticeldepthValues.push_back( + trueVerticalDepthValues.push_back( -rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() ); } - if ( values.size() == trueVerticeldepthValues.size() && + if ( values.size() == trueVerticalDepthValues.size() && values.size() == measuredDepthValues.size() ) { - this->setValuesWithTVD( values, - measuredDepthValues, - trueVerticeldepthValues, - wellLogFile->depthUnit(), - false ); + this->setValuesAndDepths( values, + measuredDepthValues, + RiaDefines::MEASURED_DEPTH, + wellLogFile->depthUnit(), + false ); canUseTvd = true; } } @@ -150,7 +150,11 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { if ( values.size() == measuredDepthValues.size() ) { - this->setValuesAndMD( values, measuredDepthValues, wellLogFile->depthUnit(), false ); + this->setValuesAndDepths( values, + measuredDepthValues, + RiaDefines::MEASURED_DEPTH, + wellLogFile->depthUnit(), + false ); } } } @@ -166,16 +170,18 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { displayUnit = wellLogPlot->depthUnit(); } - if ( wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + if ( wellLogPlot && wellLogPlot->depthType() == RiaDefines::TRUE_VERTICAL_DEPTH && + this->curveData()->availableDepthTypes().count( RiaDefines::TRUE_VERTICAL_DEPTH ) ) { - m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(), - this->curveData()->trueDepthPlotValues( displayUnit ).data(), - static_cast( this->curveData()->xPlotValues().size() ) ); + m_qwtPlotCurve + ->setSamples( this->curveData()->xPlotValues().data(), + this->curveData()->depthPlotValues( RiaDefines::TRUE_VERTICAL_DEPTH, displayUnit ).data(), + static_cast( this->curveData()->xPlotValues().size() ) ); } else { m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(), - this->curveData()->measuredDepthPlotValues( displayUnit ).data(), + this->curveData()->depthPlotValues( RiaDefines::MEASURED_DEPTH, displayUnit ).data(), static_cast( this->curveData()->xPlotValues().size() ) ); } m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 7a7f675149..07b06aaf77 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -49,16 +49,6 @@ namespace caf { -template <> -void caf::AppEnum::setUp() -{ - addItem( RimWellLogPlot::MEASURED_DEPTH, "MEASURED_DEPTH", "Measured Depth" ); - addItem( RimWellLogPlot::TRUE_VERTICAL_DEPTH, "TRUE_VERTICAL_DEPTH", "True Vertical Depth (MSL)" ); - addItem( RimWellLogPlot::PSEUDO_LENGTH, "PSEUDO_LENGTH", "Pseudo Length" ); - addItem( RimWellLogPlot::CONNECTION_NUMBER, "CONNECTION_NUMBER", "Connection Number" ); - setDefault( RimWellLogPlot::MEASURED_DEPTH ); -} - template <> void RimWellLogPlot::AxisGridEnum::setUp() { @@ -90,7 +80,7 @@ RimWellLogPlot::RimWellLogPlot() m_commonDataSource.xmlCapability()->disableIO(); m_commonDataSource = new RimWellLogCurveCommonDataSource; - caf::AppEnum depthType = MEASURED_DEPTH; + caf::AppEnum depthType = RiaDefines::MEASURED_DEPTH; CAF_PDM_InitField( &m_depthType, "DepthType", depthType, "Type", "", "", "" ); caf::AppEnum depthUnit = RiaDefines::UNIT_METER; @@ -108,7 +98,7 @@ RimWellLogPlot::RimWellLogPlot() m_nameConfig = new RimWellLogPlotNameConfig(); m_availableDepthUnits = {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET}; - m_availableDepthTypes = {MEASURED_DEPTH, TRUE_VERTICAL_DEPTH}; + m_availableDepthTypes = {RiaDefines::MEASURED_DEPTH, RiaDefines::TRUE_VERTICAL_DEPTH}; m_minAvailableDepth = HUGE_VAL; m_maxAvailableDepth = -HUGE_VAL; @@ -741,24 +731,24 @@ QString RimWellLogPlot::depthAxisTitle() const switch ( m_depthType.value() ) { - case MEASURED_DEPTH: + case RiaDefines::MEASURED_DEPTH: depthTitle = "MD"; break; - case TRUE_VERTICAL_DEPTH: + case RiaDefines::TRUE_VERTICAL_DEPTH: depthTitle = "TVDMSL"; break; - case PSEUDO_LENGTH: + case RiaDefines::PSEUDO_LENGTH: depthTitle = "PL"; break; - case CONNECTION_NUMBER: + case RiaDefines::CONNECTION_NUMBER: depthTitle = "Connection"; break; } - if ( m_depthType() == CONNECTION_NUMBER ) return depthTitle; + if ( m_depthType() == RiaDefines::CONNECTION_NUMBER ) return depthTitle; if ( m_depthUnit == RiaDefines::UNIT_METER ) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index ec91396ece..a6cf3fcb6a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -48,14 +48,6 @@ class RimWellLogPlot : public RimGridPlotWindow, public RimNameConfigHolderInter CAF_PDM_HEADER_INIT; public: - enum DepthTypeEnum - { - MEASURED_DEPTH, - TRUE_VERTICAL_DEPTH, - PSEUDO_LENGTH, - CONNECTION_NUMBER - }; - enum AxisGridVisibility { AXIS_GRID_NONE = 0x00, @@ -65,6 +57,7 @@ public: }; typedef caf::AppEnum AxisGridEnum; + using DepthTypeEnum = RiaDefines::DepthTypeEnum; public: RimWellLogPlot(); @@ -106,7 +99,7 @@ public: void setCommonDataSourceEnabled( bool enable ); void setAvailableDepthUnits( const std::set& depthUnits ); - void setAvailableDepthTypes( const std::set& depthTypes ); + void setAvailableDepthTypes( const std::set& depthTypes ); void onPlotAdditionOrRemoval() override; @@ -146,8 +139,8 @@ protected: caf::PdmChildField m_nameConfig; - std::set m_availableDepthUnits; - std::set m_availableDepthTypes; + std::set m_availableDepthUnits; + std::set m_availableDepthTypes; double m_minAvailableDepth; double m_maxAvailableDepth; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogRftCurve.cpp index 0ec4efd250..b10ebca117 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogRftCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogRftCurve.cpp @@ -445,12 +445,13 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) displayUnit = wellLogPlot->depthUnit(); } - if ( wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ) + if ( wellLogPlot->depthType() == RiaDefines::MEASURED_DEPTH ) { m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData ); m_qwtPlotCurve->setPerPointLabels( perPointLabels ); m_qwtPlotCurve->setSamplesFromXValuesAndYValues( this->curveData()->xPlotValues(), - this->curveData()->measuredDepthPlotValues( displayUnit ), + this->curveData()->depthPlotValues( RiaDefines::MEASURED_DEPTH, + displayUnit ), errors, false, RiuQwtPlotCurve::ERROR_ALONG_X_AXIS ); @@ -485,7 +486,8 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData ); m_qwtPlotCurve->setPerPointLabels( perPointLabels ); m_qwtPlotCurve->setSamplesFromXValuesAndYValues( this->curveData()->xPlotValues(), - this->curveData()->trueDepthPlotValues( displayUnit ), + this->curveData()->depthPlotValues( RiaDefines::TRUE_VERTICAL_DEPTH, + displayUnit ), errors, false, RiuQwtPlotCurve::ERROR_ALONG_X_AXIS ); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 5cfabf25c2..8e4f0d9a4f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -781,14 +781,7 @@ QString RimWellLogTrack::asciiDataForPlotExport() const if ( curveNames.size() == 1 ) { - if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) - { - curveDepths = curveData->trueDepthPlotValues( depthUnit ); - } - else - { - curveDepths = curveData->measuredDepthPlotValues( depthUnit ); - } + curveDepths = curveData->depthPlotValues( depthType, depthUnit ); } std::vector xPlotValues = curveData->xPlotValues(); @@ -809,13 +802,13 @@ QString RimWellLogTrack::asciiDataForPlotExport() const { if ( i == 0 ) { - if ( depthType == RimWellLogPlot::CONNECTION_NUMBER ) + if ( depthType == RiaDefines::CONNECTION_NUMBER ) out += "Connection"; - else if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) + else if ( depthType == RiaDefines::MEASURED_DEPTH ) out += "MD "; - else if ( depthType == RimWellLogPlot::PSEUDO_LENGTH ) + else if ( depthType == RiaDefines::PSEUDO_LENGTH ) out += "PL "; - else if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) out += "TVD "; for ( QString name : curveNames ) out += " \t" + name; @@ -1971,11 +1964,11 @@ void RimWellLogTrack::findRegionNamesToPlot( const CurveSamplingPointData& std::vector depthVector; - if ( depthType == RimWellLogPlot::MEASURED_DEPTH || depthType == RimWellLogPlot::PSEUDO_LENGTH ) + if ( depthType == RiaDefines::MEASURED_DEPTH || depthType == RiaDefines::PSEUDO_LENGTH ) { depthVector = curveData.md; } - else if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { depthVector = curveData.tvd; } @@ -2171,8 +2164,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot() { if ( m_formationWellPathForSourceWellPath == nullptr ) return; - if ( !( plot->depthType() == RimWellLogPlot::MEASURED_DEPTH || - plot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) ) + if ( !( plot->depthType() == RiaDefines::MEASURED_DEPTH || plot->depthType() == RiaDefines::TRUE_VERTICAL_DEPTH ) ) { return; } diff --git a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp index df328cd18d..b343fa61fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -202,26 +202,32 @@ public: if ( firstCurveData->depthUnit() == RiaDefines::UNIT_METER ) { - lasFile->AddLog( "DEPTH", "M", "Depth in meters", firstCurveData->measuredDepths() ); + lasFile->AddLog( "DEPTH", "M", "Depth in meters", firstCurveData->depths( RiaDefines::MEASURED_DEPTH ) ); } else if ( firstCurveData->depthUnit() == RiaDefines::UNIT_FEET ) { - lasFile->AddLog( "DEPTH", "FT", "Depth in feet", firstCurveData->measuredDepths() ); + lasFile->AddLog( "DEPTH", "FT", "Depth in feet", firstCurveData->depths( RiaDefines::MEASURED_DEPTH ) ); } else if ( firstCurveData->depthUnit() == RiaDefines::UNIT_NONE ) { CVF_ASSERT( false ); - lasFile->AddLog( "DEPTH", "", "Depth in Connection number", firstCurveData->measuredDepths() ); + lasFile->AddLog( "DEPTH", + "", + "Depth in Connection number", + firstCurveData->depths( RiaDefines::MEASURED_DEPTH ) ); } - if ( firstCurveData->tvDepths().size() ) + if ( firstCurveData->depths( RiaDefines::TRUE_VERTICAL_DEPTH ).size() ) { - lasFile->AddLog( "TVDMSL", "M", "True vertical depth in meters", firstCurveData->tvDepths() ); + lasFile->AddLog( "TVDMSL", + "M", + "True vertical depth in meters", + firstCurveData->depths( RiaDefines::TRUE_VERTICAL_DEPTH ) ); if ( m_exportTvdrkb && m_rkbDiff != -1.0 ) { // Export True Vertical Depth Rotary Kelly Bushing - TVDRKB - std::vector tvdrkbValues = firstCurveData->tvDepths(); + std::vector tvdrkbValues = firstCurveData->depths( RiaDefines::TRUE_VERTICAL_DEPTH ); for ( auto& value : tvdrkbValues ) { value += m_rkbDiff; @@ -245,7 +251,7 @@ public: double minDepth = 0.0; double maxDepth = 0.0; - firstCurveData->calculateMDRange( &minDepth, &maxDepth ); + firstCurveData->calculateDepthRange( RiaDefines::MEASURED_DEPTH, &minDepth, &maxDepth ); lasFile->setStartDepth( minDepth ); lasFile->setStopDepth( maxDepth ); diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp index 917aaf345e..5ef038a91e 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -45,17 +45,17 @@ RigWellLogCurveData::~RigWellLogCurveData() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellLogCurveData::setValuesAndMD( const std::vector& xValues, - const std::vector& measuredDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ) +void RigWellLogCurveData::setValuesAndDepths( const std::vector& xValues, + const std::vector& depths, + RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ) { - CVF_ASSERT( xValues.size() == measuredDepths.size() ); + CVF_ASSERT( xValues.size() == depths.size() ); - m_xValues = xValues; - m_measuredDepths = measuredDepths; - m_tvDepths.clear(); - m_depthUnit = depthUnit; + m_xValues = xValues; + m_depths[depthType] = depths; + m_depthUnit = depthUnit; // Disable depth value filtering is intended to be used for // extraction curve data @@ -67,19 +67,22 @@ void RigWellLogCurveData::setValuesAndMD( const std::vector& xValues, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellLogCurveData::setValuesWithTVD( const std::vector& xValues, - const std::vector& measuredDepths, - const std::vector& tvDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ) +void RigWellLogCurveData::setValuesAndDepths( const std::vector& xValues, + const std::map>& depths, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ) { - CVF_ASSERT( xValues.size() == measuredDepths.size() ); + for ( auto it = depths.begin(); it != depths.end(); ++it ) + { + CVF_ASSERT( xValues.size() == it->second.size() ); + } - m_xValues = xValues; - m_measuredDepths = measuredDepths; - m_tvDepths = tvDepths; - m_depthUnit = depthUnit; + m_xValues = xValues; + m_depths = depths; + m_depthUnit = depthUnit; + // Disable depth value filtering is intended to be used for + // extraction curve data m_isExtractionCurve = isExtractionCurve; calculateIntervalsOfContinousValidValues(); @@ -96,17 +99,24 @@ const std::vector& RigWellLogCurveData::xValues() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigWellLogCurveData::measuredDepths() const +std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depthType ) const { - return m_measuredDepths; + auto it = m_depths.find( depthType ); + return it != m_depths.end() ? it->second : std::vector(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigWellLogCurveData::tvDepths() const +std::set RigWellLogCurveData::availableDepthTypes() const { - return m_tvDepths; + std::set depthTypes; + + for ( auto depthValuePair : m_depths ) + { + depthTypes.insert( depthValuePair.first ); + } + return depthTypes; } //-------------------------------------------------------------------------------------------------- @@ -123,18 +133,21 @@ std::vector RigWellLogCurveData::xPlotValues() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::trueDepthPlotValues( RiaDefines::DepthUnitType destinationDepthUnit ) const +std::vector RigWellLogCurveData::depthPlotValues( RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType destinationDepthUnit ) const { std::vector filteredValues; - if ( m_tvDepths.size() ) + + const std::vector depthValues = depths( depthType ); + if ( !depthValues.empty() ) { if ( destinationDepthUnit == m_depthUnit ) { - RiaCurveDataTools::getValuesByIntervals( m_tvDepths, m_intervalsOfContinousValidValues, &filteredValues ); + RiaCurveDataTools::getValuesByIntervals( depthValues, m_intervalsOfContinousValidValues, &filteredValues ); } else { - std::vector convertedValues = convertDepthValues( destinationDepthUnit, m_tvDepths ); + std::vector convertedValues = convertDepthValues( destinationDepthUnit, depthValues ); RiaCurveDataTools::getValuesByIntervals( convertedValues, m_intervalsOfContinousValidValues, &filteredValues ); } } @@ -142,26 +155,6 @@ std::vector RigWellLogCurveData::trueDepthPlotValues( RiaDefines::DepthU return filteredValues; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigWellLogCurveData::measuredDepthPlotValues( RiaDefines::DepthUnitType destinationDepthUnit ) const -{ - std::vector filteredValues; - - if ( destinationDepthUnit == m_depthUnit ) - { - RiaCurveDataTools::getValuesByIntervals( m_measuredDepths, m_intervalsOfContinousValidValues, &filteredValues ); - } - else - { - std::vector convertedValues = convertDepthValues( destinationDepthUnit, m_measuredDepths ); - RiaCurveDataTools::getValuesByIntervals( convertedValues, m_intervalsOfContinousValidValues, &filteredValues ); - } - - return filteredValues; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -181,17 +174,20 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( bool isTvDepthsAvailable = false; std::vector tvDepths; - if ( m_tvDepths.size() > 0 ) isTvDepthsAvailable = true; + auto mdIt = m_depths.find( RiaDefines::MEASURED_DEPTH ); + auto tvdIt = m_depths.find( RiaDefines::TRUE_VERTICAL_DEPTH ); - if ( m_measuredDepths.size() > 0 ) + if ( tvdIt != m_depths.end() && !tvdIt->second.empty() ) isTvDepthsAvailable = true; + + if ( mdIt != m_depths.end() && !mdIt->second.empty() ) { - double currentMd = m_measuredDepths[0]; + double currentMd = mdIt->second.front(); size_t segmentStartIdx = 0; - while ( segmentStartIdx < m_measuredDepths.size() - 1 ) + while ( segmentStartIdx < mdIt->second.size() - 1 ) { - double segmentStartMd = m_measuredDepths[segmentStartIdx]; - double segmentEndMd = m_measuredDepths[segmentStartIdx + 1]; + double segmentStartMd = mdIt->second[segmentStartIdx]; + double segmentEndMd = mdIt->second[segmentStartIdx + 1]; double segmentStartX = m_xValues[segmentStartIdx]; double segmentEndX = m_xValues[segmentStartIdx + 1]; @@ -199,8 +195,8 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( double segmentEndTvd = 0.0; if ( isTvDepthsAvailable ) { - segmentStartTvd = m_tvDepths[segmentStartIdx]; - segmentEndTvd = m_tvDepths[segmentStartIdx + 1]; + segmentStartTvd = tvdIt->second[segmentStartIdx]; + segmentEndTvd = tvdIt->second[segmentStartIdx + 1]; } while ( currentMd <= segmentEndMd ) @@ -228,11 +224,17 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData( if ( isTvDepthsAvailable ) { - reSampledData->setValuesWithTVD( xValues, measuredDepths, tvDepths, m_depthUnit, true ); + std::map> resampledDepths = + {{RiaDefines::TRUE_VERTICAL_DEPTH, tvDepths}, {RiaDefines::MEASURED_DEPTH, measuredDepths}}; + reSampledData->setValuesAndDepths( xValues, resampledDepths, m_depthUnit, true ); } else { - reSampledData->setValuesAndMD( xValues, measuredDepths, m_depthUnit, m_isExtractionCurve ); + reSampledData->setValuesAndDepths( xValues, + measuredDepths, + RiaDefines::MEASURED_DEPTH, + m_depthUnit, + m_isExtractionCurve ); } return reSampledData; @@ -258,7 +260,7 @@ void RigWellLogCurveData::calculateIntervalsOfContinousValidValues() for ( size_t intIdx = 0; intIdx < intervalsCount; intIdx++ ) { std::vector> depthValuesIntervals; - splitIntervalAtEmptySpace( m_measuredDepths, + splitIntervalAtEmptySpace( m_depths[RiaDefines::MEASURED_DEPTH], intervalsOfValidValues[intIdx].first, intervalsOfValidValues[intIdx].second, &depthValuesIntervals ); @@ -323,16 +325,18 @@ void RigWellLogCurveData::splitIntervalAtEmptySpace( const std::vector& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigWellLogCurveData::calculateMDRange( double* minimumDepth, double* maximumDepth ) const +bool RigWellLogCurveData::calculateDepthRange( RiaDefines::DepthTypeEnum depthType, + double* minimumDepth, + double* maximumDepth ) const { CVF_ASSERT( minimumDepth && maximumDepth ); double minValue = HUGE_VAL; double maxValue = -HUGE_VAL; - for ( size_t vIdx = 0; vIdx < m_measuredDepths.size(); vIdx++ ) + for ( size_t vIdx = 0; vIdx < depths( depthType ).size(); vIdx++ ) { - double value = m_measuredDepths[vIdx]; + double value = depths( depthType )[vIdx]; if ( value < minValue ) { @@ -356,42 +360,6 @@ bool RigWellLogCurveData::calculateMDRange( double* minimumDepth, double* maximu return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigWellLogCurveData::calculateTVDRange( double* minTVD, double* maxTVD ) const -{ - CVF_ASSERT( minTVD && maxTVD ); - - double minValue = HUGE_VAL; - double maxValue = -HUGE_VAL; - - for ( size_t vIdx = 0; vIdx < m_tvDepths.size(); vIdx++ ) - { - double value = m_tvDepths[vIdx]; - - if ( value < minValue ) - { - minValue = value; - } - - if ( value > maxValue ) - { - maxValue = value; - } - } - - if ( maxValue >= minValue ) - { - *minTVD = minValue; - *maxTVD = maxValue; - - return true; - } - - return false; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h index 1e49fce51c..c47572406d 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.h @@ -23,6 +23,8 @@ #include "cvfObject.h" +#include +#include #include class RigWellLogCurveDataTestInterface; @@ -36,28 +38,29 @@ public: RigWellLogCurveData(); ~RigWellLogCurveData() override; - void setValuesAndMD( const std::vector& xValues, - const std::vector& measuredDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ); - - void setValuesWithTVD( const std::vector& xValues, - const std::vector& measuredDepths, - const std::vector& tvDepths, - RiaDefines::DepthUnitType depthUnit, - bool isExtractionCurve ); + void setValuesAndDepths( const std::vector& xValues, + const std::vector& depths, + RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ); + void setValuesAndDepths( const std::vector& xValues, + const std::map>& depths, + RiaDefines::DepthUnitType depthUnit, + bool isExtractionCurve ); const std::vector& xValues() const; - const std::vector& measuredDepths() const; - const std::vector& tvDepths() const; - bool calculateMDRange( double* minMD, double* maxMD ) const; - bool calculateTVDRange( double* minTVD, double* maxTVD ) const; + + std::vector depths( RiaDefines::DepthTypeEnum depthType ) const; + + std::set availableDepthTypes() const; + + bool calculateDepthRange( RiaDefines::DepthTypeEnum depthType, double* minMD, double* maxMD ) const; RiaDefines::DepthUnitType depthUnit() const; - std::vector xPlotValues() const; - std::vector trueDepthPlotValues( RiaDefines::DepthUnitType destinationDepthUnit ) const; - std::vector measuredDepthPlotValues( RiaDefines::DepthUnitType destinationDepthUnit ) const; + std::vector xPlotValues() const; + std::vector depthPlotValues( RiaDefines::DepthTypeEnum depthType, + RiaDefines::DepthUnitType destinationDepthUnit ) const; std::vector> polylineStartStopIndices() const; cvf::ref calculateResampledCurveData( double newMeasuredDepthStepSize ) const; @@ -77,10 +80,9 @@ private: static std::vector convertFromFeetToMeter( const std::vector& valuesInFeet ); private: - std::vector m_xValues; - std::vector m_measuredDepths; - std::vector m_tvDepths; - bool m_isExtractionCurve; + std::vector m_xValues; + std::map> m_depths; + bool m_isExtractionCurve; std::vector> m_intervalsOfContinousValidValues; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index e59d4195ac..68b0c4472d 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -55,7 +55,7 @@ void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth( std: { std::map tempMakeVectorUniqueOnMeasuredDepth; - if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) + if ( depthType == RiaDefines::MEASURED_DEPTH ) { for ( const std::pair& formation : m_formations ) { @@ -77,7 +77,7 @@ void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth( std: } } } - else if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { for ( const std::pair& formation : m_formations ) { @@ -106,11 +106,11 @@ void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth( std: if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop)) { double depth; - if (depthType == RimWellLogPlot::MEASURED_DEPTH) + if (depthType == RiaDefines::MEASURED_DEPTH) { depth = formation.first.mdTop; } - else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH) + else if (depthType == RiaDefines::TRUE_VERTICAL_DEPTH) { depth = formation.first.tvdTop; } @@ -125,11 +125,11 @@ void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth( std: for (const std::pair& formation : m_formations) { double depth; - if (depthType == RimWellLogPlot::MEASURED_DEPTH) + if (depthType == RiaDefines::MEASURED_DEPTH) { depth = formation.first.mdBase; } - else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH) + else if (depthType == RiaDefines::TRUE_VERTICAL_DEPTH) { depth = formation.first.tvdBase; } @@ -169,7 +169,7 @@ void RigWellPathFormations::evaluateFormationsForOnePosition( { double depth; - if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) + if ( depthType == RiaDefines::MEASURED_DEPTH ) { if ( position == TOP ) { @@ -180,7 +180,7 @@ void RigWellPathFormations::evaluateFormationsForOnePosition( depth = formation.first.mdBase; } } - else if ( depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { if ( position == TOP ) { @@ -237,11 +237,11 @@ void RigWellPathFormations::evaluateFluids( const std::vector RiuWellPathComponentPlotItem::depthsOfDepthType() cons double startDepth = m_startMD; double endDepth = m_endMD; - if ( m_depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH ) + if ( m_depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { cvf::Vec3d startPoint = m_wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( m_startMD ); cvf::Vec3d endPoint = m_wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( m_endMD );