My Project
Loading...
Searching...
No Matches
RPTKeywordNormalisation.hpp
1/*
2 Copyright 2025 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 OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
21#define OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
22
23#include <functional>
24#include <initializer_list>
25#include <map>
26#include <string>
27#include <utility>
28#include <vector>
29
30namespace Opm {
31 class DeckKeyword;
32 class ErrorGuard;
33 class KeywordLocation;
34 class ParseContext;
35} // namespace Opm
36
37namespace Opm {
38
42{
43public:
45 using MnemonicMap = std::vector<std::pair<std::string, int>>;
46
49 using IntegerControlHandler = std::function<MnemonicMap(const std::vector<int>&)>;
50
52 using MnemonicPredicate = std::function<bool(const std::string&)>;
53
64 explicit RPTKeywordNormalisation(IntegerControlHandler integerControlHandler,
65 MnemonicPredicate isMnemonic)
66 : integerControlHandler_ { std::move(integerControlHandler) }
67 , isMnemonic_ { std::move(isMnemonic) }
68 {}
69
83 const ParseContext& parseContext,
84 ErrorGuard& errors) const;
85
86private:
89 IntegerControlHandler integerControlHandler_{};
90
93 MnemonicPredicate isMnemonic_{};
94
112 MnemonicMap parseMnemonics(const std::vector<std::string>& deckItems,
113 const KeywordLocation& location,
114 const ParseContext& parseContext,
115 ErrorGuard& errors) const;
116
139 MnemonicMap parseMixedStyle(const DeckKeyword& kw,
140 const ParseContext& parseContext,
141 ErrorGuard& errors) const;
142};
143
144} // namespace Opm
145
146#endif // OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
Definition DeckKeyword.hpp:36
Definition ErrorGuard.hpp:30
Definition ParseContext.hpp:84
Normalise disparate input sources into sequence of report keyword mnemonics and associate values.
Definition RPTKeywordNormalisation.hpp:42
std::vector< std::pair< std::string, int > > MnemonicMap
Mnemonic sequence. Preserves input ordering.
Definition RPTKeywordNormalisation.hpp:45
std::function< MnemonicMap(const std::vector< int > &)> IntegerControlHandler
Callback for translating a sequence of integer controls into a sequence of mnemonics.
Definition RPTKeywordNormalisation.hpp:49
MnemonicMap normaliseKeyword(const DeckKeyword &kw, const ParseContext &parseContext, ErrorGuard &errors) const
Normalise report keyword specification into sequence of mnemonics and associate integer values.
Definition RPTKeywordNormalisation.cpp:108
RPTKeywordNormalisation(IntegerControlHandler integerControlHandler, MnemonicPredicate isMnemonic)
Constructor.
Definition RPTKeywordNormalisation.hpp:64
std::function< bool(const std::string &)> MnemonicPredicate
Mnemonic validity predicate.
Definition RPTKeywordNormalisation.hpp:52
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30