opm-simulators
TargetCalculator.hpp
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 
26 #include <vector>
27 
28 namespace Opm {
29 
30 template<typename Scalar, typename IndexTraits> class GroupStateHelper;
31 
32 namespace GroupStateHelpers
33  {
34 
37 template<typename Scalar, typename IndexTraits>
39 {
40 public:
42 
43  TargetCalculator(const GroupStateHelperType& groupStateHelper,
44  const std::vector<Scalar>& resv_coeff,
45  const Group& group);
46 
49  TargetCalculator(const GroupStateHelperType& groupStateHelper,
50  const std::vector<Scalar>& resv_coeff,
51  Group::ProductionCMode cmode);
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 private:
63  Group::ProductionCMode cmode_;
64  const GroupStateHelperType& groupStateHelper_;
65  const std::vector<Scalar>& resv_coeff_;
66 };
67 
70 template<typename Scalar, typename IndexTraits>
72 {
73 public:
75 
76  InjectionTargetCalculator(const GroupStateHelperType& groupStateHelper,
77  const Phase& injection_phase);
78 
79  template <typename RateVec>
80  auto calcModeRateFromRates(const RateVec& rates) const
81  {
82  return rates[pos_];
83  }
84 
85 private:
86  int pos_;
87 };
88 
89 } // namespace GroupStateHelpers
90 
91 
92 } // namespace Opm
93 
94 #endif
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Definition: BlackoilWellModelConstraints.hpp:37
Based on a group control mode, extract or calculate rates, and provide other conveniences.
Definition: TargetCalculator.hpp:71
Based on a group control mode, extract or calculate rates, and provide other conveniences.
Definition: TargetCalculator.hpp:38