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