From 911f260d0f9dac3a1c505c588a828d10dc988a59 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 21 Mar 2023 12:04:16 +0100 Subject: [PATCH] Improve robustness of well flow calculator --- .../ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp | 6 +++--- .../ProjectDataModel/Flow/RimWellAllocationPlot.cpp | 4 ++-- .../ProjectDataModel/Flow/RimWellConnectivityTable.cpp | 3 ++- .../ReservoirDataModel/RigAccWellFlowCalculator.cpp | 6 ++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp index ec9997d662..5a15734f4a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationOverTimePlot.cpp @@ -465,7 +465,7 @@ RigWellAllocationOverTime RimWellAllocationOverTimePlot::createWellAllocationOve const auto& [pipeBranchesCLCoords, pipeBranchesCellIds] = RigSimulationWellCenterLineCalculator::extractBranchData( simWellBranches ); - if ( tracerFractionCellValues.size() ) + if ( !tracerFractionCellValues.empty() && !pipeBranchesCLCoords.empty() ) { bool isProducer = ( simWellData->wellProductionType( i ) == RiaDefines::WellProductionType::PRODUCER || simWellData->wellProductionType( i ) == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE ); @@ -480,12 +480,12 @@ RigWellAllocationOverTime RimWellAllocationOverTimePlot::createWellAllocationOve isProducer ); timeStepAndCalculatorPairs.emplace( allTimeSteps[i], calculator ); } - else if ( pipeBranchesCLCoords.size() > 0 ) + else if ( !pipeBranchesCLCoords.empty() ) { const auto calculator = RigAccWellFlowCalculator( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold ); // NOTE: Would like to prevent this check. Is added due to calculator.tracerNames() gives // "oil", "water" and "gas" as return value when calculator.totalTracerFractions().size() = 0 - if ( calculator.totalTracerFractions().size() > 0 ) + if ( !calculator.totalTracerFractions().empty() ) { timeStepAndCalculatorPairs.emplace( allTimeSteps[i], calculator ); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index efc4d30e97..2df32ba5c4 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -261,7 +261,7 @@ void RimWellAllocationPlot::updateFromWell() double smallContributionThreshold = 0.0; if ( m_groupSmallContributions() ) smallContributionThreshold = m_smallContributionsThreshold; - if ( tracerFractionCellValues.size() ) + if ( !tracerFractionCellValues.empty() && !pipeBranchesCLCoords.empty() ) { bool isProducer = ( simWellData->wellProductionType( m_timeStep ) == RiaDefines::WellProductionType::PRODUCER || simWellData->wellProductionType( m_timeStep ) == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE ); @@ -277,7 +277,7 @@ void RimWellAllocationPlot::updateFromWell() } else { - if ( pipeBranchesCLCoords.size() > 0 ) + if ( !pipeBranchesCLCoords.empty() ) { wfCalculator.reset( new RigAccWellFlowCalculator( pipeBranchesCLCoords, pipeBranchesCellIds, smallContributionThreshold ) ); } diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp index 88b28ca7b3..f53f699f6a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellConnectivityTable.cpp @@ -1224,7 +1224,8 @@ void RimWellConnectivityTable::createAndEmplaceTimeStepAndCalculatorPairInMap( s std::map*> tracerFractionCellValues = RimWellAllocationTools::findOrCreateRelevantTracerCellFractions( simWellData, m_flowDiagSolution, timeStepIndex ); - if ( !tracerFractionCellValues.empty() ) + + if ( !tracerFractionCellValues.empty() && !pipeBranchesCLCoords.empty() ) { bool isProducer = ( simWellData->wellProductionType( timeStepIndex ) == RiaDefines::WellProductionType::PRODUCER || simWellData->wellProductionType( timeStepIndex ) == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp index 6844a8d147..70d7bcd8fb 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp @@ -80,6 +80,8 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator( const std::vector