My Project
udq.hpp
1 /*
2  Copyright 2021 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 it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  OPM is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with OPM. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef RST_UDQ
20 #define RST_UDQ
21 
22 #include <cstddef>
23 #include <optional>
24 #include <string>
25 #include <unordered_set>
26 #include <utility>
27 #include <variant>
28 #include <vector>
29 #include <algorithm>
30 
31 #include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
32 #include <opm/input/eclipse/EclipseState/Runspec.hpp>
33 
34 namespace Opm {
35 
36 namespace RestartIO {
37 
38 struct RstHeader;
39 
40 class RstUDQ {
41 public:
42  struct RstDefine {
43  RstDefine(const std::string& expression_arg, UDQUpdate status_arg);
44 
45  std::string expression;
46  UDQUpdate status;
47  std::vector<std::pair<std::string, double>> values;
48  std::optional<double> field_value;
49  };
50 
51  struct RstAssign {
52  void update_value(const std::string& name_arg, double new_value);
53 
54  std::optional<double> value;
55  std::unordered_set<std::string> selector;
56  };
57 
58 
59  RstUDQ(const std::string& name_arg,
60  const std::string& unit_arg,
61  const std::string& define_arg,
62  UDQUpdate status_arg);
63 
64  RstUDQ(const std::string& name_arg,
65  const std::string& unit_arg);
66 
67  void add_value(double value);
68  void add_value(const std::string& wgname, double value);
69 
70  bool is_define() const;
71  double assign_value() const;
72  const std::unordered_set<std::string>& assign_selector() const;
73  const std::string& expression() const;
74  const std::vector<std::pair<std::string, double>>& values() const;
75  std::optional<double> field_value() const;
76 
77  std::string name;
78  std::string unit;
79  UDQVarType var_type;
80 
81 private:
82  std::variant<std::monostate, RstDefine, RstAssign> data;
83 };
84 
85 
86 
87 class RstUDQActive {
88 
89  struct RstRecord {
90  RstRecord(UDAControl c, std::size_t i, std::size_t u1, std::size_t u2);
91 
92 
93  UDAControl control;
94  std::size_t input_index;
95  std::size_t use_count;
96  std::size_t wg_offset;
97  };
98 
99 
100 public:
101  RstUDQActive() = default;
102  RstUDQActive(const std::vector<int>& iuad, const std::vector<int>& iuap, const std::vector<int>& igph);
103 
104  std::vector<RstRecord> iuad;
105  std::vector<int> wg_index;
106  std::vector<Phase> ig_phase;
107 };
108 }
109 }
110 
111 
112 
113 #endif
Definition: udq.hpp:87
Definition: udq.hpp:40
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: udq.hpp:51
Definition: udq.hpp:42