SummaryConfig.hpp
Go to the documentation of this file.
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 <set>
26#include <string>
27#include <vector>
28
31
32namespace Opm {
33
34 /*
35 Very small utility class to get value semantics on the smspec_node
36 pointers. This should die as soon as the smspec_node class proper gets
37 value semantics.
38 */
39
41 public:
44
45 SummaryConfigNode() = default;
46 explicit SummaryConfigNode(std::string keyword, const Category cat, Location loc_arg);
47
49
52 SummaryConfigNode& number(const int num);
53 SummaryConfigNode& isUserDefined(const bool userDefined);
54
55 const std::string& keyword() const { return this->keyword_; }
56 Category category() const { return this->category_; }
57 Type type() const { return this->type_; }
58 const std::string& namedEntity() const { return this->name_; }
59 int number() const { return this->number_; }
60 bool isUserDefined() const { return this->userDefined_; }
61
63 const Location& location( ) const { return this->loc; }
64
65 operator Opm::EclIO::SummaryNode() const {
66 return { keyword_, category_, type_, name_, number_, "", -1, -1, -1, std::numeric_limits<size_t>::max() };
67 }
68
69 template<class Serializer>
70 void serializeOp(Serializer& serializer)
71 {
72 serializer(keyword_);
73 serializer(category_);
74 loc.serializeOp(serializer);
75 serializer(type_);
76 serializer(name_);
77 serializer(number_);
78 serializer(userDefined_);
79 }
80
81 private:
82 std::string keyword_;
83 Category category_;
84 Location loc;
85 Type type_{ Type::Undefined };
86 std::string name_{};
87 int number_{std::numeric_limits<int>::min()};
88 bool userDefined_{false};
89 };
90
92
93 bool operator==(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
94 bool operator<(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
95
96 inline bool operator!=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
97 {
98 return ! (lhs == rhs);
99 }
100
101 inline bool operator<=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
102 {
103 return ! (rhs < lhs);
104 }
105
106 inline bool operator>(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
107 {
108 return rhs < lhs;
109 }
110
111 inline bool operator>=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
112 {
113 return ! (lhs < rhs);
114 }
115
116 class Deck;
117 class ErrorGuard;
118 class GridDims;
119 class ParseContext;
120 class Schedule;
121 class TableManager;
122
124 public:
126 typedef std::vector< keyword_type > keyword_list;
127 typedef keyword_list::const_iterator const_iterator;
128
129 SummaryConfig() = default;
131 const Schedule&,
132 const TableManager&,
133 const ParseContext&,
134 ErrorGuard&);
135
136 template <typename T>
138 const Schedule&,
139 const TableManager&,
140 const ParseContext&,
141 T&&);
142
144 const Schedule&,
145 const TableManager&);
146
148 const std::set<std::string>& shortKwds,
149 const std::set<std::string>& smryKwds);
150
152
155 size_t size() const;
158
159 /*
160 The hasKeyword() method will consult the internal set
161 'short_keywords', i.e. the query should be based on pure
162 keywords like 'WWCT' and 'BPR' - and *not* fully
163 identifiers like 'WWCT:OPX' and 'BPR:10,12,3'.
164 */
165 bool hasKeyword( const std::string& keyword ) const;
166
167 /*
168 The hasSummaryKey() method will look for fully
169 qualified keys like 'RPR:3' and 'BPR:10,15,20.
170 */
171 bool hasSummaryKey(const std::string& keyword ) const;
172 /*
173 Can be used to query if a certain 3D field, e.g. PRESSURE,
174 is required to calculate the summary variables.
175 */
176 bool require3DField( const std::string& keyword) const;
177 bool requireFIPNUM( ) const;
178
179 bool operator==(const SummaryConfig& data) const;
180
181 template<class Serializer>
182 void serializeOp(Serializer& serializer)
183 {
184 serializer.vector(keywords);
185 serializer(short_keywords);
186 serializer(summary_keywords);
187 }
188
189 bool createRunSummary() const {
190 return runSummaryConfig.create;
191 }
192
193 private:
194 SummaryConfig( const Deck& deck,
195 const Schedule& schedule,
196 const TableManager& tables,
197 const ParseContext& parseContext,
198 ErrorGuard& errors,
199 const GridDims& dims);
200
201 /*
202 The short_keywords set contains only the pure keyword
203 part, e.g. "WWCT", and not the qualification with
204 well/group name or a numerical value.
205 */
206 keyword_list keywords;
207 std::set<std::string> short_keywords;
208 std::set<std::string> summary_keywords;
209
210 struct {
211 bool create { false };
212 bool narrow { false };
213 bool separate { true };
214 } runSummaryConfig;
215
216 void handleProcessingInstruction(const std::string& keyword);
217 };
218
219} //namespace Opm
220
221#endif
const char *const name
Definition: cJSON.h:258
const char *const string
Definition: cJSON.h:170
Definition: Deck.hpp:115
Definition: ErrorGuard.hpp:29
Definition: GridDims.hpp:32
Definition: Location.hpp:25
void serializeOp(Serializer &serializer)
Definition: Location.hpp:51
Definition: ParseContext.hpp:84
Definition: Schedule.hpp:113
Definition: Serializer.hpp:38
Definition: SummaryConfig.hpp:40
Type type() const
Definition: SummaryConfig.hpp:57
SummaryConfigNode & namedEntity(std::string name)
bool isUserDefined() const
Definition: SummaryConfig.hpp:60
int number() const
Definition: SummaryConfig.hpp:59
SummaryConfigNode & isUserDefined(const bool userDefined)
const std::string & namedEntity() const
Definition: SummaryConfig.hpp:58
static SummaryConfigNode serializeObject()
const Location & location() const
Definition: SummaryConfig.hpp:63
SummaryConfigNode & number(const int num)
SummaryConfigNode(std::string keyword, const Category cat, Location loc_arg)
void serializeOp(Serializer &serializer)
Definition: SummaryConfig.hpp:70
Category category() const
Definition: SummaryConfig.hpp:56
SummaryConfigNode & parameterType(const Type type)
std::string uniqueNodeKey() const
Opm::EclIO::SummaryNode::Type Type
Definition: SummaryConfig.hpp:43
Opm::EclIO::SummaryNode::Category Category
Definition: SummaryConfig.hpp:42
const std::string & keyword() const
Definition: SummaryConfig.hpp:55
Definition: SummaryConfig.hpp:123
bool create
Definition: SummaryConfig.hpp:211
SummaryConfig(const keyword_list &kwds, const std::set< std::string > &shortKwds, const std::set< std::string > &smryKwds)
bool require3DField(const std::string &keyword) const
std::vector< keyword_type > keyword_list
Definition: SummaryConfig.hpp:126
static SummaryConfig serializeObject()
bool requireFIPNUM() const
void serializeOp(Serializer &serializer)
Definition: SummaryConfig.hpp:182
bool hasSummaryKey(const std::string &keyword) const
SummaryConfig(const Deck &, const Schedule &, const TableManager &, const ParseContext &, T &&)
SummaryConfig & merge(SummaryConfig &&)
bool separate
Definition: SummaryConfig.hpp:213
const_iterator begin() const
bool operator==(const SummaryConfig &data) const
size_t size() const
keyword_list::const_iterator const_iterator
Definition: SummaryConfig.hpp:127
bool createRunSummary() const
Definition: SummaryConfig.hpp:189
bool narrow
Definition: SummaryConfig.hpp:212
bool hasKeyword(const std::string &keyword) const
SummaryConfig(const Deck &, const Schedule &, const TableManager &)
SummaryConfig(const Deck &, const Schedule &, const TableManager &, const ParseContext &, ErrorGuard &)
SummaryConfig()=default
SummaryConfig & merge(const SummaryConfig &)
SummaryConfigNode keyword_type
Definition: SummaryConfig.hpp:125
const_iterator end() const
Definition: TableManager.hpp:63
UDAKeyword keyword(UDAControl control)
Definition: A.hpp:4
bool operator==(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
bool operator<(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
bool operator<=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Definition: SummaryConfig.hpp:101
bool operator>(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Definition: SummaryConfig.hpp:106
bool operator>=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Definition: SummaryConfig.hpp:111
bool operator!=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Definition: SummaryConfig.hpp:96
SummaryConfigNode::Category parseKeywordCategory(const std::string &keyword)
T min(const T v0, const T v1)
Definition: exprtk.hpp:1400
T max(const T v0, const T v1)
Definition: exprtk.hpp:1407
static std::string data()
Definition: exprtk.hpp:40022
Definition: SummaryNode.hpp:30
Category
Definition: SummaryNode.hpp:31
Type
Definition: SummaryNode.hpp:48