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 <cstddef>
24#include <functional>
25#include <memory>
26#include <optional>
27#include <string>
28#include <unordered_map>
29#include <vector>
30
31namespace Opm {
32
33 class SegmentMatcher;
34 class SegmentSet;
35 class SummaryState;
36 class UDQFunctionTable;
37 class UDQSet;
38 class UDQState;
39 class WellMatcher;
40
41} // namespace Opm
42
43namespace Opm {
44
46 {
47 public:
48 using SegmentMatcherFactory = std::function<std::unique_ptr<SegmentMatcher>()>;
49
50 UDQContext(const UDQFunctionTable& udqft,
51 const WellMatcher& wm,
52 SegmentMatcherFactory create_segment_matcher,
53 SummaryState& summary_state,
54 UDQState& udq_state);
55
56 std::optional<double> get(const std::string& key) const;
57 std::optional<double> get_well_var(const std::string& well, const std::string& var) const;
58 std::optional<double> get_group_var(const std::string& group, const std::string& var) const;
59 std::optional<double> get_segment_var(const std::string& well, const std::string& var, std::size_t segment) const;
60
61 void add(const std::string& key, double value);
62 void update_assign(const std::string& keyword, const UDQSet& udq_result);
63 void update_define(std::size_t report_step, const std::string& keyword, const UDQSet& udq_result);
64
65 const UDQFunctionTable& function_table() const;
66
67 std::vector<std::string> wells() const;
68 std::vector<std::string> wells(const std::string& pattern) const;
69 std::vector<std::string> groups() const;
70 SegmentSet segments() const;
71 SegmentSet segments(const std::vector<std::string>& set_descriptor) const;
72
73 private:
74 const UDQFunctionTable& udqft;
75 const WellMatcher& well_matcher;
76
77 SegmentMatcherFactory create_segment_matcher;
78 mutable std::unique_ptr<SegmentMatcher> segment_matcher;
79 SummaryState& summary_state;
80 UDQState& udq_state;
81
82 //std::unordered_map<std::string, UDQSet> udq_results;
83 std::unordered_map<std::string, double> values;
84
85 void ensure_segment_matcher_exists() const;
86 };
87
88} // namespace Opm
89
90#endif // UDQ_CONTEXT_HPP
Definition SummaryState.hpp:68
Definition UDQContext.hpp:46
Definition UDQFunctionTable.hpp:32
Definition UDQSet.hpp:186
Definition UDQState.hpp:38
Definition WellMatcher.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30