My Project
GuideRateConfig.hpp
1/*
2 Copyright 2019 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#ifndef GUIDE_RATE_CONFIG_HPP
21#define GUIDE_RATE_CONFIG_HPP
22
23#include <optional>
24#include <string>
25#include <unordered_map>
26#include <utility>
27
28#include <opm/input/eclipse/Schedule/Group/GuideRateModel.hpp>
29#include <opm/input/eclipse/Schedule/Group/Group.hpp>
30#include <opm/input/eclipse/Schedule/Well/Well.hpp>
31
32namespace Opm {
33
34
36public:
37
38 struct WellTarget {
39 double guide_rate;
40 Well::GuideRateTarget target;
41 double scaling_factor;
42
43 bool operator==(const WellTarget& data) const {
44 return guide_rate == data.guide_rate &&
45 target == data.target &&
46 scaling_factor == data.scaling_factor;
47 }
48
49 template<class Serializer>
50 void serializeOp(Serializer& serializer)
51 {
52 serializer(guide_rate);
53 serializer(target);
54 serializer(scaling_factor);
55 }
56};
57
59 double guide_rate;
60 Group::GuideRateProdTarget target;
61
62 bool operator==(const GroupProdTarget& data) const {
63 return guide_rate == data.guide_rate &&
64 target == data.target;
65 }
66
67 template<class Serializer>
68 void serializeOp(Serializer& serializer)
69 {
70 serializer(guide_rate);
71 serializer(target);
72 }
73};
74
76 double guide_rate;
77 Group::GuideRateInjTarget target;
78
79 bool operator==(const GroupInjTarget& data) const {
80 return guide_rate == data.guide_rate &&
81 target == data.target;
82 }
83
84 template<class Serializer>
85 void serializeOp(Serializer& serializer)
86 {
87 serializer(guide_rate);
88 serializer(target);
89 }
90};
91
92 static GuideRateConfig serializationTestObject();
93
94 const GuideRateModel& model() const;
95 bool has_model() const;
96 bool update_model(const GuideRateModel& model);
97 void update_well(const Well& well);
98 void update_injection_group(const std::string& group_name, const Group::GroupInjectionProperties& properties);
99 void update_production_group(const Group& group);
100 const WellTarget& well(const std::string& well) const;
101 const GroupProdTarget& production_group(const std::string& group) const;
102 const GroupInjTarget& injection_group(const Phase& phase, const std::string& group) const;
103
104 bool has_well(const std::string& well) const;
105 bool has_injection_group(const Phase& phase, const std::string& group) const;
106 bool has_production_group(const std::string& group) const;
107
108 bool operator==(const GuideRateConfig& data) const;
109
110 template<class Serializer>
111 void serializeOp(Serializer& serializer)
112 {
113 serializer(m_model);
114 serializer(wells);
115 serializer(production_groups);
116 serializer(injection_groups);
117 }
118
119private:
120
121 typedef std::pair<Phase,std::string> pair;
122
123 struct pair_hash
124 {
125 template <class T1, class T2>
126 std::size_t operator() (const std::pair<T1, T2> &pair) const
127 {
128 return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
129 }
130 };
131
132 std::optional<GuideRateModel> m_model;
133 std::unordered_map<std::string, WellTarget> wells;
134 std::unordered_map<std::string, GroupProdTarget> production_groups;
135 std::unordered_map<pair, GroupInjTarget, pair_hash> injection_groups;
136
137};
138
139}
140
141#endif
Definition: Group.hpp:44
Definition: GuideRateConfig.hpp:35
Definition: GuideRateModel.hpp:29
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: Well.hpp:78
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: Group.hpp:131
Definition: GuideRateConfig.hpp:75
Definition: GuideRateConfig.hpp:58
Definition: GuideRateConfig.hpp:38