opm-common
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 <cstddef>
29#include <limits>
30#include <optional>
31#include <set>
32#include <string>
33#include <unordered_set>
34#include <vector>
35
36namespace Opm {
37 class AquiferConfig;
38 class Deck;
39 class EclipseState;
40 class ErrorGuard;
42 class GridDims;
43 class ParseContext;
44 class Schedule;
45} // namespace Opm
46
47namespace Opm {
48
55 {
56 public:
58 using Category = Opm::EclIO::SummaryNode::Category;
59
61 using Type = Opm::EclIO::SummaryNode::Type;
62
67 SummaryConfigNode() = default;
68
77 explicit SummaryConfigNode(std::string keyword,
78 const Category cat,
79 KeywordLocation loc_arg);
80
83
91
98 SummaryConfigNode& namedEntity(std::string name);
99
106 SummaryConfigNode& number(const int num);
107
114 SummaryConfigNode& isUserDefined(const bool userDefined);
115
122
124 const std::string& keyword() const { return this->keyword_; }
125
127 Category category() const { return this->category_; }
128
130 Type type() const { return this->type_; }
131
133 const std::string& namedEntity() const { return this->name_; }
134
136 int number() const { return this->number_; }
137
139 bool isUserDefined() const { return this->userDefined_; }
140
142 const std::string& fip_region() const { return *this->fip_region_ ; }
143
145 std::string uniqueNodeKey() const;
146
150 const KeywordLocation& location() const { return this->loc; }
151
153 operator EclIO::SummaryNode() const
154 {
155 return {
156 /* keyword = */ this->keyword_,
157 /* category = */ this->category_,
158 /* type = */ this->type_,
159 /* wgname = */ this->name_,
160 /* number = */ this->number_,
161 /* fip_region = */ this->fip_region_,
162 /* lgr = */ {} // std::optional<>
163 };
164 }
165
171 template<class Serializer>
172 void serializeOp(Serializer& serializer)
173 {
174 serializer(keyword_);
175 serializer(category_);
176 serializer(loc);
177 serializer(type_);
178 serializer(name_);
179 serializer(number_);
180 serializer(fip_region_);
181 serializer(userDefined_);
182 }
183
184 private:
186 std::string keyword_{};
187
189 Category category_{};
190
192 Type type_{ Type::Undefined };
193
195 std::string name_{};
196
201 int number_{std::numeric_limits<int>::min()};
202
204 std::optional<std::string> fip_region_{};
205
207 bool userDefined_{false};
208
212 KeywordLocation loc{};
213 };
214
222
230
238 bool operator==(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
239
247 bool operator<(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
248
256 inline bool operator!=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
257 {
258 return ! (lhs == rhs);
259 }
260
268 inline bool operator<=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
269 {
270 return ! (rhs < lhs);
271 }
272
280 inline bool operator>(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
281 {
282 return rhs < lhs;
283 }
284
292 inline bool operator>=(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs)
293 {
294 return ! (lhs < rhs);
295 }
296
299 {
300 public:
303 using keyword_list = std::vector<SummaryConfigNode>;
304
306 SummaryConfig() = default;
307
336 SummaryConfig(const Deck& deck,
337 const Schedule& schedule,
338 const FieldPropsManager& field_props,
339 const AquiferConfig& aquiferConfig,
340 const ParseContext& parseContext,
341 ErrorGuard& errors);
342
377 template <typename T>
378 SummaryConfig(const Deck& deck,
379 const Schedule& schedule,
380 const FieldPropsManager& field_props,
381 const AquiferConfig& aquiferConfig,
382 const ParseContext& parseContext,
383 T&& errors);
384
408 SummaryConfig(const Deck& deck,
409 const Schedule& schedule,
410 const FieldPropsManager& field_props,
411 const AquiferConfig& aquiferConfig);
412
424 const std::set<std::string>& shortKwds,
425 const std::set<std::string>& smryKwds);
426
429
433 auto begin() const { return this->m_keywords.begin(); }
434
438 auto end() const { return this->m_keywords.end(); }
439
441 std::size_t size() const { return this->m_keywords.size(); }
442
449
460
481 registerRequisiteUDQorActionSummaryKeys(const std::vector<std::string>& extraKeys,
482 const EclipseState& es,
483 const Schedule& sched);
484
493 bool hasKeyword(const std::string& keyword) const;
494
505 bool match(const std::string& keywordPattern) const;
506
516 keyword_list keywords(const std::string& keywordPattern) const;
517
524 bool hasSummaryKey(const std::string& key) const;
525
534 bool require3DField(const std::string& keyword) const;
535
537 std::set<std::string> fip_regions() const;
538
540 std::set<std::string> fip_regions_interreg_flow() const;
541
548 bool operator==(const SummaryConfig& data) const;
549
555 template<class Serializer>
556 void serializeOp(Serializer& serializer)
557 {
558 serializer(m_keywords);
559 serializer(short_keywords);
560 serializer(summary_keywords);
561 }
562
565 bool createRunSummary() const
566 { return runSummaryConfig.create; }
567
574 const SummaryConfigNode& operator[](std::size_t index) const;
575
576 private:
611 SummaryConfig(const Deck& deck,
612 const Schedule& schedule,
613 const FieldPropsManager& field_props,
614 const AquiferConfig& aquiferConfig,
615 const ParseContext& parseContext,
616 ErrorGuard& errors,
617 const GridDims& dims);
618
620 keyword_list m_keywords{};
621
627 std::set<std::string> short_keywords{};
628
630 std::set<std::string> summary_keywords{};
631
633 struct {
636 bool create { false };
637
641 bool narrow { false };
642
647 bool separate { true };
648 } runSummaryConfig{};
649
658 void handleProcessingInstruction(const std::string& keyword);
659 };
660
661} // namespace Opm
662
663#endif // OPM_SUMMARY_CONFIG_HPP
Definition AquiferConfig.hpp:46
Definition Deck.hpp:46
Definition EclipseState.hpp:66
Definition ErrorGuard.hpp:30
Definition FieldPropsManager.hpp:42
Definition GridDims.hpp:31
Definition KeywordLocation.hpp:27
Control parser behaviour in failure conditions.
Definition ParseContext.hpp:115
Definition Schedule.hpp:101
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition of a single summary vector.
Definition SummaryConfig.hpp:55
SummaryConfigNode()=default
Default constructor.
Type type() const
Retrieve summary vector's type.
Definition SummaryConfig.hpp:130
static SummaryConfigNode serializationTestObject()
Create a serialisation test object.
SummaryConfigNode & namedEntity(std::string name)
Assign vector's named entity.
SummaryConfigNode(std::string keyword, const Category cat, KeywordLocation loc_arg)
Constructor.
bool isUserDefined() const
Retrieve summary vector's UDQ flag.
Definition SummaryConfig.hpp:139
int number() const
Retrieve summary vector's associated numeric ID.
Definition SummaryConfig.hpp:136
const KeywordLocation & location() const
Retrieve summary keyword location in input.
Definition SummaryConfig.hpp:150
SummaryConfigNode & isUserDefined(const bool userDefined)
Assign vector's UDQ flag.
const std::string & namedEntity() const
Retrieve summary vector's named entity.
Definition SummaryConfig.hpp:133
const std::string & fip_region() const
Retrieve summary vector's associated region.
Definition SummaryConfig.hpp:142
SummaryConfigNode & number(const int num)
Assign vector's numeric ID.
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition SummaryConfig.hpp:172
SummaryConfigNode & fip_region(const std::string &fip_region)
Assign vector's associated region name.
Category category() const
Retrieve summary vector's level.
Definition SummaryConfig.hpp:127
SummaryConfigNode & parameterType(const Type type)
Assign vector type.
std::string uniqueNodeKey() const
Retrieve a unique distinguishing identifier for this summary vector.
Opm::EclIO::SummaryNode::Type Type
Summary vector type (rates, cumulative, pressure, &c).
Definition SummaryConfig.hpp:61
Opm::EclIO::SummaryNode::Category Category
Summary vector level (field, well, region, &c).
Definition SummaryConfig.hpp:58
const std::string & keyword() const
Retrieve summary vector name.
Definition SummaryConfig.hpp:124
bool create
Whether or not to create a human-readable .RSM file at the end of the simulation run.
Definition SummaryConfig.hpp:636
SummaryConfig(const Deck &deck, const Schedule &schedule, const FieldPropsManager &field_props, const AquiferConfig &aquiferConfig)
Constructor.
std::set< std::string > fip_regions() const
Named region sets needed across all known region level vectors.
bool require3DField(const std::string &keyword) const
Query whether or not a 3D dynamic property is needed to evaluate some/all summary vectors.
keyword_list keywords(const std::string &keywordPattern) const
Retrieve all vector definitions matching a vector name pattern.
const SummaryConfigNode & operator[](std::size_t index) const
Retrieve summary vector definition from linear index.
SummaryConfig & merge(SummaryConfig &&other)
Incorporate other vector collection into current.
SummaryConfig & merge(const SummaryConfig &other)
Incorporate other vector collection into current.
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition SummaryConfig.hpp:556
std::set< std::string > fip_regions_interreg_flow() const
Named region sets needed across all known inter-region vectors.
std::vector< SummaryConfigNode > keyword_list
Convenience type alias for a linear sequence of summary vector definitions.
Definition SummaryConfig.hpp:303
bool separate
Whether or not to create a separate .RSM file instead of placing the run summary at the end of the ....
Definition SummaryConfig.hpp:647
SummaryConfig(const Deck &deck, const Schedule &schedule, const FieldPropsManager &field_props, const AquiferConfig &aquiferConfig, const ParseContext &parseContext, ErrorGuard &errors)
Constructor.
static SummaryConfig serializationTestObject()
Create a serialisation test object.
SummaryConfig(const keyword_list &keywords, const std::set< std::string > &shortKwds, const std::set< std::string > &smryKwds)
Constructor.
bool operator==(const SummaryConfig &data) const
Equality predicate.
std::size_t size() const
Number of summary vectors in current collection.
Definition SummaryConfig.hpp:441
bool match(const std::string &keywordPattern) const
Query existence of summary vector name with pattern matching.
auto end() const
One past the end of the sequence of summary vector definitions.
Definition SummaryConfig.hpp:438
bool createRunSummary() const
Whether or not to create a human-readable .RSM file at the end of the simulation run.
Definition SummaryConfig.hpp:565
bool narrow
Whether or not to output the .RSM file in "narrow" format.
Definition SummaryConfig.hpp:641
bool hasKeyword(const std::string &keyword) const
Query existence of summary vector name.
SummaryConfig()=default
Default constructor.
bool hasSummaryKey(const std::string &key) const
Query existence of fully qualified summary vector key.
auto begin() const
Beginning of sequence of summary vector definitions.
Definition SummaryConfig.hpp:433
keyword_list registerRequisiteUDQorActionSummaryKeys(const std::vector< std::string > &extraKeys, const EclipseState &es, const Schedule &sched)
Form definitions from vectors used in UDQs and ACTIONX.
SummaryConfig(const Deck &deck, const Schedule &schedule, const FieldPropsManager &field_props, const AquiferConfig &aquiferConfig, const ParseContext &parseContext, T &&errors)
Constructor.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
bool operator<(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Canonical comparison operator for SummaryConfigNode objects.
SummaryConfigNode::Type parseKeywordType(std::string keyword)
Infer summary vector type from keyword name.
bool operator<=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Less-than-or-equal comparison operator for SummaryConfigNode objects.
Definition SummaryConfig.hpp:268
bool operator>(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Greater-than comparison operator for SummaryConfigNode objects.
Definition SummaryConfig.hpp:280
bool operator>=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Greater-than-or-equal comparison operator for SummaryConfigNode objects.
Definition SummaryConfig.hpp:292
bool operator!=(const SummaryConfigNode &lhs, const SummaryConfigNode &rhs)
Inequality operator for SummaryConfigNode objects.
Definition SummaryConfig.hpp:256
SummaryConfigNode::Category parseKeywordCategory(const std::string &keyword)
Infer summary vector level from keyword name.
Definition SummaryNode.hpp:36