///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include #include //================================================================================================== /// /// //================================================================================================== class RigMainGrid; class RigActiveCellInfo; class RigEclCellIndexCalculator { public: RigEclCellIndexCalculator(const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo) : m_mainGrid(mainGrid), m_activeCellInfo(activeCellInfo) {} size_t resultCellIndex(size_t gridIndex, size_t gridCellIndex) const; private: const RigMainGrid* m_mainGrid; const RigActiveCellInfo* m_activeCellInfo; }; //================================================================================================== /// /// //================================================================================================== #include #include "cvfBase.h" #include "cvfVector3.h" struct RigWellResultPoint; class RigAccWellFlowCalculator { public: RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, const std::vector< std::vector >& pipeBranchesCellIds, const std::map* >& tracerCellFractionValues, const RigEclCellIndexCalculator& cellIndexCalculator, double smallContribThreshold, bool isProducer); RigAccWellFlowCalculator(const std::vector< std::vector >& pipeBranchesCLCoords, const std::vector< std::vector >& pipeBranchesCellIds, 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; const std::vector& pseudoLengthFromTop(size_t branchIdx) const; const std::vector& trueVerticalDepth(size_t branchIdx) const; const std::vector& accumulatedTracerFlowPrPseudoLength(const QString& tracerName, size_t branchIdx) const; const std::vector& tracerFlowPrPseudoLength(const QString& tracerName, size_t branchIdx) const; const std::vector& tracerNames() const { return m_tracerNames;} std::vector > totalTracerFractions() const; private: bool isConnectionFlowConsistent(const RigWellResultPoint &wellCell) const; bool isFlowRateConsistent(double flowRate) const; void calculateAccumulatedFlowPrConnection(size_t branchIdx, size_t startConnectionNumberFromTop); void calculateFlowPrPseudoLength(size_t branchIdx, double startPseudoLengthFromTop); std::vector calculateWellCellFlowPrTracer(const RigWellResultPoint& wellCell, const std::vector& currentAccumulatedFlowPrTracer ) const; void sortTracers(); void groupSmallContributions(); void groupSmallTracers(std::map >* branchFlowSet, const std::vector& tracersToGroup); bool isWellFlowConsistent() const; std::vector calculateAccumulatedFractions(const std::vector& accumulatedFlowPrTracer) const; std::vector wrpToUniqueWrpIndexFromBottom(const std::vector &branchCells) const; static size_t connectionIndexFromTop( const std::vector& resPointToConnectionIndexFromBottom, size_t clSegIdx) ; std::vector findDownStreamBranchIdxs( const RigWellResultPoint& connectionPoint) const; std::vector > totalWellFlowPrTracer() const; const std::vector< std::vector >& m_pipeBranchesCLCoords; const std::vector< std::vector >& m_pipeBranchesCellIds; const std::map* >* m_tracerCellFractionValues; RigEclCellIndexCalculator m_cellIndexCalculator; std::vector m_tracerNames; double m_smallContributionsThreshold; bool m_isProducer; struct BranchFlow { std::vector depthValuesFromTop; std::vector trueVerticalDepth; std::map > accFlowPrTracer; std::map > flowPrTracer; }; void storeFlowOnDepth(BranchFlow *branchFlow, double depthValue, const std::vector& accFlowPrTracer, const std::vector& flowPrTracer); void storeFlowOnDepthWTvd(BranchFlow *branchFlow, double depthValue, double trueVerticalDepth, const std::vector& accFlowPrTracer, const std::vector& flowPrTracer); std::vector accumulatedDsBranchFlowPrTracer(const BranchFlow &downStreamBranchFlow) const; void addDownStreamBranchFlow(std::vector *accFlowPrTracer, const std::vector& accBranchFlowPrTracer) const; std::vector< BranchFlow > m_connectionFlowPrBranch; std::vector< BranchFlow > m_pseudoLengthFlowPrBranch; };