My Project
Loading...
Searching...
No Matches
UDQAssign.hpp
1/*
2 Copyright 2018 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
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#ifndef UDQASSIGN_HPP_
21#define UDQASSIGN_HPP_
22
23#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
24#include <opm/input/eclipse/Schedule/UDQ/UDQSet.hpp>
25
26#include <cstddef>
27#include <string>
28#include <unordered_set>
29#include <utility>
30#include <vector>
31
32namespace Opm {
33
35{
36public:
37 // If the same keyword is assigned several times the different
38 // assignment records are assembled in one UDQAssign instance. This is
39 // an attempt to support restart in a situation where a full UDQ ASSIGN
40 // statement can be swapped with a UDQ DEFINE statement.
42 {
43 std::vector<std::string> input_selector{};
44 std::unordered_set<std::string> rst_selector{};
45 std::vector<UDQSet::EnumeratedItems> numbered_selector{};
46 double value{};
47 std::size_t report_step{};
48
49 AssignRecord() = default;
50
51 AssignRecord(const std::vector<std::string>& selector,
52 const double value_arg,
53 const std::size_t report_step_arg)
54 : input_selector(selector)
55 , value (value_arg)
56 , report_step (report_step_arg)
57 {}
58
59 AssignRecord(const std::unordered_set<std::string>& selector,
60 const double value_arg,
61 const std::size_t report_step_arg)
62 : rst_selector(selector)
63 , value (value_arg)
64 , report_step (report_step_arg)
65 {}
66
67 AssignRecord(const std::vector<UDQSet::EnumeratedItems>& selector,
68 const double value_arg,
69 const std::size_t report_step_arg)
70 : numbered_selector(selector)
71 , value (value_arg)
72 , report_step (report_step_arg)
73 {}
74
75 AssignRecord(std::vector<UDQSet::EnumeratedItems>&& selector,
76 const double value_arg,
77 const std::size_t report_step_arg)
78 : numbered_selector(std::move(selector))
79 , value (value_arg)
80 , report_step (report_step_arg)
81 {}
82
83 void eval(UDQSet& values) const;
84
85 bool operator==(const AssignRecord& data) const;
86
87 template<class Serializer>
88 void serializeOp(Serializer& serializer)
89 {
90 serializer(this->input_selector);
91 serializer(this->rst_selector);
92 serializer(this->numbered_selector);
93 serializer(this->value);
94 serializer(this->report_step);
95 }
96 };
97
98 UDQAssign() = default;
99 UDQAssign(const std::string& keyword,
100 const std::vector<std::string>& selector,
101 double value,
102 std::size_t report_step);
103
104 UDQAssign(const std::string& keyword,
105 const std::unordered_set<std::string>& selector,
106 double value,
107 std::size_t report_step);
108
109 UDQAssign(const std::string& keyword,
110 const std::vector<UDQSet::EnumeratedItems>& selector,
111 double value,
112 std::size_t report_step);
113
114 UDQAssign(const std::string& keyword,
115 std::vector<UDQSet::EnumeratedItems>&& selector,
116 double value,
117 std::size_t report_step);
118
119 static UDQAssign serializationTestObject();
120
121 const std::string& keyword() const;
122 UDQVarType var_type() const;
123
124 void add_record(const std::vector<std::string>& selector,
125 double value,
126 std::size_t report_step);
127
128 void add_record(const std::unordered_set<std::string>& rst_selector,
129 double value,
130 std::size_t report_step);
131
132 void add_record(const std::vector<UDQSet::EnumeratedItems>& selector,
133 double value,
134 std::size_t report_step);
135
136 void add_record(std::vector<UDQSet::EnumeratedItems>&& selector,
137 double value,
138 std::size_t report_step);
139
140 UDQSet eval(const std::vector<UDQSet::EnumeratedItems>& items) const;
141 UDQSet eval(const std::vector<std::string>& wells) const;
142 UDQSet eval() const;
143 std::size_t report_step() const;
144
145 bool operator==(const UDQAssign& data) const;
146
147 template<class Serializer>
148 void serializeOp(Serializer& serializer)
149 {
150 serializer(m_keyword);
151 serializer(m_var_type);
152 serializer(records);
153 }
154
155private:
156 std::string m_keyword{};
157 UDQVarType m_var_type{UDQVarType::NONE};
158 std::vector<AssignRecord> records{};
159};
160
161} // namespace Opm
162
163#endif // UDQASSIGN_HPP_
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition UDQAssign.hpp:35
Definition UDQSet.hpp:187
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition UDQAssign.hpp:42