From d4f11e0f8fd71917547ce555b36c4ca72b49b982 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 19 Apr 2023 07:16:13 +0200 Subject: [PATCH] WBS-plot: Add optional support for maximum curve interval for UCS parameter curve (#10118) * WBS-plot: Add optional support for maximum curve interval for UCS parameter curve * GeoMech: Guard out-of-bound access to Pore pressure data --- .../RigFemPartResultCalculatorNormalST.cpp | 15 +++++++----- .../RimWellLogCurveCommonDataSource.cpp | 8 +++++++ .../WellLog/RimWellLogCurveCommonDataSource.h | 2 ++ .../WellLog/RimWellLogExtractionCurve.cpp | 24 +++++++++++++++++++ .../WellLog/RimWellLogWbsCurve.h | 2 +- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp index 634e12e993..a163abeb21 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp @@ -105,14 +105,17 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int par { for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + const size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + float por = 0.0f; + if ( nodeIdx < srcPORFrameData.size() ) + { + por = srcPORFrameData[nodeIdx]; + if ( por == inf ) por = 0.0f; + } + if ( elmNodResIdx < srcSFrameData.size() ) { - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - - float por = srcPORFrameData[nodeIdx]; - if ( por == inf ) por = 0.0f; - // ST = SE_abacus + porePressure // porePressure is POR-Bar. double SE_abacus = -srcSFrameData[elmNodResIdx]; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index ed9150faef..dee1dcbe96 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -833,6 +833,14 @@ QString RimWellLogCurveCommonDataSource::smoothingUiOrderinglabel() return "ApplySmoothing"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimWellLogCurveCommonDataSource::maximumCurvePointInterval() const +{ + return m_maximumCurvePointInterval(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h index d71b4732ef..fe7c9fd36b 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h @@ -103,6 +103,8 @@ public: static QString smoothingUiOrderinglabel(); + std::pair maximumCurvePointInterval() const; + private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index cc92989d29..2ee510ed46 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -50,6 +50,7 @@ #include "RimTools.h" #include "RimWellBoreStabilityPlot.h" #include "RimWellLogCurve.h" +#include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogFile.h" #include "RimWellLogFileChannel.h" #include "RimWellLogPlot.h" @@ -421,6 +422,29 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::performDataExtraction( bool* isUsingPseudoLength ) { + if ( dynamic_cast( m_case.value() ) && ( m_geomResultDefinition->resultPositionType() == RIG_WELLPATH_DERIVED ) && + ( m_geomResultDefinition->resultFieldName() == "UCS" ) ) + { + RimWellBoreStabilityPlot* wbsPlot = nullptr; + this->firstAncestorOrThisOfType( wbsPlot ); + if ( wbsPlot ) + { + auto maxCurvePointInterval = wbsPlot->commonDataSource()->maximumCurvePointInterval(); + if ( maxCurvePointInterval.first ) + { + double maxIntervalLength = maxCurvePointInterval.second; + + // Special handling for a UCS parameter curve as this curve also depends on UCS that can be defined in a LAS file with + // high resolution. The maximum curve interval was designed to only be used by RimWellLogWbsCurve. To be able to use + // this functionality for a wellpath UCS curve, we get the maximumCurvePointInterval directly. It is not possible to + // control this setting locally on the curve object, the value is always taken directly from the WBS plot settings. + extractData( isUsingPseudoLength, {}, maxIntervalLength ); + + return; + } + } + } + extractData( isUsingPseudoLength, {}, {} ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.h index 731fb747de..75989eb87c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogWbsCurve.h @@ -27,7 +27,7 @@ std::optional createOptional( bool enable, const T& value ) { if ( !enable ) return {}; - return std::optional( value ); + return value; } template