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 
30 #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
31 #include <opm/parser/eclipse/EclipseState/Runspec.hpp>
32 
33 namespace Opm {
34 
35 namespace RestartIO {
36 
37 struct RstHeader;
38 
39 class RstUDQ {
40 public:
41  struct RstDefine {
42  RstDefine(const std::string& expression_arg, UDQUpdate status_arg);
43 
44  std::string expression;
45  UDQUpdate status;
46  std::vector<std::pair<std::string, double>> values;
47  std::optional<double> field_value;
48  };
49 
50  struct RstAssign {
51  void update_value(const std::string& name_arg, double new_value);
52 
53  std::optional<double> value;
54  std::unordered_set<std::string> selector;
55  };
56 
57 
58  RstUDQ(const std::string& name_arg,
59  const std::string& unit_arg,
60  const std::string& define_arg,
61  UDQUpdate status_arg);
62 
63  RstUDQ(const std::string& name_arg,
64  const std::string& unit_arg);
65 
66  void add_value(double value);
67  void add_value(const std::string& wgname, double value);
68 
69  bool is_define() const;
70  double assign_value() const;
71  const std::unordered_set<std::string>& assign_selector() const;
72  const std::string& expression() const;
73  const std::vector<std::pair<std::string, double>>& values() const;
74  std::optional<double> field_value() const;
75 
76  std::string name;
77  std::string unit;
78  UDQVarType var_type;
79 
80 private:
81  std::variant<std::monostate, RstDefine, RstAssign> data;
82 };
83 
84 
85 
86 class RstUDQActive {
87 
88  struct RstRecord {
89  RstRecord(UDAControl c, std::size_t i, std::size_t u1, std::size_t u2);
90 
91 
92  UDAControl control;
93  std::size_t input_index;
94  std::size_t use_count;
95  std::size_t wg_offset;
96  };
97 
98 
99 public:
100  RstUDQActive() = default;
101  RstUDQActive(const std::vector<int>& iuad, const std::vector<int>& iuap, const std::vector<int>& igph);
102 
103  std::vector<RstRecord> iuad;
104  std::vector<int> wg_index;
105  std::vector<Phase> ig_phase;
106 };
107 }
108 }
109 
110 
111 
112 #endif
Definition: udq.hpp:86
Definition: udq.hpp:39
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: udq.hpp:50
Definition: udq.hpp:41