From 62ce2b18e0aaff06e5fc28e8c310cb4c4aebac35 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 27 Jan 2023 10:29:11 +0100 Subject: [PATCH] RFT improvements * Avoid accessing nullptr * remove unused function * Allow RFT data from single summary case to be used in RFT plots * #9736 Support horizontal plotting of LAS curves --- .../Application/Tools/RiaSummaryTools.cpp | 10 ++++ .../Application/Tools/RiaSummaryTools.h | 2 + .../Flow/RimWellPlotTools.cpp | 29 ++++++++++- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 50 ++++++++++++++++++- .../ProjectDataModel/RimPressureDepthData.cpp | 18 ++----- .../ProjectDataModel/RimPressureDepthData.h | 3 +- .../WellLog/RimWellLogFileCurve.cpp | 5 +- 7 files changed, 93 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp index 9e8e8129db..65cf7cda56 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp @@ -52,6 +52,16 @@ RimSummaryMultiPlotCollection* RiaSummaryTools::summaryMultiPlotCollection() return RimMainPlotCollection::current()->summaryMultiPlotCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RiaSummaryTools::singleTopLevelSummaryCases() +{ + if ( summaryCaseMainCollection() ) return summaryCaseMainCollection()->topLevelSummaryCases(); + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h index daaccdff7c..10587bcdca 100644 --- a/ApplicationLibCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationLibCode/Application/Tools/RiaSummaryTools.h @@ -53,6 +53,8 @@ public: static RimSummaryCaseMainCollection* summaryCaseMainCollection(); static RimSummaryMultiPlotCollection* summaryMultiPlotCollection(); + static std::vector singleTopLevelSummaryCases(); + static void notifyCalculatedCurveNameHasChanged( int calculationId, const QString& currentCurveName ); static RimSummaryPlot* parentSummaryPlot( caf::PdmObject* object ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 8a17561cf4..eba2f3ed95 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -636,10 +636,12 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve( const RimWellLogCu } else if ( rftSummaryCase != nullptr ) { - rftSummaryCase->firstAncestorOrThisOfTypeAsserted( rftEnsemble ); + RimSummaryCaseCollection* parentEnsemble = nullptr; + + rftSummaryCase->firstAncestorOrThisOfType( parentEnsemble ); return RiaRftPltCurveDefinition( RifDataSourceForRftPlt( RifDataSourceForRftPlt::SUMMARY_RFT, rftSummaryCase, - rftEnsemble ), + parentEnsemble ), wellName, timeStep ); } @@ -855,6 +857,23 @@ std::set } } } + else if ( addr.sourceType() == RifDataSourceForRftPlt::SUMMARY_RFT ) + { + auto summaryCase = addr.summaryCase(); + if ( summaryCase && summaryCase->rftReader() ) + { + RifDataSourceForRftPlt summaryAddr( RifDataSourceForRftPlt::SUMMARY_RFT, summaryCase, addr.ensemble() ); + + std::set timeSteps = summaryCase->rftReader()->availableTimeSteps( wellPathNameOrSimWellName ); + for ( const QDateTime& time : timeSteps ) + { + if ( selectedTimeStepSet.count( time ) ) + { + curveDefs.insert( RiaRftPltCurveDefinition( summaryAddr, wellPathNameOrSimWellName, time ) ); + } + } + } + } } return curveDefs; @@ -1280,6 +1299,8 @@ std::map> RimWellPlotTools::calculat RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, gridTimeSteps ); std::set filteredEnsembleRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, ensembleRftTimeSteps ); + std::set filteredSummaryRftTimeSteps = + RimWellPlotTools::findMatchingOrAdjacentTimeSteps( baseTimeSteps, summaryRftTimeSteps ); if ( addFirstTimestep && gridTimeSteps.size() ) { @@ -1292,6 +1313,7 @@ std::map> RimWellPlotTools::calculat std::set& allFilteredTimesteps = filteredRftTimeSteps; allFilteredTimesteps.insert( filteredEnsembleRftTimeSteps.begin(), filteredEnsembleRftTimeSteps.end() ); allFilteredTimesteps.insert( filteredGridTimeSteps.begin(), filteredGridTimeSteps.end() ); + allFilteredTimesteps.insert( filteredSummaryRftTimeSteps.begin(), filteredSummaryRftTimeSteps.end() ); for ( const QDateTime& time : allFilteredTimesteps ) { @@ -1381,6 +1403,9 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps( case RifDataSourceForRftPlt::ENSEMBLE_RFT: hasEnsemble = true; break; + case RifDataSourceForRftPlt::SUMMARY_RFT: + hasRft = true; + break; } } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 2a0bf12288..e187db0ca5 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -23,6 +23,7 @@ #include "RiaDateStringParser.h" #include "RiaPlotDefines.h" #include "RiaSimWellBranchTools.h" +#include "RiaSummaryTools.h" #include "RifReaderEclipseRft.h" @@ -41,6 +42,7 @@ #include "RimPressureDepthData.h" #include "RimProject.h" #include "RimRegularLegendConfig.h" +#include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimTools.h" #include "RimWellLogExtractionCurve.h" @@ -816,6 +818,28 @@ QList RimWellRftPlot::calculateValueOptions( const caf:: } } + auto singleCases = RiaSummaryTools::singleTopLevelSummaryCases(); + if ( !singleCases.empty() ) + { + options.push_back( caf::PdmOptionItemInfo::createHeader( RifDataSourceForRftPlt::sourceTypeUiText( + RifDataSourceForRftPlt::SUMMARY_RFT ), + true ) ); + for ( auto summaryCase : singleCases ) + { + if ( summaryCase->rftReader() && + summaryCase->rftReader()->wellNames().contains( m_wellPathNameOrSimWellName ) ) + { + RimSummaryCaseCollection* parentEnsemble = nullptr; + summaryCase->firstAncestorOrThisOfType( parentEnsemble ); + auto addr = RifDataSourceForRftPlt( RifDataSourceForRftPlt::SUMMARY_RFT, summaryCase, parentEnsemble ); + + auto item = caf::PdmOptionItemInfo( summaryCase->displayCaseName(), QVariant::fromValue( addr ) ); + item.setLevel( 1 ); + options.push_back( item ); + } + } + } + const std::vector gridCases = RimWellPlotTools::gridCasesForWell( simWellName ); if ( !gridCases.empty() ) { @@ -1046,6 +1070,19 @@ std::map RimWellRftPlot::findWellSources() wellNames[simWellName].push_back( "Sim.Well" ); } } + + auto singleCases = RiaSummaryTools::singleTopLevelSummaryCases(); + for ( auto summaryCase : singleCases ) + { + if ( auto rftReader = summaryCase->rftReader() ) + { + for ( const QString& wellName : rftReader->wellNames() ) + { + wellNames[wellName].push_back( "Summary" ); + } + } + } + const std::vector rftEnsembles = RimWellPlotTools::rftEnsembles(); // Ensemble RFT wells { @@ -1071,6 +1108,15 @@ std::map RimWellRftPlot::findWellSources() } } } + + const std::vector pressureDepthData = RimWellPlotTools::pressureDepthData(); + for ( const auto& pd : pressureDepthData ) + { + for ( const auto& wellName : pd->wellNames() ) + { + wellNames[wellName].push_back( "Observed" ); + } + } } return wellNames; } @@ -1106,8 +1152,8 @@ void RimWellRftPlot::onLoadDataAndUpdate() createEnsembleCurveSets(); updateEditorsFromCurves(); - // Update of curve color must happen here when loading data from project file, as the curve color is blended by the - // background color. The background color is taken from the viewer. + // Update of curve color must happen here when loading data from project file, as the curve color is blended by + // the background color. The background color is taken from the viewer. RimWellLogTrack* const plotTrack = dynamic_cast( plotByIndex( 0 ) ); if ( plotTrack && plotTrack->viewer() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.cpp b/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.cpp index 0f305d923f..05416202f3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.cpp @@ -37,7 +37,7 @@ RimPressureDepthData::RimPressureDepthData() CAF_PDM_InitFieldNoDefault( &m_wells, "Wells", "Wells" ); m_wells.xmlCapability()->disableIO(); m_wells.uiCapability()->setUiReadOnly( true ); - m_wells.registerGetMethod( this, &RimPressureDepthData::wells ); + m_wells.registerGetMethod( this, &RimPressureDepthData::wellNames ); } //-------------------------------------------------------------------------------------------------- @@ -75,7 +75,7 @@ RifReaderRftInterface* RimPressureDepthData::rftReader() //-------------------------------------------------------------------------------------------------- bool RimPressureDepthData::hasWell( const QString& wellPathName ) const { - std::vector allWells = wells(); + std::vector allWells = wellNames(); for ( const QString& well : allWells ) { if ( well == wellPathName ) @@ -89,24 +89,12 @@ bool RimPressureDepthData::hasWell( const QString& wellPathName ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimPressureDepthData::wells() const +std::vector RimPressureDepthData::wellNames() const { if ( m_fmuRftReader.p() ) { std::set wellNames = const_cast( m_fmuRftReader.p() )->wellNames(); return std::vector( wellNames.begin(), wellNames.end() ); } - return std::vector(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimPressureDepthData::labels( const RifEclipseRftAddress& rftAddress ) -{ - if ( m_fmuRftReader.p() ) - { - return const_cast( m_fmuRftReader.p() )->labels( rftAddress ); - } return {}; } diff --git a/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.h b/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.h index 665ff8aa43..34cd22c45a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.h +++ b/ApplicationLibCode/ProjectDataModel/RimPressureDepthData.h @@ -40,8 +40,7 @@ public: RifReaderRftInterface* rftReader(); bool hasWell( const QString& wellPathName ) const; - std::vector wells() const; - std::vector labels( const RifEclipseRftAddress& rftAddress ); + std::vector wellNames() const; private: cvf::ref m_fmuRftReader; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp index 25235b47f2..eccecf5749 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp @@ -196,9 +196,8 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) depthType = wellLogPlot->depthType(); } - m_plotCurve->setSamplesValues( this->curveData()->propertyValuesByIntervals(), - this->curveData()->depthValuesByIntervals( depthType, displayUnit ) ); - m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + setPropertyAndDepthValuesToPlotCurve( this->curveData()->propertyValuesByIntervals(), + this->curveData()->depthValuesByIntervals( depthType, displayUnit ) ); if ( updateParentPlot ) {