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 GROUP2_HPP
21#define GROUP2_HPP
22
23#include <algorithm>
24#include <map>
25#include <optional>
26#include <string>
27
28#include <opm/input/eclipse/Deck/UDAValue.hpp>
29#include <opm/input/eclipse/EclipseState/Util/IOrderSet.hpp>
30#include <opm/input/eclipse/EclipseState/Phase.hpp>
31#include <opm/input/eclipse/Schedule/Group/GPMaint.hpp>
32#include <opm/input/eclipse/Units/UnitSystem.hpp>
33
34namespace Opm {
35
36namespace RestartIO {
37struct RstGroup;
38}
39
40
41class SummaryState;
42class UDQConfig;
43class UDQActive;
44class Group {
45public:
46
47// A group can have both injection controls and production controls set at
48// the same time, i.e. this enum is used as a bitmask.
49enum class GroupType : unsigned {
50 NONE = 0,
51 PRODUCTION = 1,
52 INJECTION = 2,
53 MIXED = 3
54};
55
56
57
58enum class ExceedAction {
59 NONE = 0,
60 CON = 1,
61 CON_PLUS = 2, // String: "+CON"
62 WELL = 3,
63 PLUG = 4,
64 RATE = 5
65};
66static const std::string ExceedAction2String( ExceedAction enumValue );
67static ExceedAction ExceedActionFromString( const std::string& stringValue );
68static ExceedAction ExceedActionFromInt(const int value);
69
70enum 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};
79static const std::string InjectionCMode2String( InjectionCMode enumValue );
80static InjectionCMode InjectionCModeFromString( const std::string& stringValue );
81static InjectionCMode InjectionCModeFromInt(int ecl_int);
82static int InjectionCMode2Int(InjectionCMode enumValue);
83
84enum 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};
95static const std::string ProductionCMode2String( ProductionCMode enumValue );
96static ProductionCMode ProductionCModeFromString( const std::string& stringValue );
97static ProductionCMode ProductionCModeFromInt(int ecl_int);
98static int ProductionCMode2Int(Group::ProductionCMode cmode);
99
100enum 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};
114static GuideRateProdTarget GuideRateProdTargetFromString( const std::string& stringValue );
115static GuideRateProdTarget GuideRateProdTargetFromInt(int ecl_id);
116
117
118enum class GuideRateInjTarget {
119 RATE = 1,
120 VOID = 2,
121 NETV = 3,
122 RESV = 4,
123 POTN = 5,
124 NO_GUIDE_RATE = 6
125};
126static GuideRateInjTarget GuideRateInjTargetFromString( const std::string& stringValue );
127static GuideRateInjTarget GuideRateInjTargetFromInt(int ecl_id);
128static int GuideRateInjTargetToInt(GuideRateInjTarget target);
129
130
132 GroupInjectionProperties() = default;
133 explicit GroupInjectionProperties(std::string group_name_arg);
134 GroupInjectionProperties(std::string group_name_arg, Phase phase, const UnitSystem& unit_system);
135
136 std::string name{};
137 Phase phase = Phase::WATER;
138 InjectionCMode cmode = InjectionCMode::NONE;
139 UDAValue surface_max_rate;
140 UDAValue resv_max_rate;
141 UDAValue target_reinj_fraction;
142 UDAValue target_void_fraction;
143 std::optional<std::string> reinj_group;
144 std::optional<std::string> voidage_group;
145 bool available_group_control = true;
146 double guide_rate = 0;
147 GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
148
149 static GroupInjectionProperties serializationTestObject();
150
151 int injection_controls = 0;
152 bool operator==(const GroupInjectionProperties& other) const;
153 bool operator!=(const GroupInjectionProperties& other) const;
154 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
155 bool uda_phase() const;
156 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
157
158 template<class Serializer>
159 void serializeOp(Serializer& serializer)
160 {
161 serializer(this->name);
162 serializer(phase);
163 serializer(cmode);
164 serializer(surface_max_rate);
165 serializer(resv_max_rate);
166 serializer(target_reinj_fraction);
167 serializer(target_void_fraction);
168 serializer(reinj_group);
169 serializer(voidage_group);
170 serializer(injection_controls);
171 serializer(available_group_control);
172 serializer(guide_rate);
173 serializer(guide_rate_def);
174 }
175};
176
178{
179 ExceedAction allRates{ExceedAction::NONE};
180 ExceedAction water{ExceedAction::NONE};
181 ExceedAction gas{ExceedAction::NONE};
182 ExceedAction liquid{ExceedAction::NONE};
183
184 template<class Serializer>
185 void serializeOp(Serializer& serializer)
186 {
187 serializer(allRates);
188 serializer(water);
189 serializer(gas);
190 serializer(liquid);
191 }
192
193 bool operator==(const GroupLimitAction& other) const
194 {
195 return (this->allRates == other.allRates)
196 && (this->water == other.water)
197 && (this->gas == other.gas)
198 && (this->liquid == other.liquid);
199 }
200};
201
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
218 GroupProductionProperties(const UnitSystem& unit_system, const std::string& gname);
219
220 std::string name;
221 ProductionCMode cmode = ProductionCMode::NONE;
222 GroupLimitAction group_limit_action;
223 UDAValue oil_target;
224 UDAValue water_target;
225 UDAValue gas_target;
226 UDAValue liquid_target;
227 double guide_rate = 0;
228 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
229 double resv_target = 0;
230 bool available_group_control = true;
231 static GroupProductionProperties serializationTestObject();
232
233 int production_controls = 0;
234 bool operator==(const GroupProductionProperties& other) const;
235 bool operator!=(const GroupProductionProperties& other) const;
236 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
237 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
238
239 template<class Serializer>
240 void serializeOp(Serializer& serializer)
241 {
242 serializer(name);
243 serializer(cmode);
244 serializer(group_limit_action);
245 serializer(oil_target);
246 serializer(water_target);
247 serializer(gas_target);
248 serializer(liquid_target);
249 serializer(guide_rate);
250 serializer(guide_rate_def);
251 serializer(resv_target);
252 serializer(available_group_control);
253 serializer(production_controls);
254 }
255};
256
257
259 ProductionCMode cmode;
260 GroupLimitAction group_limit_action;
261 double oil_target;
262 double water_target;
263 double gas_target;
264 double liquid_target;
265 double guide_rate;
266 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
267 double resv_target = 0;
268 int production_controls = 0;
269};
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
Definition GPMaint.hpp:31
Definition Group.hpp:44
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:61
Definition UnitSystem.hpp:33
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Group.hpp:131
Definition Group.hpp:178
Definition Group.hpp:202
Definition Group.hpp:258
Definition group.hpp:33