My Project
UDQInput.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
21#ifndef UDQINPUT__HPP_
22#define UDQINPUT__HPP_
23
24#include <variant>
25
26#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
27#include <opm/input/eclipse/Schedule/UDQ/UDQDefine.hpp>
28#include <opm/input/eclipse/Schedule/UDQ/UDQAssign.hpp>
29
30namespace Opm {
31
32class UDQAssign;
33class UDQDefine;
34
35class UDQIndex {
36public:
37 UDQIndex() = default;
38
39 UDQIndex(std::size_t insert_index_arg, std::size_t typed_insert_index_arg, UDQAction action_arg, UDQVarType var_type_arg) :
40 insert_index(insert_index_arg),
41 typed_insert_index(typed_insert_index_arg),
42 action(action_arg),
43 var_type(var_type_arg)
44 {
45 }
46
47 static UDQIndex serializationTestObject()
48 {
49 UDQIndex result;
50 result.insert_index = 1;
51 result.typed_insert_index = 2;
52 result.action = UDQAction::ASSIGN;
53 result.var_type = UDQVarType::WELL_VAR;
54
55 return result;
56 }
57
58 bool operator==(const UDQIndex& data) const {
59 return insert_index == data.insert_index &&
60 typed_insert_index == data.typed_insert_index &&
61 action == data.action &&
62 var_type == data.var_type;
63 }
64
65 template<class Serializer>
66 void serializeOp(Serializer& serializer)
67 {
68 serializer(insert_index);
69 serializer(typed_insert_index);
70 serializer(action);
71 serializer(var_type);
72 }
73
74 std::size_t insert_index;
75 std::size_t typed_insert_index;
76 UDQAction action;
77 UDQVarType var_type;
78};
79
80
82public:
83 UDQInput(const UDQIndex& index, const UDQDefine& udq_define, const std::string& unit);
84 UDQInput(const UDQIndex& index, const UDQAssign& udq_assign, const std::string& unit);
85
86 template<typename T>
87 const T& get() const;
88
89 template<typename T>
90 bool is() const;
91
92 const std::string& keyword() const;
93 const UDQVarType& var_type() const;
94 const std::string& unit() const;
95 const UDQIndex index;
96
97 bool operator==(const UDQInput& other) const;
98private:
99 std::variant<UDQDefine, UDQAssign> value;
100 const std::string m_keyword;
101 UDQVarType m_var_type;
102 const std::string m_unit;
103};
104}
105
106
107
108#endif
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: UDQAssign.hpp:34
Definition: UDQDefine.hpp:43
Definition: UDQInput.hpp:35
Definition: UDQInput.hpp:81
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29