My Project
Loading...
Searching...
No Matches
RPTConfig.hpp
1/*
2 Copyright 2020 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 RPT_CONFIG_HPP
21#define RPT_CONFIG_HPP
22
23#include <string>
24#include <unordered_map>
25#include <utility>
26#include <vector>
27
28namespace Opm {
29
30 class DeckKeyword;
31 class ParseContext;
32 class ErrorGuard;
33
34} // namespace Opm
35
36namespace Opm {
37
40{
41public:
46 RPTConfig() = default;
47
56 explicit RPTConfig(const DeckKeyword& keyword);
57
76 explicit RPTConfig(const DeckKeyword& keyword,
77 const RPTConfig* prev,
78 const ParseContext& parseContext,
79 ErrorGuard& errors);
80
89 bool contains(const std::string& key) const;
90
94 auto begin() const { return this->mnemonics_.begin(); }
95
99 auto end() const { return this->mnemonics_.end(); }
100
102 auto size() const { return this->mnemonics_.size(); }
103
112 unsigned& at(const std::string& key) { return this->mnemonics_.at(key); }
113
122 unsigned at(const std::string& key) const { return this->mnemonics_.at(key); }
123
130 bool operator==(const RPTConfig& other) const;
131
134
140 template<class Serializer>
141 void serializeOp(Serializer& serializer)
142 {
143 serializer(this->mnemonics_);
144 }
145
146private:
148 std::unordered_map<std::string, unsigned int> mnemonics_{};
149
154 void assignMnemonics(const std::vector<std::pair<std::string, int>>& mnemonics);
155};
156
157} // namespace Opm
158
159#endif // RPT_CONFIG_HPP
Definition DeckKeyword.hpp:36
Definition ErrorGuard.hpp:30
Definition ParseContext.hpp:84
Configuration manager for RPTSCHED and RPTSOL keywords.
Definition RPTConfig.hpp:40
RPTConfig()=default
Default constructor.
unsigned & at(const std::string &key)
Get read/write access to particular mnemonic value.
Definition RPTConfig.hpp:112
unsigned at(const std::string &key) const
Get read-only access to particular mnemonic value.
Definition RPTConfig.hpp:122
auto begin() const
Start of internal mnemonic sequence.
Definition RPTConfig.hpp:94
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition RPTConfig.hpp:141
auto end() const
End of internal mnemonic sequence.
Definition RPTConfig.hpp:99
static RPTConfig serializationTestObject()
Create a serialisation test object.
Definition RPTConfig.cpp:95
bool operator==(const RPTConfig &other) const
Equality predicate.
Definition RPTConfig.cpp:90
bool contains(const std::string &key) const
Mnemonic existence predicate.
Definition RPTConfig.cpp:85
auto size() const
Number of mnemonics in internal sequence.
Definition RPTConfig.hpp:102
Class for (de-)serializing.
Definition Serializer.hpp:94
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30