My Project
Loading...
Searching...
No Matches
Group.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 OPM_GROUP_HPP
21#define OPM_GROUP_HPP
22
23#include <opm/input/eclipse/EclipseState/Phase.hpp>
24#include <opm/input/eclipse/EclipseState/Util/IOrderSet.hpp>
25
26#include <opm/input/eclipse/Schedule/Group/GPMaint.hpp>
27
28#include <opm/input/eclipse/Deck/UDAValue.hpp>
29
30#include <opm/input/eclipse/Units/UnitSystem.hpp>
31
32#include <cstddef>
33#include <map>
34#include <optional>
35#include <string>
36
37namespace Opm {
38
39namespace RestartIO {
40struct RstGroup;
41}
42
43class SummaryState;
44class UDQConfig;
45class UDQActive;
46
47class Group {
48public:
49 // A group can have both injection controls and production controls set at
50 // the same time, i.e. this enum is used as a bitmask.
51 enum class GroupType : unsigned {
52 NONE = 0,
53 PRODUCTION = 1,
54 INJECTION = 2,
55 MIXED = 3
56 };
57
58 enum class ExceedAction {
59 NONE = 0,
60 CON = 1,
61 CON_PLUS = 2, // String: "+CON"
62 WELL = 3,
63 PLUG = 4,
64 RATE = 5
65 };
66 static const std::string ExceedAction2String( ExceedAction enumValue );
67 static ExceedAction ExceedActionFromString( const std::string& stringValue );
68 static ExceedAction ExceedActionFromInt(const int value);
69
70 enum class InjectionCMode : int {
71 NONE = 0,
72 RATE = 1,
73 RESV = 2,
74 REIN = 4,
75 VREP = 8,
76 FLD = 16,
77 SALE = 32
78 };
79 static const std::string InjectionCMode2String( InjectionCMode enumValue );
80 static InjectionCMode InjectionCModeFromString( const std::string& stringValue );
81 static InjectionCMode InjectionCModeFromInt(int ecl_int);
82 static int InjectionCMode2Int(InjectionCMode enumValue);
83
84 enum class ProductionCMode : int {
85 NONE = 0,
86 ORAT = 1,
87 WRAT = 2,
88 GRAT = 4,
89 LRAT = 8,
90 CRAT = 16,
91 RESV = 32,
92 PRBL = 64,
93 FLD = 128
94 };
95 static const std::string ProductionCMode2String( ProductionCMode enumValue );
96 static ProductionCMode ProductionCModeFromString( const std::string& stringValue );
97 static ProductionCMode ProductionCModeFromInt(int ecl_int);
98 static int ProductionCMode2Int(Group::ProductionCMode cmode);
99
100 enum class GuideRateProdTarget {
101 OIL = 0,
102 WAT = 1,
103 GAS = 2,
104 LIQ = 3,
105 RES = 4,
106 COMB = 5,
107 WGA = 6,
108 CVAL = 7,
109 INJV = 8,
110 POTN = 9,
111 FORM = 10,
112 NO_GUIDE_RATE = 11
113 };
114 static GuideRateProdTarget GuideRateProdTargetFromString( const std::string& stringValue );
115 static GuideRateProdTarget GuideRateProdTargetFromInt(int ecl_id);
116
117 enum class GuideRateInjTarget {
118 RATE = 1,
119 VOID = 2,
120 NETV = 3,
121 RESV = 4,
122 POTN = 5,
123 NO_GUIDE_RATE = 6
124 };
125 static GuideRateInjTarget GuideRateInjTargetFromString( const std::string& stringValue );
126 static GuideRateInjTarget GuideRateInjTargetFromInt(int ecl_id);
127 static int GuideRateInjTargetToInt(GuideRateInjTarget target);
128
130 {
131 GroupInjectionProperties() = default;
132 explicit GroupInjectionProperties(std::string group_name_arg);
133 GroupInjectionProperties(std::string group_name_arg, Phase phase, const UnitSystem& unit_system);
134
135 std::string name{};
136 Phase phase = Phase::WATER;
137 InjectionCMode cmode = InjectionCMode::NONE;
138 UDAValue surface_max_rate;
139 UDAValue resv_max_rate;
140 UDAValue target_reinj_fraction;
141 UDAValue target_void_fraction;
142 std::optional<std::string> reinj_group;
143 std::optional<std::string> voidage_group;
144 bool available_group_control = true;
145 double guide_rate = 0;
146 GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
147
148 static GroupInjectionProperties serializationTestObject();
149
150 int injection_controls = 0;
151 bool operator==(const GroupInjectionProperties& other) const;
152 bool operator!=(const GroupInjectionProperties& other) const;
153 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
154 bool uda_phase() const;
155 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
156
157 template<class Serializer>
158 void serializeOp(Serializer& serializer)
159 {
160 serializer(this->name);
161 serializer(phase);
162 serializer(cmode);
163 serializer(surface_max_rate);
164 serializer(resv_max_rate);
165 serializer(target_reinj_fraction);
166 serializer(target_void_fraction);
167 serializer(reinj_group);
168 serializer(voidage_group);
169 serializer(injection_controls);
170 serializer(available_group_control);
171 serializer(guide_rate);
172 serializer(guide_rate_def);
173 }
174 };
175
177 {
178 ExceedAction allRates{ExceedAction::NONE};
179 ExceedAction water{ExceedAction::NONE};
180 ExceedAction gas{ExceedAction::NONE};
181 ExceedAction liquid{ExceedAction::NONE};
182
183 template<class Serializer>
184 void serializeOp(Serializer& serializer)
185 {
186 serializer(allRates);
187 serializer(water);
188 serializer(gas);
189 serializer(liquid);
190 }
191
192 bool operator==(const GroupLimitAction& other) const
193 {
194 return (this->allRates == other.allRates)
195 && (this->water == other.water)
196 && (this->gas == other.gas)
197 && (this->liquid == other.liquid);
198 }
199 };
200
202 {
203 Phase phase;
204 InjectionCMode cmode;
205 double surface_max_rate;
206 double resv_max_rate;
207 double target_reinj_fraction;
208 double target_void_fraction;
209 int injection_controls = 0;
210 std::string reinj_group;
211 std::string voidage_group;
212 double guide_rate;
213 GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
214 };
215
217 {
219 GroupProductionProperties(const UnitSystem& unit_system, const std::string& gname);
220
221 std::string name;
222 ProductionCMode cmode = ProductionCMode::NONE;
223 GroupLimitAction group_limit_action;
224 UDAValue oil_target;
225 UDAValue water_target;
226 UDAValue gas_target;
227 UDAValue liquid_target;
228 double guide_rate = 0;
229 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
230 double resv_target = 0;
231 bool available_group_control = true;
232 static GroupProductionProperties serializationTestObject();
233
234 int production_controls = 0;
235 bool operator==(const GroupProductionProperties& other) const;
236 bool operator!=(const GroupProductionProperties& other) const;
237 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
238 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
239
240 template<class Serializer>
241 void serializeOp(Serializer& serializer)
242 {
243 serializer(name);
244 serializer(cmode);
245 serializer(group_limit_action);
246 serializer(oil_target);
247 serializer(water_target);
248 serializer(gas_target);
249 serializer(liquid_target);
250 serializer(guide_rate);
251 serializer(guide_rate_def);
252 serializer(resv_target);
253 serializer(available_group_control);
254 serializer(production_controls);
255 }
256 };
257
259 {
260 ProductionCMode cmode;
261 GroupLimitAction group_limit_action;
262 double oil_target;
263 double water_target;
264 double gas_target;
265 double liquid_target;
266 double guide_rate;
267 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
268 double resv_target = 0;
269 int production_controls = 0;
270 };
271
272 Group();
273 Group(const std::string& group_name, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
274 Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
275
276 static Group serializationTestObject();
277
278 std::size_t insert_index() const;
279 const std::string& name() const;
280 bool is_field() const;
281
282 bool update_gefac(double gefac, bool transfer_gefac);
283
284 // [[deprecated("use Group::control_group() or Group::flow_group()")]]
285 const std::string& parent() const;
286 std::optional<std::string> control_group() const;
287 std::optional<std::string> flow_group() const;
288
289 bool updateParent(const std::string& parent);
290 bool updateInjection(const GroupInjectionProperties& injection);
291 bool updateProduction(const GroupProductionProperties& production);
292 bool isProductionGroup() const;
293 bool isInjectionGroup() const;
294 void setProductionGroup();
295 void setInjectionGroup();
296 double getGroupEfficiencyFactor() const;
297 bool getTransferGroupEfficiencyFactor() const;
298
299 std::size_t numWells() const;
300 bool addGroup(const std::string& group_name);
301 bool hasGroup(const std::string& group_name) const;
302 void delGroup(const std::string& group_name);
303 bool addWell(const std::string& well_name);
304 bool hasWell(const std::string& well_name) const;
305 void delWell(const std::string& well_name);
306
307 const std::vector<std::string>& wells() const;
308 const std::vector<std::string>& groups() const;
309 bool wellgroup() const;
310 ProductionControls productionControls(const SummaryState& st) const;
311 InjectionControls injectionControls(Phase phase, const SummaryState& st) const;
312 bool hasInjectionControl(Phase phase) const;
313 const GroupProductionProperties& productionProperties() const;
314 const std::map<Phase , GroupInjectionProperties>& injectionProperties() const;
315 const GroupInjectionProperties& injectionProperties(Phase phase) const;
316 const GroupType& getGroupType() const;
317 ProductionCMode prod_cmode() const;
318 InjectionCMode injection_cmode() const;
319 Phase injection_phase() const;
320 bool has_control(ProductionCMode control) const;
321 bool has_control(Phase phase, InjectionCMode control) const;
322 bool productionGroupControlAvailable() const;
323 bool injectionGroupControlAvailable(const Phase phase) const;
324 const std::optional<GPMaint>& gpmaint() const;
325 void set_gpmaint(GPMaint gpmaint);
326 void set_gpmaint();
327 bool has_gpmaint_control(Phase phase, InjectionCMode cmode) const;
328 bool has_gpmaint_control(ProductionCMode cmode) const;
329
330 bool operator==(const Group& data) const;
331 const std::optional<Phase>& topup_phase() const;
332
333 template<class Serializer>
334 void serializeOp(Serializer& serializer)
335 {
336 serializer(m_name);
337 serializer(m_insert_index);
338 serializer(udq_undefined);
339 serializer(unit_system);
340 serializer(group_type);
341 serializer(gefac);
342 serializer(transfer_gefac);
343 serializer(parent_group);
344 serializer(m_wells);
345 serializer(m_groups);
346 serializer(injection_properties);
347 serializer(production_properties);
348 serializer(m_topup_phase);
349 serializer(m_gpmaint);
350 }
351
352private:
353 bool hasType(GroupType gtype) const;
354 void addType(GroupType new_gtype);
355
356 std::string m_name;
357 std::size_t m_insert_index;
358 double udq_undefined;
359 UnitSystem unit_system;
360 GroupType group_type;
361 double gefac;
362 bool transfer_gefac;
363
364 std::string parent_group;
366 IOrderSet<std::string> m_groups;
367
368 std::map<Phase, GroupInjectionProperties> injection_properties;
369 GroupProductionProperties production_properties;
370 std::optional<Phase> m_topup_phase;
371 std::optional<GPMaint> m_gpmaint;
372};
373
374Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs);
375Group::GroupType operator &(Group::GroupType lhs, Group::GroupType rhs);
376
377}
378
379#endif // OPM_GROUP_HPP
Definition GPMaint.hpp:31
Definition Group.hpp:47
Definition IOrderSet.hpp:48
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition SummaryState.hpp:68
Definition UDAValue.hpp:32
Definition UDQActive.hpp:43
Definition UDQConfig.hpp:63
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Group.hpp:130
Definition Group.hpp:177
Definition Group.hpp:202
Definition Group.hpp:259
Definition group.hpp:33