My Project
Loading...
Searching...
No Matches
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 explicit 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(const std::string& udq_key, const UDQSet& result);
57 bool define(const std::string& udq_key, const std::pair<UDQUpdate, std::size_t>& update_status) const;
58 double undefined_value() const;
59
60 bool operator==(const UDQState& other) const;
61
62 static UDQState serializationTestObject();
63
64 template <class Serializer>
65 void serializeOp(Serializer& serializer)
66 {
67 serializer(this->undef_value);
68 serializer(this->scalar_values);
69 serializer(this->well_values);
70 serializer(this->group_values);
71 serializer(this->segment_values);
72 serializer(this->defines);
73 }
74
75private:
76 double undef_value;
77 std::unordered_map<std::string, double> scalar_values{};
78
79 // [var][well] -> double
80 std::unordered_map<std::string, std::unordered_map<std::string, double>> well_values{};
81
82 // [var][group] -> double
83 std::unordered_map<std::string, std::unordered_map<std::string, double>> group_values{};
84
85 // [var][well][segment] -> double
86 std::unordered_map<std::string, std::unordered_map<std::string, std::unordered_map<std::size_t, double>>> segment_values{};
87
88 std::unordered_map<std::string, std::size_t> defines;
89
90 void add(const std::string& udq_key, const UDQSet& result);
91 double get_wg_var(const std::string& well, const std::string& key, UDQVarType var_type) const;
92};
93
94} // namespace Opm
95
96#endif // UDQSTATE_HPP_
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition UDQSet.hpp:187
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