My Project
Loading...
Searching...
No Matches
SummaryConfig.hpp
1/*
2 Copyright 2015 Statoil 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 OPM_SUMMARY_CONFIG_HPP
21#define OPM_SUMMARY_CONFIG_HPP
22
23#include <opm/io/eclipse/SummaryNode.hpp>
24
25#include <opm/common/OpmLog/KeywordLocation.hpp>
26
27#include <array>
28#include <limits>
29#include <optional>
30#include <set>
31#include <string>
32#include <unordered_set>
33#include <vector>
34
35namespace Opm {
36 class AquiferConfig;
37 class Deck;
38 class EclipseState;
39 class ErrorGuard;
40 class FieldPropsManager;
41 class GridDims;
42 class ParseContext;
43 class Schedule;
44} // namespace Opm
45
46namespace Opm {
47
49 {
50 public:
51 using Category = Opm::EclIO::SummaryNode::Category;
52 using Type = Opm::EclIO::SummaryNode::Type;
53
54 SummaryConfigNode() = default;
55 explicit SummaryConfigNode(std::string keyword,
56 const Category cat,
57 KeywordLocation loc_arg);
58
59 static SummaryConfigNode serializationTestObject();
60
61 SummaryConfigNode& parameterType(const Type type);
62 SummaryConfigNode& namedEntity(std::string name);
63 SummaryConfigNode& number(const int num);
64 SummaryConfigNode& isUserDefined(const bool userDefined);
65 SummaryConfigNode& fip_region(const std::string& fip_region);
66
67 const std::string& keyword() const { return this->keyword_; }
68 Category category() const { return this->category_; }
69 Type type() const { return this->type_; }
70 const std::string& namedEntity() const { return this->name_; }
71 int number() const { return this->number_; }
72 bool isUserDefined() const { return this->userDefined_; }
73 const std::string& fip_region() const { return *this->fip_region_ ; }
74
75 std::string uniqueNodeKey() const;
76 const KeywordLocation& location() const { return this->loc; }
77
78 operator Opm::EclIO::SummaryNode() const {
79 return { keyword_, category_, type_, name_, number_, fip_region_, {}};
80 }
81
82 template<class Serializer>
83 void serializeOp(Serializer& serializer)
84 {
85 serializer(keyword_);
86 serializer(category_);
87 serializer(loc);
88 serializer(type_);
89 serializer(name_);
90 serializer(number_);
91 serializer(fip_region_);
92 serializer(userDefined_);
93 }
94
95 private:
96 std::string keyword_;
97 Category category_;
99 Type type_{ Type::Undefined };
100 std::string name_{};
101 int number_{std::numeric_limits<int>::min()};
102 std::optional<std::string> fip_region_;
103 bool userDefined_{false};
104 };
105
106 SummaryConfigNode::Category parseKeywordCategory(const std::string& keyword);
107 SummaryConfigNode::Type parseKeywordType(std::string keyword);
108
109 bool operator==(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
110 bool operator<(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
111
112 inline bool operator!=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
113 {
114 return ! (lhs == rhs);
115 }
116
117 inline bool operator<=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
118 {
119 return ! (rhs < lhs);
120 }
121
122 inline bool operator>(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
123 {
124 return rhs < lhs;
125 }
126
127 inline bool operator>=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
128 {
129 return ! (lhs < rhs);
130 }
131
133 {
134 public:
136 typedef std::vector< keyword_type > keyword_list;
137 typedef keyword_list::const_iterator const_iterator;
138
139 SummaryConfig() = default;
140 SummaryConfig( const Deck&,
141 const Schedule&,
142 const FieldPropsManager&,
143 const AquiferConfig&,
144 const ParseContext&,
145 ErrorGuard&);
146
147 template <typename T>
148 SummaryConfig( const Deck&,
149 const Schedule&,
150 const FieldPropsManager&,
151 const AquiferConfig&,
152 const ParseContext&,
153 T&&);
154
155 SummaryConfig( const Deck&,
156 const Schedule&,
157 const FieldPropsManager&,
158 const AquiferConfig&);
159
160 SummaryConfig(const keyword_list& kwds,
161 const std::set<std::string>& shortKwds,
162 const std::set<std::string>& smryKwds);
163
164 static SummaryConfig serializationTestObject();
165
166 const_iterator begin() const;
167 const_iterator end() const;
168 size_t size() const;
169 SummaryConfig& merge( const SummaryConfig& );
170 SummaryConfig& merge( SummaryConfig&& );
171
172 keyword_list
173 registerRequisiteUDQorActionSummaryKeys(const std::vector<std::string>& extraKeys,
174 const EclipseState& es,
175 const Schedule& sched);
176
177 /*
178 The hasKeyword() method will consult the internal set
179 'short_keywords', i.e. the query should be based on pure
180 keywords like 'WWCT' and 'BPR' - and *not* fully
181 identifiers like 'WWCT:OPX' and 'BPR:10,12,3'.
182 */
183 bool hasKeyword( const std::string& keyword ) const;
184
185
186 /*
187 Will check if the SummaryConfig object contains any keyword
188 matching the pattern argument. The matching is done with
189 fnmatch().
190 */
191 bool match(const std::string& keywordPattern) const;
192
193
194 keyword_list keywords(const std::string& keywordPattern) const;
195
196 /*
197 The hasSummaryKey() method will look for fully
198 qualified keys like 'RPR:3' and 'BPR:10,15,20.
199 */
200 bool hasSummaryKey(const std::string& keyword ) const;
201 /*
202 Can be used to query if a certain 3D field, e.g. PRESSURE,
203 is required to calculate the summary variables.
204 */
205 bool require3DField( const std::string& keyword) const;
206 std::set<std::string> fip_regions() const;
207 std::set<std::string> fip_regions_interreg_flow() const;
208 std::unordered_set<std::string> wbp_wells() const;
209
210 bool operator==(const SummaryConfig& data) const;
211
212 template<class Serializer>
213 void serializeOp(Serializer& serializer)
214 {
215 serializer(m_keywords);
216 serializer(short_keywords);
217 serializer(summary_keywords);
218 }
219
220 bool createRunSummary() const {
221 return runSummaryConfig.create;
222 }
223
224 const SummaryConfigNode& operator[](std::size_t index) const;
225
226
227 private:
228 SummaryConfig( const Deck& deck,
229 const Schedule& schedule,
230 const FieldPropsManager& field_props,
231 const AquiferConfig& aquiferConfig,
232 const ParseContext& parseContext,
233 ErrorGuard& errors,
234 const GridDims& dims);
235
236 /*
237 The short_keywords set contains only the pure keyword
238 part, e.g. "WWCT", and not the qualification with
239 well/group name or a numerical value.
240 */
241 keyword_list m_keywords;
242 std::set<std::string> short_keywords;
243 std::set<std::string> summary_keywords;
244
245 struct {
246 bool create { false };
247 bool narrow { false };
248 bool separate { true };
249 } runSummaryConfig;
250
251 void handleProcessingInstruction(const std::string& keyword);
252 };
253
254} // namespace Opm
255
256#endif // OPM_SUMMARY_CONFIG_HPP
Definition AquiferConfig.hpp:46
Definition Deck.hpp:49
Definition EclipseState.hpp:63
Definition ErrorGuard.hpp:29
Definition FieldPropsManager.hpp:42
Definition GridDims.hpp:31
Definition KeywordLocation.hpp:27
Definition ParseContext.hpp:84
Definition Schedule.hpp:88
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition SummaryConfig.hpp:49
Definition SummaryConfig.hpp:133
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition SummaryNode.hpp:36