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 GroupOrder;
37 class SegmentSet;
38 class SummaryState;
39 class UDQFunctionTable;
40 class UDQSet;
41 class UDQState;
42 class UDT;
43 class WellMatcher;
44
45} // namespace Opm
46
47namespace Opm {
48
50 {
51 public:
53 {
54 std::function<std::unique_ptr<SegmentMatcher>()> segments{};
55 std::function<std::unique_ptr<RegionSetMatcher>()> regions{};
56 };
57
58 UDQContext(const UDQFunctionTable& udqft,
59 const WellMatcher& wm,
60 const GroupOrder& go,
61 const std::unordered_map<std::string, UDT>& tables,
62 MatcherFactories create_matchers,
63 SummaryState& summary_state,
64 UDQState& udq_state);
65
66 std::optional<double> get(const std::string& key) const;
67
68 std::optional<double>
69 get_well_var(const std::string& well, const std::string& var) const;
70
71 std::optional<double>
72 get_group_var(const std::string& group, const std::string& var) const;
73
74 std::optional<double>
75 get_segment_var(const std::string& well,
76 const std::string& var,
77 std::size_t segment) const;
78
79 std::optional<double>
80 get_region_var(const std::string& regSet,
81 const std::string& var,
82 std::size_t region) const;
83
84 const UDT& get_udt(const std::string& name) const;
85
86 void add(const std::string& key, double value);
87 void update_assign(const std::string& keyword, const UDQSet& udq_result);
88 void update_define(std::size_t report_step,
89 const std::string& keyword,
90 const UDQSet& udq_result);
91
92 const UDQFunctionTable& function_table() const;
93
94 const std::vector<std::string>& wells() const;
95 std::vector<std::string> wells(const std::string& pattern) const;
96 std::vector<std::string> nonFieldGroups() const;
97 std::vector<std::string> groups(const std::string& pattern) const;
98 SegmentSet segments() const;
99 SegmentSet segments(const std::vector<std::string>& set_descriptor) const;
100
101 RegionSetMatchResult regions() const;
102 RegionSetMatchResult regions(const std::string& vector_name,
103 const std::vector<std::string>& set_descriptor) const;
104
105 private:
106 struct Matchers
107 {
108 std::unique_ptr<SegmentMatcher> segments{};
109 std::unique_ptr<RegionSetMatcher> regions{};
110 };
111
112 const UDQFunctionTable& udqft;
113 const WellMatcher& well_matcher;
114 const GroupOrder& group_order_;
115 const std::unordered_map<std::string, UDT>& udt;
116
117 SummaryState& summary_state;
118 UDQState& udq_state;
119
120 MatcherFactories create_matchers_{};
121 mutable Matchers matchers_{};
122
123 //std::unordered_map<std::string, UDQSet> udq_results;
124 std::unordered_map<std::string, double> values;
125
126 void ensure_segment_matcher_exists() const;
127 void ensure_region_matcher_exists() const;
128 };
129
130} // namespace Opm
131
132#endif // UDQ_CONTEXT_HPP
Collection of group names with built-in ordering.
Definition NameOrder.hpp:69
Result Set From RegionSetMatcher's Matching Process.
Definition RegionSetMatcher.hpp:44
Definition SummaryState.hpp:72
Definition UDQContext.hpp:50
Definition UDQFunctionTable.hpp:32
Definition UDQSet.hpp:187
Definition UDQState.hpp:40
Definition UDT.hpp:30
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition UDQContext.hpp:53