My Project
Loading...
Searching...
No Matches
UDQContext.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#ifndef UDQ_CONTEXT_HPP
21#define UDQ_CONTEXT_HPP
22
23#include <opm/input/eclipse/EclipseState/Grid/RegionSetMatcher.hpp>
24#include <opm/input/eclipse/Schedule/MSW/SegmentMatcher.hpp>
25
26#include <cstddef>
27#include <functional>
28#include <memory>
29#include <optional>
30#include <string>
31#include <unordered_map>
32#include <vector>
33
34namespace Opm {
35
36 class SegmentSet;
37 class SummaryState;
38 class UDQFunctionTable;
39 class UDQSet;
40 class UDQState;
41 class UDT;
42 class WellMatcher;
43
44} // namespace Opm
45
46namespace Opm {
47
49 {
50 public:
52 {
53 std::function<std::unique_ptr<SegmentMatcher>()> segments{};
54 std::function<std::unique_ptr<RegionSetMatcher>()> regions{};
55 };
56
57 UDQContext(const UDQFunctionTable& udqft,
58 const WellMatcher& wm,
59 const std::unordered_map<std::string, UDT>& tables,
60 MatcherFactories create_matchers,
61 SummaryState& summary_state,
62 UDQState& udq_state);
63
64 std::optional<double> get(const std::string& key) const;
65
66 std::optional<double>
67 get_well_var(const std::string& well, const std::string& var) const;
68
69 std::optional<double>
70 get_group_var(const std::string& group, const std::string& var) const;
71
72 std::optional<double>
73 get_segment_var(const std::string& well,
74 const std::string& var,
75 std::size_t segment) const;
76
77 std::optional<double>
78 get_region_var(const std::string& regSet,
79 const std::string& var,
80 std::size_t region) const;
81
82 const UDT& get_udt(const std::string& name) const;
83
84 void add(const std::string& key, double value);
85 void update_assign(const std::string& keyword, const UDQSet& udq_result);
86 void update_define(std::size_t report_step,
87 const std::string& keyword,
88 const UDQSet& udq_result);
89
90 const UDQFunctionTable& function_table() const;
91
92 std::vector<std::string> wells() const;
93 std::vector<std::string> wells(const std::string& pattern) const;
94 std::vector<std::string> groups() const;
95 SegmentSet segments() const;
96 SegmentSet segments(const std::vector<std::string>& set_descriptor) const;
97
98 RegionSetMatchResult regions() const;
99 RegionSetMatchResult regions(const std::string& vector_name,
100 const std::vector<std::string>& set_descriptor) const;
101
102 private:
103 struct Matchers
104 {
105 std::unique_ptr<SegmentMatcher> segments{};
106 std::unique_ptr<RegionSetMatcher> regions{};
107 };
108
109 const UDQFunctionTable& udqft;
110 const WellMatcher& well_matcher;
111 const std::unordered_map<std::string, UDT>& udt;
112
113 SummaryState& summary_state;
114 UDQState& udq_state;
115
116 MatcherFactories create_matchers_{};
117 mutable Matchers matchers_{};
118
119 //std::unordered_map<std::string, UDQSet> udq_results;
120 std::unordered_map<std::string, double> values;
121
122 void ensure_segment_matcher_exists() const;
123 void ensure_region_matcher_exists() const;
124 };
125
126} // namespace Opm
127
128#endif // UDQ_CONTEXT_HPP
Result Set From RegionSetMatcher's Matching Process.
Definition RegionSetMatcher.hpp:44
Definition SummaryState.hpp:68
Definition UDQContext.hpp:49
Definition UDQFunctionTable.hpp:32
Definition UDQSet.hpp:187
Definition UDQState.hpp:38
Definition UDT.hpp:30
Definition WellMatcher.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition UDQContext.hpp:52