diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 7b56e8cab..b145793d4 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -528,7 +528,21 @@ namespace Opm return sum; } + /// Gets the total production flow of the given phase. + /// \param[in] phase_flows A vector containing rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] phase The phase for which to sum up. + double WellsGroup::getTotalProductionFlow(const std::vector& phase_flows, + const BlackoilPhases::PhaseIndex phase) + { + double sum = 0.0; + for (size_t i = 0; i < children_.size(); ++i) { + sum += children_[i]->getTotalProductionFlow(phase_flows, phase); + } + return sum; + } // ============== WellNode members ============ @@ -728,6 +742,25 @@ namespace Opm } + /// Gets the total production flow of the given phase. + /// \param[in] phase_flows A vector containing rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] phase The phase for which to sum up. + + double WellNode::getTotalProductionFlow(const std::vector& phase_flows, + const BlackoilPhases::PhaseIndex phase) + { + if (type() == INJECTOR) { + return 0.0; + } + return phase_flows[self_index_*phaseUsage().num_phases + phaseUsage().phase_pos[phase]]; + } + + WellType WellNode::type() const { + return wells_->type[self_index_]; + } + void WellNode::applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, const bool forced) diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index 6fe5508bc..d1b98aeda 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -179,6 +179,15 @@ namespace Opm /// wells under group control virtual double injectionGuideRate(bool only_group) = 0; + /// Gets the total production flow of the given phase. + /// \param[in] phase_flows A vector containing rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] phase The phase for which to sum up. + virtual double getTotalProductionFlow(const std::vector& phase_flows, + const BlackoilPhases::PhaseIndex phase) = 0; + + protected: /// Calculates the correct rate for the given ProductionSpecification::ControlMode double rateByMode(const double* res_rates, @@ -258,6 +267,14 @@ namespace Opm /// \param[in] only_group If true, will only accumelate guide rates for /// wells under group control virtual double injectionGuideRate(bool only_group); + + /// Gets the total production flow of the given phase. + /// \param[in] phase_flows A vector containing rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] phase The phase for which to sum up. + virtual double getTotalProductionFlow(const std::vector& phase_flows, + const BlackoilPhases::PhaseIndex phase); private: std::vector > children_; @@ -327,6 +344,17 @@ namespace Opm /// \param[in] only_group If true, will only accumelate guide rates for /// wells under group control virtual double injectionGuideRate(bool only_group); + + /// Gets the total production flow of the given phase. + /// \param[in] phase_flows A vector containing rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] phase The phase for which to sum up. + virtual double getTotalProductionFlow(const std::vector& phase_flows, + const BlackoilPhases::PhaseIndex phase); + + /// Returns the type of the well. + WellType type() const; private: Wells* wells_;