My Project
Runspec.hpp
1 /*
2  Copyright 2016 Statoil 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 it under the terms
7  of the GNU General Public License as published by the Free Software
8  Foundation, either version 3 of the License, or (at your option) any later
9  version.
10 
11  OPM is distributed in the hope that it will be useful, but WITHOUT ANY
12  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along with
16  OPM. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef OPM_RUNSPEC_HPP
20 #define OPM_RUNSPEC_HPP
21 
22 #include <iosfwd>
23 #include <string>
24 #include <optional>
25 
26 #include <opm/common/OpmLog/KeywordLocation.hpp>
27 #include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp>
28 #include <opm/parser/eclipse/EclipseState/Tables/Regdims.hpp>
29 #include <opm/parser/eclipse/EclipseState/EndpointScaling.hpp>
30 #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp>
31 #include <opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.hpp>
32 
33 namespace Opm {
34 class Deck;
35 
36 
37 enum class Phase {
38  OIL = 0,
39  GAS = 1,
40  WATER = 2,
41  SOLVENT = 3,
42  POLYMER = 4,
43  ENERGY = 5,
44  POLYMW = 6,
45  FOAM = 7,
46  BRINE = 8,
47  ZFRACTION = 9
48 
49  // If you add more entries to this enum, remember to update NUM_PHASES_IN_ENUM below.
50 };
51 
52 constexpr int NUM_PHASES_IN_ENUM = static_cast<int>(Phase::ZFRACTION) + 1; // Used to get correct size of the bitset in class Phases.
53 
54 Phase get_phase( const std::string& );
55 std::ostream& operator<<( std::ostream&, const Phase& );
56 
57 class Phases {
58  public:
59  Phases() noexcept = default;
60  Phases( bool oil, bool gas, bool wat, bool solvent = false, bool polymer = false, bool energy = false,
61  bool polymw = false, bool foam = false, bool brine = false, bool zfraction = false ) noexcept;
62 
63  static Phases serializeObject();
64 
65  bool active( Phase ) const noexcept;
66  size_t size() const noexcept;
67 
68  bool operator==(const Phases& data) const;
69 
70  template<class Serializer>
71  void serializeOp(Serializer& serializer)
72  {
73  if (serializer.isSerializing())
74  serializer(bits.to_ulong());
75  else {
76  unsigned long Bits = 0;
77  serializer(Bits);
78  bits = std::bitset<NUM_PHASES_IN_ENUM>(Bits);
79  }
80  }
81 
82  private:
83  std::bitset< NUM_PHASES_IN_ENUM > bits;
84 };
85 
86 
87 class Welldims {
88 public:
89  Welldims() = default;
90  explicit Welldims(const Deck& deck);
91 
92  static Welldims serializeObject();
93 
94  int maxConnPerWell() const
95  {
96  return this->nCWMax;
97  }
98 
99  int maxWellsPerGroup() const
100  {
101  return this->nWGMax;
102  }
103 
104  int maxGroupsInField() const
105  {
106  return this->nGMax;
107  }
108 
109  int maxWellsInField() const
110  {
111  return this->nWMax;
112  }
113 
114  int maxWellListsPrWell() const
115  {
116  return this->nWlistPrWellMax;
117  }
118 
119  int maxDynamicWellLists() const
120  {
121  return this->nDynWlistMax;
122  }
123 
124  const std::optional<KeywordLocation>& location() const {
125  return this->m_location;
126  }
127 
128  static bool rst_cmp(const Welldims& full_dims, const Welldims& rst_dims) {
129  return full_dims.maxConnPerWell() == rst_dims.maxConnPerWell() &&
130  full_dims.maxWellsPerGroup() == rst_dims.maxWellsPerGroup() &&
131  full_dims.maxGroupsInField() == rst_dims.maxGroupsInField() &&
132  full_dims.maxWellsInField() == rst_dims.maxWellsInField() &&
133  full_dims.maxWellListsPrWell() == rst_dims.maxWellListsPrWell() &&
134  full_dims.maxDynamicWellLists() == rst_dims.maxDynamicWellLists();
135  }
136 
137  bool operator==(const Welldims& data) const {
138  return this->location() == data.location() &&
139  rst_cmp(*this, data);
140  }
141 
142 
143  template<class Serializer>
144  void serializeOp(Serializer& serializer)
145  {
146  serializer(nWMax);
147  serializer(nCWMax);
148  serializer(nWGMax);
149  serializer(nGMax);
150  serializer(nWlistPrWellMax);
151  serializer(nDynWlistMax);
152  serializer(m_location);
153  }
154 
155 private:
156  int nWMax { 0 };
157  int nCWMax { 0 };
158  int nWGMax { 0 };
159  int nGMax { 0 };
160  int nWlistPrWellMax { 1 };
161  int nDynWlistMax { 1 };
162  std::optional<KeywordLocation> m_location;
163 };
164 
166 public:
167  WellSegmentDims();
168  explicit WellSegmentDims(const Deck& deck);
169 
170  static WellSegmentDims serializeObject();
171 
172 
173  int maxSegmentedWells() const
174  {
175  return this->nSegWellMax;
176  }
177 
178  int maxSegmentsPerWell() const
179  {
180  return this->nSegmentMax;
181  }
182 
183  int maxLateralBranchesPerWell() const
184  {
185  return this->nLatBranchMax;
186  }
187 
188  bool operator==(const WellSegmentDims& data) const;
189 
190  template<class Serializer>
191  void serializeOp(Serializer& serializer)
192  {
193  serializer(nSegWellMax);
194  serializer(nSegmentMax);
195  serializer(nLatBranchMax);
196  }
197 
198 private:
199  int nSegWellMax;
200  int nSegmentMax;
201  int nLatBranchMax;
202 };
203 
204 class NetworkDims {
205 public:
206  NetworkDims();
207  explicit NetworkDims(const Deck& deck);
208 
209  static NetworkDims serializeObject();
210 
211  int maxNONodes() const
212  {
213  return this->nMaxNoNodes;
214  }
215 
216  int maxNoBranches() const
217  {
218  return this->nMaxNoBranches;
219  }
220 
221  int maxNoBranchesConToNode() const
222  {
223  return this->nMaxNoBranchesConToNode;
224  }
225 
226  bool operator==(const NetworkDims& data) const;
227 
228  template<class Serializer>
229  void serializeOp(Serializer& serializer)
230  {
231  serializer(nMaxNoNodes);
232  serializer(nMaxNoBranches);
233  serializer(nMaxNoBranchesConToNode);
234  }
235 
236 private:
237  int nMaxNoNodes;
238  int nMaxNoBranches;
239  int nMaxNoBranchesConToNode;
240 };
241 
243 public:
245  explicit AquiferDimensions(const Deck& deck);
246 
247  static AquiferDimensions serializeObject();
248 
249  int maxAnalyticAquifers() const
250  {
251  return this->maxNumAnalyticAquifers;
252  }
253 
254  int maxAnalyticAquiferConnections() const
255  {
256  return this->maxNumAnalyticAquiferConn;
257  }
258 
259  template <class Serializer>
260  void serializeOp(Serializer& serializer)
261  {
262  serializer(this->maxNumAnalyticAquifers);
263  serializer(this->maxNumAnalyticAquiferConn);
264  }
265 
266 private:
267  int maxNumAnalyticAquifers;
268  int maxNumAnalyticAquiferConn;
269 };
270 
271 bool operator==(const AquiferDimensions& lhs, const AquiferDimensions& rhs);
272 
274 {
275 public:
276  EclHysterConfig() = default;
277  explicit EclHysterConfig(const Deck& deck);
278 
279  static EclHysterConfig serializeObject();
280 
284  //void setActive(bool yesno);
285 
289  bool active() const;
290 
297  int pcHysteresisModel() const;
298 
305  int krHysteresisModel() const;
306 
307  bool operator==(const EclHysterConfig& data) const;
308 
309  template<class Serializer>
310  void serializeOp(Serializer& serializer)
311  {
312  serializer(activeHyst);
313  serializer(pcHystMod);
314  serializer(krHystMod);
315  }
316 
317 private:
318  // enable hysteresis at all
319  bool activeHyst { false };
320 
321  // the capillary pressure and the relperm hysteresis models to be used
322  int pcHystMod { 0 };
323  int krHystMod { 0 };
324 };
325 
327 public:
328  enum class ThreePhaseOilKrModel {
329  Default,
330  Stone1,
331  Stone2
332  };
333 
334  enum class KeywordFamily {
335  Family_I, // SGOF, SWOF, SLGOF
336  Family_II, // SGFN, SOF{2,3}, SWFN
337  Undefined,
338  };
339 
340  SatFuncControls();
341  explicit SatFuncControls(const Deck& deck);
342  explicit SatFuncControls(const double tolcritArg,
343  const ThreePhaseOilKrModel model,
344  const KeywordFamily family);
345 
346  static SatFuncControls serializeObject();
347 
348  double minimumRelpermMobilityThreshold() const
349  {
350  return this->tolcrit;
351  }
352 
353  ThreePhaseOilKrModel krModel() const
354  {
355  return this->krmodel;
356  }
357 
358  KeywordFamily family() const
359  {
360  return this->satfunc_family;
361  }
362 
363  bool operator==(const SatFuncControls& rhs) const;
364 
365  template<class Serializer>
366  void serializeOp(Serializer& serializer)
367  {
368  serializer(tolcrit);
369  serializer(krmodel);
370  serializer(satfunc_family);
371  }
372 
373 private:
374  double tolcrit;
375  ThreePhaseOilKrModel krmodel = ThreePhaseOilKrModel::Default;
376  KeywordFamily satfunc_family = KeywordFamily::Undefined;
377 };
378 
379 
380 class Nupcol {
381 public:
382  Nupcol();
383  explicit Nupcol(int min_value);
384  void update(int value);
385  int value() const;
386 
387  static Nupcol serializeObject();
388  bool operator==(const Nupcol& data) const;
389 
390  template<class Serializer>
391  void serializeOp(Serializer& serializer) {
392  serializer(this->nupcol_value);
393  serializer(this->min_nupcol);
394  }
395 
396 private:
397  int min_nupcol;
398  int nupcol_value;
399 };
400 
401 
402 class Runspec {
403 public:
404  Runspec() = default;
405  explicit Runspec( const Deck& );
406 
407  static Runspec serializeObject();
408 
409  std::time_t start_time() const noexcept;
410  const UDQParams& udqParams() const noexcept;
411  const Phases& phases() const noexcept;
412  const Tabdims& tabdims() const noexcept;
413  const Regdims& regdims() const noexcept;
414  const EndpointScaling& endpointScaling() const noexcept;
415  const Welldims& wellDimensions() const noexcept;
416  const WellSegmentDims& wellSegmentDimensions() const noexcept;
417  const NetworkDims& networkDimensions() const noexcept;
418  const AquiferDimensions& aquiferDimensions() const noexcept;
419  int eclPhaseMask( ) const noexcept;
420  const EclHysterConfig& hysterPar() const noexcept;
421  const Actdims& actdims() const noexcept;
422  const SatFuncControls& saturationFunctionControls() const noexcept;
423  const Nupcol& nupcol() const noexcept;
424  bool co2Storage() const noexcept;
425  bool micp() const noexcept;
426 
427  bool operator==(const Runspec& data) const;
428  static bool rst_cmp(const Runspec& full_state, const Runspec& rst_state);
429 
430  template<class Serializer>
431  void serializeOp(Serializer& serializer)
432  {
433  serializer(this->m_start_time);
434  active_phases.serializeOp(serializer);
435  m_tabdims.serializeOp(serializer);
436  m_regdims.serializeOp(serializer);
437  endscale.serializeOp(serializer);
438  welldims.serializeOp(serializer);
439  wsegdims.serializeOp(serializer);
440  netwrkdims.serializeOp(serializer);
441  aquiferdims.serializeOp(serializer);
442  udq_params.serializeOp(serializer);
443  hystpar.serializeOp(serializer);
444  m_actdims.serializeOp(serializer);
445  m_sfuncctrl.serializeOp(serializer);
446  m_nupcol.serializeOp(serializer);
447  serializer(m_co2storage);
448  serializer(m_micp);
449  }
450 
451 private:
452  std::time_t m_start_time;
453  Phases active_phases;
454  Tabdims m_tabdims;
455  Regdims m_regdims;
456  EndpointScaling endscale;
457  Welldims welldims;
458  WellSegmentDims wsegdims;
459  NetworkDims netwrkdims;
460  AquiferDimensions aquiferdims;
461  UDQParams udq_params;
462  EclHysterConfig hystpar;
463  Actdims m_actdims;
464  SatFuncControls m_sfuncctrl;
465  Nupcol m_nupcol;
466  bool m_co2storage;
467  bool m_micp;
468 };
469 
470 
471 }
472 
473 #endif // OPM_RUNSPEC_HPP
Definition: Actdims.hpp:30
Definition: Runspec.hpp:242
Definition: Deck.hpp:119
Definition: Runspec.hpp:274
int pcHysteresisModel() const
Return the type of the hysteresis model which is used for capillary pressure.
bool active() const
Specify whether hysteresis is enabled or not.
int krHysteresisModel() const
Return the type of the hysteresis model which is used for relative permeability.
Definition: EndpointScaling.hpp:28
Definition: Runspec.hpp:204
Definition: Runspec.hpp:380
Definition: Runspec.hpp:57
Definition: Regdims.hpp:36
Definition: Runspec.hpp:402
Definition: Runspec.hpp:326
Definition: Serializer.hpp:38
Definition: Tabdims.hpp:36
Definition: UDQParams.hpp:31
Definition: Runspec.hpp:165
Definition: Runspec.hpp:87
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29