diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp index efda43826f..d2cdebec94 100644 --- a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.cpp @@ -72,6 +72,7 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto m_tracerNames.push_back(RIG_RESERVOIR_TRACER_NAME); + initializePipeBranchesMeasuredDepths(); calculateAccumulatedFlowPrConnection(0, 1); calculateFlowPrPseudoLength(0, 0.0); sortTracers(); @@ -102,7 +103,7 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto #else m_tracerNames.push_back(RIG_FLOW_TOTAL_NAME); #endif - + initializePipeBranchesMeasuredDepths(); calculateAccumulatedFlowPrConnection(0, 1); calculateFlowPrPseudoLength(0, 0.0); #ifdef USE_WELL_PHASE_RATES @@ -110,6 +111,54 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto #endif } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector& pipeBranchCLCoords, + const std::vector & pipeBranchCellIds, + const std::vector & pipeBranchMeasuredDepths, + double smallContribThreshold) + : m_tracerCellFractionValues(nullptr), + m_cellIndexCalculator(RigEclCellIndexCalculator(nullptr, nullptr)), + m_smallContributionsThreshold(smallContribThreshold), + m_isProducer(true) +{ + m_connectionFlowPrBranch.resize(m_pipeBranchesCellIds.size()); + m_pseudoLengthFlowPrBranch.resize(m_pipeBranchesCellIds.size()); + + m_pipeBranchesCLCoords.push_back(pipeBranchCLCoords); + m_pipeBranchesCellIds.push_back(pipeBranchCellIds); + m_pipeBranchesMeasuredDepths.push_back(pipeBranchMeasuredDepths); + + #ifdef USE_WELL_PHASE_RATES + m_tracerNames.push_back(RIG_FLOW_OIL_NAME); + m_tracerNames.push_back(RIG_FLOW_GAS_NAME); + m_tracerNames.push_back(RIG_FLOW_WATER_NAME); + #else + m_tracerNames.push_back(RIG_FLOW_TOTAL_NAME); + #endif + initializePipeBranchesMeasuredDepths(); + calculateAccumulatedFlowPrConnection(0, 1); + calculateFlowPrPseudoLength(0, 0.0); + #ifdef USE_WELL_PHASE_RATES + sortTracers(); + #endif +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigAccWellFlowCalculator::initializePipeBranchesMeasuredDepths() +{ + for (const auto & branchClPoints: m_pipeBranchesCLCoords) + { + RigSimulationWellCoordsAndMD mdCalculator(branchClPoints); + m_pipeBranchesMeasuredDepths.push_back(mdCalculator.measuredDepths()); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -401,8 +450,7 @@ void RigAccWellFlowCalculator::calculateFlowPrPseudoLength(size_t branchIdx, dou { const std::vector& branchCells = m_pipeBranchesCellIds[branchIdx]; const std::vector & branchClPoints = m_pipeBranchesCLCoords[branchIdx]; - - RigSimulationWellCoordsAndMD mdCalculator(branchClPoints); + const std::vector & branchMDs = m_pipeBranchesMeasuredDepths[branchIdx]; int clSegIdx = static_cast(branchCells.size()) - 1; @@ -432,8 +480,8 @@ void RigAccWellFlowCalculator::calculateFlowPrPseudoLength(size_t branchIdx, dou const RigWellResultPoint& wellCell = branchCells[currentSegmentIndex]; std::vector flowPrTracerToAccumulate = calculateWellCellFlowPrTracer( wellCell, accFlowPrTracer); - double pseudoLengthFromTop_lower = mdCalculator.measuredDepths()[cellBottomPointIndex] + startPseudoLengthFromTop; - double tvd_lower = -mdCalculator.wellPathPoints()[cellBottomPointIndex][2]; + double pseudoLengthFromTop_lower = branchMDs[cellBottomPointIndex] + startPseudoLengthFromTop; + double tvd_lower = -branchClPoints[cellBottomPointIndex][2]; // Push back the new start-of-cell flow, with the previously accumulated result into the storage @@ -455,8 +503,8 @@ void RigAccWellFlowCalculator::calculateFlowPrPseudoLength(size_t branchIdx, dou addDownStreamBranchFlow(&accFlowPrTracer, flowPrTracerToAccumulate); - double pseudoLengthFromTop_upper = mdCalculator.measuredDepths()[cellUpperPointIndex] + startPseudoLengthFromTop; - double tvd_upper = -mdCalculator.wellPathPoints()[cellUpperPointIndex][2]; + double pseudoLengthFromTop_upper = branchMDs[cellUpperPointIndex] + startPseudoLengthFromTop; + double tvd_upper = -branchClPoints[cellUpperPointIndex][2]; // Push back the accumulated result into the storage diff --git a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h index 4c2027cb71..4ac3879ba6 100644 --- a/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigAccWellFlowCalculator.h @@ -67,6 +67,11 @@ public: const std::vector< std::vector >& pipeBranchesCellIds, double smallContribThreshold); + RigAccWellFlowCalculator(const std::vector & pipeBranchCLCoords, + const std::vector & pipeBranchCellIds, + const std::vector & pipeBranchMeasuredDepths, + double smallContribThreshold); + const std::vector& connectionNumbersFromTop(size_t branchIdx) const; const std::vector& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx) const; const std::vector& tracerFlowPrConnection(const QString& tracerName, size_t branchIdx) const; @@ -82,6 +87,8 @@ public: std::vector > totalTracerFractions() const; private: + void initializePipeBranchesMeasuredDepths(); + bool isConnectionFlowConsistent(const RigWellResultPoint &wellCell) const; bool isFlowRateConsistent(double flowRate) const; @@ -107,8 +114,10 @@ private: std::vector > totalWellFlowPrTracer() const; - const std::vector< std::vector >& m_pipeBranchesCLCoords; - const std::vector< std::vector >& m_pipeBranchesCellIds; + std::vector< std::vector > m_pipeBranchesCLCoords; + std::vector< std::vector > m_pipeBranchesCellIds; + std::vector< std::vector > m_pipeBranchesMeasuredDepths; + const std::map* >* m_tracerCellFractionValues; RigEclCellIndexCalculator m_cellIndexCalculator; std::vector m_tracerNames;