TargetCalculator.hpp
Go to the documentation of this file.
1/*
2 Copyright 2020 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20
21#ifndef OPM_TARGETCALCULATOR_HEADER_INCLUDED
22#define OPM_TARGETCALCULATOR_HEADER_INCLUDED
23
24#include <opm/input/eclipse/Schedule/Group/Group.hpp>
25#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
26
27#include <optional>
28#include <string>
29#include <vector>
30
31namespace Opm {
32
33class DeferredLogger;
34template<class Scalar> class GroupState;
35struct PhaseUsage;
36
37namespace WGHelpers {
38
41template<class Scalar>
43{
44public:
45 TargetCalculator(const Group::ProductionCMode cmode,
46 const PhaseUsage& pu,
47 const std::vector<Scalar>& resv_coeff,
48 const Scalar group_grat_target_from_sales,
49 const std::string& group_name,
50 const GroupState<Scalar>& group_state,
51 const bool use_gpmaint);
52
53 template <typename RateType>
54 RateType calcModeRateFromRates(const std::vector<RateType>& rates) const
55 {
56 return calcModeRateFromRates(rates.data());
57 }
58
59 template <typename RateType>
60 RateType calcModeRateFromRates(const RateType* rates) const;
61
62 Scalar groupTarget(const std::optional<Group::ProductionControls>& ctrl,
63 DeferredLogger& deferred_logger) const;
64
65 GuideRateModel::Target guideTargetMode() const;
66
67private:
68 Group::ProductionCMode cmode_;
69 const PhaseUsage& pu_;
70 const std::vector<Scalar>& resv_coeff_;
71 const Scalar group_grat_target_from_sales_;
72 const std::string& group_name_;
73 const GroupState<Scalar>& group_state_;
74 bool use_gpmaint_;
75};
76
79template<class Scalar>
81{
82public:
83 InjectionTargetCalculator(const Group::InjectionCMode& cmode,
84 const PhaseUsage& pu,
85 const std::vector<Scalar>& resv_coeff,
86 const std::string& group_name,
87 const Scalar sales_target,
88 const GroupState<Scalar>& group_state,
89 const Phase& injection_phase,
90 const bool use_gpmaint,
91 DeferredLogger& deferred_logger);
92
93 template <typename RateVec>
94 auto calcModeRateFromRates(const RateVec& rates) const
95 {
96 return rates[pos_];
97 }
98
99 Scalar groupTarget(const std::optional<Group::InjectionControls>& ctrl,
100 DeferredLogger& deferred_logger) const;
101
102 GuideRateModel::Target guideTargetMode() const;
103
104private:
105 Group::InjectionCMode cmode_;
106 const PhaseUsage& pu_;
107 const std::vector<Scalar>& resv_coeff_;
108 const std::string& group_name_;
109 Scalar sales_target_;
110 const GroupState<Scalar>& group_state_;
111 bool use_gpmaint_;
112 int pos_;
113 GuideRateModel::Target target_;
114};
115
116} // namespace WGHelpers
117
118} // namespace Opm
119
120#endif
Definition: DeferredLogger.hpp:57
Definition: GroupState.hpp:35
Definition: TargetCalculator.hpp:81
InjectionTargetCalculator(const Group::InjectionCMode &cmode, const PhaseUsage &pu, const std::vector< Scalar > &resv_coeff, const std::string &group_name, const Scalar sales_target, const GroupState< Scalar > &group_state, const Phase &injection_phase, const bool use_gpmaint, DeferredLogger &deferred_logger)
GuideRateModel::Target guideTargetMode() const
Scalar groupTarget(const std::optional< Group::InjectionControls > &ctrl, DeferredLogger &deferred_logger) const
auto calcModeRateFromRates(const RateVec &rates) const
Definition: TargetCalculator.hpp:94
Definition: TargetCalculator.hpp:43
RateType calcModeRateFromRates(const RateType *rates) const
RateType calcModeRateFromRates(const std::vector< RateType > &rates) const
Definition: TargetCalculator.hpp:54
GuideRateModel::Target guideTargetMode() const
Scalar groupTarget(const std::optional< Group::ProductionControls > &ctrl, DeferredLogger &deferred_logger) const
TargetCalculator(const Group::ProductionCMode cmode, const PhaseUsage &pu, const std::vector< Scalar > &resv_coeff, const Scalar group_grat_target_from_sales, const std::string &group_name, const GroupState< Scalar > &group_state, const bool use_gpmaint)
Definition: BlackoilPhases.hpp:27
Definition: BlackoilPhases.hpp:46