My Project
UDQState.hpp
1/*
2 Copyright 2020 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#ifndef UDQSTATE_HPP_
21#define UDQSTATE_HPP_
22
23#include <opm/input/eclipse/Schedule/UDQ/UDQSet.hpp>
24
25#include <cstddef>
26#include <string>
27#include <unordered_map>
28#include <utility>
29#include <vector>
30
31namespace Opm { namespace RestartIO {
32 struct RstState;
33}} // namespace Opm::RestartIO
34
35namespace Opm {
36
38{
39public:
40 UDQState() = default;
41 UDQState(double undefined);
42
43 bool has(const std::string& key) const;
44 void load_rst(const RestartIO::RstState& rst_state);
45
46 bool has_well_var(const std::string& well, const std::string& key) const;
47 bool has_group_var(const std::string& group, const std::string& key) const;
48 bool has_segment_var(const std::string& well, const std::string& key, const std::size_t segment) const;
49
50 double get(const std::string& key) const;
51 double get_group_var(const std::string& well, const std::string& var) const;
52 double get_well_var(const std::string& well, const std::string& var) const;
53 double get_segment_var(const std::string& well, const std::string& var, const std::size_t segment) const;
54
55 void add_define(std::size_t report_step, const std::string& udq_key, const UDQSet& result);
56 void add_assign(std::size_t report_step, const std::string& udq_key, const UDQSet& result);
57 bool assign(std::size_t report_step, const std::string& udq_key) const;
58 bool define(const std::string& udq_key, const std::pair<UDQUpdate, std::size_t>& update_status) const;
59 double undefined_value() const;
60
61 bool operator==(const UDQState& other) const;
62
63 static UDQState serializationTestObject();
64
65 template <class Serializer>
66 void serializeOp(Serializer& serializer)
67 {
68 serializer(this->undef_value);
69 serializer(this->scalar_values);
70 serializer(this->well_values);
71 serializer(this->group_values);
72 serializer(this->segment_values);
73 serializer(this->assignments);
74 serializer(this->defines);
75 }
76
77private:
78 double undef_value;
79 std::unordered_map<std::string, double> scalar_values{};
80
81 // [var][well] -> double
82 std::unordered_map<std::string, std::unordered_map<std::string, double>> well_values{};
83
84 // [var][group] -> double
85 std::unordered_map<std::string, std::unordered_map<std::string, double>> group_values{};
86
87 // [var][well][segment] -> double
88 std::unordered_map<std::string, std::unordered_map<std::string, std::unordered_map<std::size_t, double>>> segment_values{};
89
90 std::unordered_map<std::string, std::size_t> assignments;
91 std::unordered_map<std::string, std::size_t> defines;
92
93 void add(const std::string& udq_key, const UDQSet& result);
94 double get_wg_var(const std::string& well, const std::string& key, UDQVarType var_type) const;
95};
96
97} // namespace Opm
98
99#endif // UDQSTATE_HPP_
Class for (de-)serializing.
Definition: Serializer.hpp:84
Definition: UDQSet.hpp:182
Definition: UDQState.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: state.hpp:54