My Project
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/Runspec.hpp>
31 #include <opm/input/eclipse/Schedule/Group/GPMaint.hpp>
32 #include <opm/input/eclipse/Units/UnitSystem.hpp>
33 
34 namespace Opm {
35 
36 namespace RestartIO {
37 struct RstGroup;
38 }
39 
40 
41 class SummaryState;
42 class UDQConfig;
43 class UDQActive;
44 class Group {
45 public:
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.
49 enum class GroupType : unsigned {
50  NONE = 0,
51  PRODUCTION = 1,
52  INJECTION = 2,
53  MIXED = 3
54 };
55 
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 
118 enum class GuideRateInjTarget {
119  RATE = 1,
120  VOID = 2,
121  NETV = 3,
122  RESV = 4,
123  POTN = 5,
124  NO_GUIDE_RATE = 6
125 };
126 static GuideRateInjTarget GuideRateInjTargetFromString( const std::string& stringValue );
127 static GuideRateInjTarget GuideRateInjTargetFromInt(int ecl_id);
128 static 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  Phase phase;
179  InjectionCMode cmode;
180  double surface_max_rate;
181  double resv_max_rate;
182  double target_reinj_fraction;
183  double target_void_fraction;
184  int injection_controls = 0;
185  std::string reinj_group;
186  std::string voidage_group;
187  double guide_rate;
188  GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
189 };
190 
193  GroupProductionProperties(const UnitSystem& unit_system, const std::string& gname);
194 
195  std::string name;
196  ProductionCMode cmode = ProductionCMode::NONE;
197  ExceedAction exceed_action = ExceedAction::NONE;
198  UDAValue oil_target;
199  UDAValue water_target;
200  UDAValue gas_target;
201  UDAValue liquid_target;
202  double guide_rate = 0;
203  GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
204  double resv_target = 0;
205  bool available_group_control = true;
206  static GroupProductionProperties serializationTestObject();
207 
208  int production_controls = 0;
209  bool operator==(const GroupProductionProperties& other) const;
210  bool operator!=(const GroupProductionProperties& other) const;
211  bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
212  void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
213 
214  template<class Serializer>
215  void serializeOp(Serializer& serializer)
216  {
217  serializer(name);
218  serializer(cmode);
219  serializer(exceed_action);
220  serializer(oil_target);
221  serializer(water_target);
222  serializer(gas_target);
223  serializer(liquid_target);
224  serializer(guide_rate);
225  serializer(guide_rate_def);
226  serializer(resv_target);
227  serializer(available_group_control);
228  serializer(production_controls);
229  }
230 };
231 
232 
234  ProductionCMode cmode;
235  ExceedAction exceed_action;
236  double oil_target;
237  double water_target;
238  double gas_target;
239  double liquid_target;
240  double guide_rate;
241  GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
242  double resv_target = 0;
243  int production_controls = 0;
244 };
245 
246 
247  Group();
248  Group(const std::string& group_name, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
249  Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
250 
251  static Group serializationTestObject();
252 
253  std::size_t insert_index() const;
254  const std::string& name() const;
255  bool is_field() const;
256  int getGroupNetVFPTable() const;
257 
258  bool updateNetVFPTable(int vfp_arg);
259  bool update_gefac(double gefac, bool transfer_gefac);
260 
261  // [[deprecated("use Group::control_group() or Group::flow_group()")]]
262  const std::string& parent() const;
263  std::optional<std::string> control_group() const;
264  std::optional<std::string> flow_group() const;
265 
266  bool updateParent(const std::string& parent);
267  bool updateInjection(const GroupInjectionProperties& injection);
268  bool updateProduction(const GroupProductionProperties& production);
269  bool isProductionGroup() const;
270  bool isInjectionGroup() const;
271  void setProductionGroup();
272  void setInjectionGroup();
273  double getGroupEfficiencyFactor() const;
274  bool getTransferGroupEfficiencyFactor() const;
275 
276  std::size_t numWells() const;
277  bool addGroup(const std::string& group_name);
278  bool hasGroup(const std::string& group_name) const;
279  void delGroup(const std::string& group_name);
280  bool addWell(const std::string& well_name);
281  bool hasWell(const std::string& well_name) const;
282  void delWell(const std::string& well_name);
283 
284  const std::vector<std::string>& wells() const;
285  const std::vector<std::string>& groups() const;
286  bool wellgroup() const;
287  ProductionControls productionControls(const SummaryState& st) const;
288  InjectionControls injectionControls(Phase phase, const SummaryState& st) const;
289  bool hasInjectionControl(Phase phase) const;
290  const GroupProductionProperties& productionProperties() const;
291  const std::map<Phase , GroupInjectionProperties>& injectionProperties() const;
292  const GroupInjectionProperties& injectionProperties(Phase phase) const;
293  const GroupType& getGroupType() const;
294  ProductionCMode prod_cmode() const;
295  InjectionCMode injection_cmode() const;
296  Phase injection_phase() const;
297  bool has_control(ProductionCMode control) const;
298  bool has_control(Phase phase, InjectionCMode control) const;
299  bool productionGroupControlAvailable() const;
300  bool injectionGroupControlAvailable(const Phase phase) const;
301  const std::optional<GPMaint>& gpmaint() const;
302  void set_gpmaint(GPMaint gpmaint);
303  void set_gpmaint();
304  bool has_gpmaint_control(Phase phase, InjectionCMode cmode) const;
305  bool has_gpmaint_control(ProductionCMode cmode) const;
306 
307  bool operator==(const Group& data) const;
308  const std::optional<Phase>& topup_phase() const;
309 
310  template<class Serializer>
311  void serializeOp(Serializer& serializer)
312  {
313  serializer(m_name);
314  serializer(m_insert_index);
315  serializer(udq_undefined);
316  serializer(unit_system);
317  serializer(group_type);
318  serializer(gefac);
319  serializer(transfer_gefac);
320  serializer(vfp_table);
321  serializer(parent_group);
322  serializer(m_wells);
323  serializer(m_groups);
324  serializer(injection_properties);
325  serializer(production_properties);
326  serializer(m_topup_phase);
327  serializer(m_gpmaint);
328  }
329 
330 private:
331  bool hasType(GroupType gtype) const;
332  void addType(GroupType new_gtype);
333 
334  std::string m_name;
335  std::size_t m_insert_index;
336  double udq_undefined;
337  UnitSystem unit_system;
338  GroupType group_type;
339  double gefac;
340  bool transfer_gefac;
341  int vfp_table;
342 
343  std::string parent_group;
344  IOrderSet<std::string> m_wells;
345  IOrderSet<std::string> m_groups;
346 
347  std::map<Phase, GroupInjectionProperties> injection_properties;
348  GroupProductionProperties production_properties;
349  std::optional<Phase> m_topup_phase;
350  std::optional<GPMaint> m_gpmaint;
351 };
352 
353 Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs);
354 Group::GroupType operator &(Group::GroupType lhs, Group::GroupType rhs);
355 
356 }
357 
358 #endif
Definition: GPMaint.hpp:30
Definition: Group.hpp:44
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: SummaryState.hpp:69
Definition: UDAValue.hpp:32
Definition: UDQActive.hpp:43
Definition: UDQConfig.hpp:51
Definition: UnitSystem.hpp:33
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: Group.hpp:131
Definition: Group.hpp:191
Definition: Group.hpp:177
Definition: Group.hpp:233
Definition: group.hpp:33