From 8e94caceed2e8d2fba85460cb22dca596f50f761 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 29 Nov 2019 13:53:02 +0100 Subject: [PATCH] Fix Well Allocation Plot depth axis zoom --- .../Flow/RimWellAllocationPlot.cpp | 55 ++++++++++++++++--- .../Flow/RimWellFlowRateCurve.cpp | 51 ++--------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 7ab6d6514a..e6e0f73e4e 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -308,23 +308,60 @@ void RimWellAllocationPlot::updateFromWell() std::vector tracerNames = wfCalculator->tracerNames(); for ( const QString& tracerName : tracerNames ) { - const std::vector* accFlow = nullptr; + std::vector curveDepthValues = depthValues; + std::vector accFlow; if ( depthType == RiaDefines::CONNECTION_NUMBER ) { - accFlow = &( m_flowType == ACCUMULATED - ? wfCalculator->accumulatedTracerFlowPrConnection( tracerName, brIdx ) - : wfCalculator->tracerFlowPrConnection( tracerName, brIdx ) ); + accFlow = ( m_flowType == ACCUMULATED + ? wfCalculator->accumulatedTracerFlowPrConnection( tracerName, brIdx ) + : wfCalculator->tracerFlowPrConnection( tracerName, brIdx ) ); + + // Insert the first depth position again, to add a value pair + curveDepthValues.insert( curveDepthValues.begin(), curveDepthValues[0] ); + accFlow.insert( accFlow.begin(), 0.0 ); + + if ( brIdx == 0 && !accFlow.empty() ) // Add fictitious point to 0 for first branch + { + accFlow.push_back( accFlow.back() ); + curveDepthValues.push_back( 0.0 ); + } } else if ( depthType == RiaDefines::PSEUDO_LENGTH || depthType == RiaDefines::TRUE_VERTICAL_DEPTH ) { - accFlow = &( m_flowType == ACCUMULATED - ? wfCalculator->accumulatedTracerFlowPrPseudoLength( tracerName, brIdx ) - : wfCalculator->tracerFlowPrPseudoLength( tracerName, brIdx ) ); + accFlow = ( m_flowType == ACCUMULATED + ? wfCalculator->accumulatedTracerFlowPrPseudoLength( tracerName, brIdx ) + : wfCalculator->tracerFlowPrPseudoLength( tracerName, brIdx ) ); + + // Insert the first depth position again, to add a value pair + curveDepthValues.insert( curveDepthValues.begin(), curveDepthValues[0] ); + accFlow.insert( accFlow.begin(), 0.0 ); + + if ( brIdx == 0 && branchCount > 1 ) + { + // Add a dummy negative depth value to make the contribution + // from other branches connected to well head visible + + auto minmax_it = std::minmax_element( curveDepthValues.begin(), curveDepthValues.end() ); + double availableMinDepth = *( minmax_it.first ); + double availableMaxDepth = *( minmax_it.second ); + + double depthSpan = 0.1 * cvf::Math::abs( availableMinDepth - availableMaxDepth ); + + // Round off value to floored decade + double logDecValue = log10( depthSpan ); + logDecValue = cvf::Math::floor( logDecValue ); + depthSpan = pow( 10.0, logDecValue ); + + double dummyNegativeDepthValue = curveDepthValues.back() - depthSpan; + + curveDepthValues.push_back( dummyNegativeDepthValue ); + accFlow.push_back( accFlow.back() ); + } } - if ( accFlow ) + if ( !accFlow.empty() ) { - addStackedCurve( tracerName, depthType, depthValues, *accFlow, plotTrack ); + addStackedCurve( tracerName, depthType, curveDepthValues, accFlow, plotTrack ); // TODO: THIs is the data to be plotted... } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp index 410ba406e1..267a73f97c 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellFlowRateCurve.cpp @@ -243,8 +243,6 @@ void RimWellFlowRateCurve::updateStackedPlotData() RimWellLogTrack* wellLogTrack; firstAncestorOrThisOfTypeAsserted( wellLogTrack ); - bool isFirstTrack = ( wellLogTrack == wellLogPlot->plotByIndex( 0 ) ); - RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType(); RiaDefines::DepthUnitType displayUnit = wellLogPlot->depthUnit(); if ( depthType == RiaDefines::CONNECTION_NUMBER ) @@ -255,7 +253,10 @@ void RimWellFlowRateCurve::updateStackedPlotData() std::vector depthValues; std::vector stackedValues; std::vector> polyLineStartStopIndices; - double zPos = -10000.0 + 100 * groupId(); // Z-position of curve, to draw them in correct order + + // Z-position of curve, to draw them in correct order + double zPos = -10000.0 + 100.0 * static_cast( groupId() ); + // Starting way behind the grid (z == 0) at -10000 giving room for 100 groups with 100 curves each before getting above the grid { std::map> stackedCurveGroups = wellLogTrack->visibleStackedCurves(); @@ -268,6 +269,8 @@ void RimWellFlowRateCurve::updateStackedPlotData() } std::vector allDepthValues = curveData()->depths( depthType ); + if ( allDepthValues.empty() ) return; + std::vector allStackedValues( allDepthValues.size() ); for ( RimWellFlowRateCurve* stCurve : stackedCurves ) @@ -294,48 +297,6 @@ void RimWellFlowRateCurve::updateStackedPlotData() polyLineStartStopIndices = tempCurveData.polylineStartStopIndices(); } - // Insert the first depth position again, to add a value pair - - if ( depthValues.size() ) // Should we really do this for all curve variants ? - { - depthValues.insert( depthValues.begin(), depthValues[0] ); - stackedValues.insert( stackedValues.begin(), 0.0 ); - polyLineStartStopIndices.front().second += 1; - - if ( wellLogPlot->plotCount() > 1 && isFirstTrack ) - { - // Add a dummy negative depth value to make the contribution - // from other branches connected to well head visible - - double availableMinDepth; - double availableMaxDepth; - wellLogPlot->availableDepthRange( &availableMinDepth, &availableMaxDepth ); - - double depthSpan = 0.1 * cvf::Math::abs( availableMinDepth - availableMaxDepth ); - - // Round off value to floored decade - double logDecValue = log10( depthSpan ); - logDecValue = cvf::Math::floor( logDecValue ); - depthSpan = pow( 10.0, logDecValue ); - - double dummyNegativeDepthValue = depthValues.back() - depthSpan; - - depthValues.push_back( dummyNegativeDepthValue ); - stackedValues.push_back( stackedValues.back() ); - polyLineStartStopIndices.front().second += 1; - } - } - - // Add a dummy point for the zeroth connection to make the "end" distribution show better. - - if ( isFirstTrack && isUsingConnectionNumberDepthType() ) - { - stackedValues.push_back( stackedValues.back() ); - depthValues.push_back( 0.0 ); - - polyLineStartStopIndices.front().second += 1; - } - auto minmax_it = std::minmax_element( stackedValues.begin(), stackedValues.end() ); this->setOverrideCurveDataXRange( *( minmax_it.first ), *( minmax_it.second ) );