opm-common
Loading...
Searching...
No Matches
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 <opm/common/OpmLog/KeywordLocation.hpp>
23
24#include <opm/input/eclipse/EclipseState/EndpointScaling.hpp>
25#include <opm/input/eclipse/EclipseState/Phase.hpp>
26#include <opm/input/eclipse/EclipseState/Tables/Regdims.hpp>
27#include <opm/input/eclipse/EclipseState/Tables/Tabdims.hpp>
28
29#include <opm/input/eclipse/Schedule/Action/Actdims.hpp>
30#include <opm/input/eclipse/Schedule/UDQ/UDQParams.hpp>
31
32#include <bitset>
33#include <cstddef>
34#include <ctime>
35#include <optional>
36
37namespace Opm {
38
39 class Deck;
40
41} // namespace Opm
42
43namespace Opm {
44
45class Phases
46{
47public:
48 Phases() noexcept = default;
49 Phases(bool oil, bool gas, bool wat,
50 bool solvent = false,
51 bool polymer = false,
52 bool energy = false,
53 bool polymw = false,
54 bool foam = false,
55 bool brine = false,
56 bool zfraction = false) noexcept;
57
58 static Phases serializationTestObject();
59
60 bool active( Phase ) const noexcept;
61 size_t size() const noexcept;
62
63 bool operator==(const Phases& data) const;
64
65 template<class Serializer>
66 void serializeOp(Serializer& serializer)
67 {
68 serializer(bits);
69 }
70
71private:
72 std::bitset<NUM_PHASES_IN_ENUM> bits;
73};
74
75class Welldims {
76public:
77 Welldims() = default;
78 explicit Welldims(const Deck& deck);
79
80 static Welldims serializationTestObject();
81
82 int maxConnPerWell() const
83 {
84 return this->nCWMax;
85 }
86
87 int maxWellsPerGroup() const
88 {
89 return this->nWGMax;
90 }
91
92 int maxGroupsInField() const
93 {
94 return this->nGMax;
95 }
96
97 int maxWellsInField() const
98 {
99 return this->nWMax;
100 }
101
102 int maxWellListsPrWell() const
103 {
104 return this->nWlistPrWellMax;
105 }
106
107 int maxDynamicWellLists() const
108 {
109 return this->nDynWlistMax;
110 }
111
112 const std::optional<KeywordLocation>& location() const
113 {
114 return this->m_location;
115 }
116
117 static bool rst_cmp(const Welldims& full_dims, const Welldims& rst_dims) {
118 return full_dims.maxConnPerWell() == rst_dims.maxConnPerWell() &&
119 full_dims.maxWellsPerGroup() == rst_dims.maxWellsPerGroup() &&
120 full_dims.maxGroupsInField() == rst_dims.maxGroupsInField() &&
121 full_dims.maxWellsInField() == rst_dims.maxWellsInField() &&
122 full_dims.maxWellListsPrWell() == rst_dims.maxWellListsPrWell() &&
123 full_dims.maxDynamicWellLists() == rst_dims.maxDynamicWellLists();
124 }
125
126 bool operator==(const Welldims& data) const {
127 return this->location() == data.location() &&
128 rst_cmp(*this, data);
129 }
130
131 template<class Serializer>
132 void serializeOp(Serializer& serializer)
133 {
134 serializer(nWMax);
135 serializer(nCWMax);
136 serializer(nWGMax);
137 serializer(nGMax);
138 serializer(nWlistPrWellMax);
139 serializer(nDynWlistMax);
140 serializer(m_location);
141 }
142
143private:
144 int nWMax { 0 };
145 int nCWMax { 0 };
146 int nWGMax { 0 };
147 int nGMax { 0 };
148 int nWlistPrWellMax { 1 };
149 int nDynWlistMax { 1 };
150 std::optional<KeywordLocation> m_location;
151};
152
153class WellSegmentDims {
154public:
155 WellSegmentDims();
156 explicit WellSegmentDims(const Deck& deck);
157
158 static WellSegmentDims serializationTestObject();
159
160 int maxSegmentedWells() const
161 {
162 return this->nSegWellMax;
163 }
164
165 int maxSegmentsPerWell() const
166 {
167 return this->nSegmentMax;
168 }
169
170 int maxLateralBranchesPerWell() const
171 {
172 return this->nLatBranchMax;
173 }
174
175 const std::optional<KeywordLocation>& location() const
176 {
177 return this->location_;
178 }
179
180 bool operator==(const WellSegmentDims& data) const;
181
182 template<class Serializer>
183 void serializeOp(Serializer& serializer)
184 {
185 serializer(nSegWellMax);
186 serializer(nSegmentMax);
187 serializer(nLatBranchMax);
188 serializer(location_);
189 }
190
191private:
192 int nSegWellMax;
193 int nSegmentMax;
194 int nLatBranchMax;
195 std::optional<KeywordLocation> location_;
196};
197
198class NetworkDims {
199public:
200 NetworkDims();
201 explicit NetworkDims(const Deck& deck);
202
203 static NetworkDims serializationTestObject();
204
205 int maxNONodes() const
206 {
207 return this->nMaxNoNodes;
208 }
209
210 int maxNoBranches() const
211 {
212 return this->nMaxNoBranches;
213 }
214
215 int maxNoBranchesConToNode() const
216 {
217 return this->nMaxNoBranchesConToNode;
218 }
219
220 bool extendedNetwork() const
221 {
222 return this->type_ == Type::Extended;
223 }
224
225 bool standardNetwork() const
226 {
227 return this->type_ == Type::Standard;
228 }
229
230 bool active() const
231 {
232 return this->extendedNetwork()
233 || this->standardNetwork();
234 }
235
236 bool operator==(const NetworkDims& data) const;
237
238 template<class Serializer>
239 void serializeOp(Serializer& serializer)
240 {
241 serializer(nMaxNoNodes);
242 serializer(nMaxNoBranches);
243 serializer(nMaxNoBranchesConToNode);
244 }
245
246private:
247 enum class Type { None, Extended, Standard, };
248
249 int nMaxNoNodes;
250 int nMaxNoBranches;
251 int nMaxNoBranchesConToNode;
252 Type type_{ Type::None };
253};
254
255class AquiferDimensions {
256public:
257 AquiferDimensions();
258 explicit AquiferDimensions(const Deck& deck);
259
260 static AquiferDimensions serializationTestObject();
261
262 int maxAnalyticAquifers() const
263 {
264 return this->maxNumAnalyticAquifers;
265 }
266
267 int maxAnalyticAquiferConnections() const
268 {
269 return this->maxNumAnalyticAquiferConn;
270 }
271
272 template <class Serializer>
273 void serializeOp(Serializer& serializer)
274 {
275 serializer(this->maxNumAnalyticAquifers);
276 serializer(this->maxNumAnalyticAquiferConn);
277 }
278
279private:
280 int maxNumAnalyticAquifers;
281 int maxNumAnalyticAquiferConn;
282};
283
284bool operator==(const AquiferDimensions& lhs, const AquiferDimensions& rhs);
285
286class EclHysterConfig
287{
288public:
289 EclHysterConfig() = default;
290 explicit EclHysterConfig(const Deck& deck);
291
292 static EclHysterConfig serializationTestObject();
293
297 //void setActive(bool yesno);
298
302 bool active() const;
303
310 int pcHysteresisModel() const;
311
318 int krHysteresisModel() const;
319
325 double modParamTrapped() const;
326
332 double curvatureCapPrs() const;
333
337 bool activeWag() const;
338
342 bool doPcScaling() const;
343
347 bool fixWettingPhaseKillough() const;
348
349 bool operator==(const EclHysterConfig& data) const;
350
351 template<class Serializer>
352 void serializeOp(Serializer& serializer)
353 {
354 serializer(activeHyst);
355 serializer(pcHystMod);
356 serializer(krHystMod);
357 serializer(modParamTrappedValue);
358 serializer(curvatureCapPrsValue);
359 serializer(activeWagHyst);
360 serializer(enablePcScaling);
361 serializer(enableKilloughWettingFix);
362 }
363
364private:
365 // enable hysteresis at all
366 bool activeHyst { false };
367
368 // the capillary pressure and the relperm hysteresis models to be used
369 int pcHystMod { -1 };
370 int krHystMod { -1 };
371 // regularisation parameter used for Killough model
372 double modParamTrappedValue { 0.1 };
373 // curvature parameter for capillary pressure
374 double curvatureCapPrsValue { 0.1 };
375
376 // enable WAG hysteresis
377 bool activeWagHyst { false };
378
379 // flag to enable Pc scaling
380 bool enablePcScaling { false };
381
382 // flag to enable Fix for wetting phase Killough
383 bool enableKilloughWettingFix { false };
384};
385
386class SatFuncControls {
387public:
388 enum class ThreePhaseOilKrModel {
389 Default,
390 Stone1,
391 Stone2
392 };
393
394 enum class KeywordFamily {
395 Family_I, // SGOF, SWOF, SLGOF
396 Family_II, // SGFN, SOF{2,3}, SWFN, SGWFN
397 Family_III, // GSF, WSF
398
399 Undefined,
400 };
401
402 SatFuncControls();
403 explicit SatFuncControls(const Deck& deck);
404 explicit SatFuncControls(const double tolcritArg,
405 const ThreePhaseOilKrModel model,
406 const KeywordFamily family);
407
408 static SatFuncControls serializationTestObject();
409
410 double minimumRelpermMobilityThreshold() const
411 {
412 return this->tolcrit;
413 }
414
415 ThreePhaseOilKrModel krModel() const
416 {
417 return this->krmodel;
418 }
419
420 KeywordFamily family() const
421 {
422 return this->satfunc_family;
423 }
424
425 bool operator==(const SatFuncControls& rhs) const;
426
427 template<class Serializer>
428 void serializeOp(Serializer& serializer)
429 {
430 serializer(tolcrit);
431 serializer(krmodel);
432 serializer(satfunc_family);
433 }
434
435private:
436 double tolcrit;
437 ThreePhaseOilKrModel krmodel = ThreePhaseOilKrModel::Default;
438 KeywordFamily satfunc_family = KeywordFamily::Undefined;
439};
440
441
442class Nupcol {
443public:
444 Nupcol();
445 explicit Nupcol(int min_value);
446 void update(int value);
447 int value() const;
448
449 static Nupcol serializationTestObject();
450 bool operator==(const Nupcol& data) const;
451
452 template<class Serializer>
453 void serializeOp(Serializer& serializer) {
454 serializer(this->nupcol_value);
455 serializer(this->min_nupcol);
456 }
457
458private:
459 int min_nupcol;
460 int nupcol_value;
461};
462
463
464class MechSolver
465{
466public:
467 enum class Solver
468 {
469 TPSA
470 };
471
472 enum class CouplingScheme
473 {
474 Lagged,
475 FixedStress
476 };
477
478 MechSolver() = default;
479
480 explicit MechSolver(const Deck&);
481
482 bool operator==(const MechSolver& data) const;
483
484 static MechSolver serializationTestObject();
485
486 template<class Serializer>
487 void serializeOp(Serializer& serializer)
488 {
489 serializer(this->m_solver);
490 serializer(this->m_coupling);
491 serializer(this->m_fixed_stress_min_iter);
492 serializer(this->m_fixed_stress_max_iter);
493 }
494
495 bool laggedScheme() const
496 {
497 return this->m_coupling == CouplingScheme::Lagged;
498 }
499
500 bool fixedStressScheme() const
501 {
502 return this->m_coupling == CouplingScheme::FixedStress;
503 }
504
505 int fixedStressMinIter() const
506 {
507 return this->m_fixed_stress_min_iter;
508 }
509
510 int fixedStressMaxIter() const
511 {
512 return this->m_fixed_stress_max_iter;
513 }
514
515 bool tpsa() const
516 {
517 return this->m_solver == Solver::TPSA;
518 }
519
520private:
521 Solver m_solver{};
522 CouplingScheme m_coupling = CouplingScheme::Lagged;
523 int m_fixed_stress_min_iter{};
524 int m_fixed_stress_max_iter{};
525};
526
527
528class Tracers {
529public:
530 Tracers() = default;
531
532 explicit Tracers(const Deck& );
533 int water_tracers() const;
534 int gas_tracers() const;
535 int oil_tracers() const;
536
537 template<class Serializer>
538 void serializeOp(Serializer& serializer) {
539 serializer(this->m_oil_tracers);
540 serializer(this->m_water_tracers);
541 serializer(this->m_gas_tracers);
542 serializer(this->m_env_tracers);
543 serializer(this->diffusion_control);
544 serializer(this->max_iter);
545 serializer(this->min_iter);
546 }
547
548 static Tracers serializationTestObject();
549 bool operator==(const Tracers& data) const;
550
551private:
552 int m_oil_tracers{};
553 int m_water_tracers{};
554 int m_gas_tracers{};
555 int m_env_tracers{};
556 bool diffusion_control{false};
557 int max_iter{};
558 int min_iter{};
559 // The TRACERS keyword has some additional options which seem quite arcane,
560 // for now not included here.
561};
562
563
564class Geochem {
565public:
566 Geochem() = default;
567 Geochem(std::string file_name, double mbal_tol, double ph_tol, bool charge_balance,
568 bool activated, int splay_tree)
569 : m_file_name(file_name)
570 , m_mbal_tol(mbal_tol)
571 , m_ph_tol(ph_tol)
572 , m_charge_balance(charge_balance)
573 , m_activated(activated)
574 , m_splay_tree(splay_tree)
575 { };
576 explicit Geochem(const Deck&);
577
578 const std::string& geochem_file_name() const;
579 double mbal_tol() const;
580 double ph_tol() const;
581 int splay_tree_resolution() const;
582 bool charge_balance() const;
583 bool enabled() const;
584
585 template<class Serializer>
586 void serializeOp(Serializer& serializer) {
587 serializer(this->m_file_name);
588 serializer(this->m_mbal_tol);
589 serializer(this->m_ph_tol);
590 serializer(this->m_charge_balance);
591 serializer(this->m_activated);
592 serializer(this->m_splay_tree);
593 }
594 static Geochem serializationTestObject();
595
596 bool operator==(const Geochem& data) const;
597
598private:
599 std::string m_file_name;
600 double m_mbal_tol{};
601 double m_ph_tol{};
602 bool m_charge_balance{false};
603 bool m_activated{false};
604 int m_splay_tree{0};
605};
606
607
608class Runspec {
609public:
610 Runspec() = default;
611 explicit Runspec( const Deck& );
612
613 static Runspec serializationTestObject();
614
615 std::time_t start_time() const noexcept;
616 const UDQParams& udqParams() const noexcept;
617 const Phases& phases() const noexcept;
618 const Tabdims& tabdims() const noexcept;
619 const Regdims& regdims() const noexcept;
620 const EndpointScaling& endpointScaling() const noexcept;
621 const Welldims& wellDimensions() const noexcept;
622 const WellSegmentDims& wellSegmentDimensions() const noexcept;
623 const NetworkDims& networkDimensions() const noexcept;
624 const AquiferDimensions& aquiferDimensions() const noexcept;
625 int eclPhaseMask( ) const noexcept;
626 const EclHysterConfig& hysterPar() const noexcept;
627 const Actdims& actdims() const noexcept;
628 const SatFuncControls& saturationFunctionControls() const noexcept;
629 const Nupcol& nupcol() const noexcept;
630
631 const MechSolver& mechSolver() const;
632
633 const Tracers& tracers() const;
634 const Geochem& geochem() const;
635 bool compositionalMode() const;
636 size_t numComps() const;
637 bool co2Storage() const noexcept;
638 bool co2Sol() const noexcept;
639 bool h2Sol() const noexcept;
640 bool h2Storage() const noexcept;
641 bool micp() const noexcept;
642 bool mech() const noexcept;
643 bool frac() const noexcept;
644 bool temp() const noexcept;
645 bool compositional() const noexcept;
646 bool biof() const noexcept;
647
648 bool operator==(const Runspec& data) const;
649 static bool rst_cmp(const Runspec& full_state, const Runspec& rst_state);
650
651 template<class Serializer>
652 void serializeOp(Serializer& serializer)
653 {
654 serializer(this->m_start_time);
655 serializer(active_phases);
656 serializer(m_tabdims);
657 serializer(m_regdims);
658 serializer(endscale);
659 serializer(welldims);
660 serializer(wsegdims);
661 serializer(netwrkdims);
662 serializer(aquiferdims);
663 serializer(udq_params);
664 serializer(hystpar);
665 serializer(m_actdims);
666 serializer(m_sfuncctrl);
667 serializer(m_nupcol);
668 serializer(m_tracers);
669 serializer(m_comps);
670 serializer(m_co2storage);
671 serializer(m_co2sol);
672 serializer(m_h2sol);
673 serializer(m_h2storage);
674 serializer(m_micp);
675 serializer(m_mech);
676 serializer(m_frac);
677 serializer(m_temp);
678 serializer(m_mechsolver);
679 serializer(m_biof);
680 serializer(m_geochem);
681 }
682
683private:
684 std::time_t m_start_time{};
685 Phases active_phases{};
686 Tabdims m_tabdims{};
687 Regdims m_regdims{};
688 EndpointScaling endscale{};
689 Welldims welldims{};
690 WellSegmentDims wsegdims{};
691 NetworkDims netwrkdims{};
692 AquiferDimensions aquiferdims{};
693 UDQParams udq_params{};
694 EclHysterConfig hystpar{};
695 Actdims m_actdims{};
696 SatFuncControls m_sfuncctrl{};
697 Nupcol m_nupcol{};
698 MechSolver m_mechsolver{};
699 Tracers m_tracers{};
700 Geochem m_geochem{};
701 size_t m_comps = 0;
702 bool m_co2storage{false};
703 bool m_co2sol{false};
704 bool m_h2sol{false};
705 bool m_h2storage{false};
706 bool m_micp{false};
707 bool m_mech{false};
708 bool m_frac{false};
709 bool m_temp{false};
710 bool m_biof{false};
711};
712
713std::size_t declaredMaxRegionID(const Runspec& rspec);
714
715} // namespace Opm
716
717#endif // OPM_RUNSPEC_HPP
Definition Actdims.hpp:30
Definition Runspec.hpp:255
Definition Deck.hpp:46
Definition Runspec.hpp:287
int pcHysteresisModel() const
Return the type of the hysteresis model which is used for capillary pressure.
Definition Runspec.cpp:486
double modParamTrapped() const
Regularisation parameter used for Killough model.
Definition Runspec.cpp:492
bool fixWettingPhaseKillough() const
Activate fix for wetting phase killough.
Definition Runspec.cpp:504
double curvatureCapPrs() const
Curvature parameter used for capillary pressure hysteresis.
Definition Runspec.cpp:495
bool activeWag() const
Wag hysteresis.
Definition Runspec.cpp:498
bool doPcScaling() const
Do Pc scaling for scanning curves.
Definition Runspec.cpp:501
bool active() const
Specify whether hysteresis is enabled or not.
Definition Runspec.cpp:483
int krHysteresisModel() const
Return the type of the hysteresis model which is used for relative permeability.
Definition Runspec.cpp:489
Definition EndpointScaling.hpp:28
Definition Runspec.hpp:564
Definition Runspec.hpp:465
Definition Runspec.hpp:198
Definition Runspec.hpp:442
Definition Runspec.hpp:46
Definition Regdims.hpp:36
Definition Runspec.hpp:608
Definition Runspec.hpp:386
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition Tabdims.hpp:36
Definition Runspec.hpp:528
Definition UDQParams.hpp:31
Definition Runspec.hpp:153
Definition Runspec.hpp:75
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30