Loading...
Searching...
No Matches
RPTKeywordNormalisation.hpp
/*
Copyright 2025 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
#define OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
#include <functional>
#include <initializer_list>
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace Opm {
class DeckKeyword;
class ErrorGuard;
class KeywordLocation;
class ParseContext;
} // namespace Opm
namespace Opm {
class RPTKeywordNormalisation
{
public:
using MnemonicMap = std::vector<std::pair<std::string, int>>;
using IntegerControlHandler = std::function<MnemonicMap(const std::vector<int>&)>;
using MnemonicPredicate = std::function<bool(const std::string&)>;
explicit RPTKeywordNormalisation(IntegerControlHandler integerControlHandler,
MnemonicPredicate isMnemonic)
: integerControlHandler_ { std::move(integerControlHandler) }
, isMnemonic_ { std::move(isMnemonic) }
{}
MnemonicMap normaliseKeyword(const DeckKeyword& kw,
const ParseContext& parseContext,
ErrorGuard& errors) const;
private:
IntegerControlHandler integerControlHandler_{};
MnemonicPredicate isMnemonic_{};
MnemonicMap parseMnemonics(const std::vector<std::string>& deckItems,
const KeywordLocation& location,
const ParseContext& parseContext,
ErrorGuard& errors) const;
MnemonicMap parseMixedStyle(const DeckKeyword& kw,
const ParseContext& parseContext,
ErrorGuard& errors) const;
};
} // namespace Opm
#endif // OPM_RPT_KEYWORD_NORMALISATION_HPP_INCLUDED
Opm::DeckKeyword
Definition DeckKeyword.hpp:36
Opm::ErrorGuard
Definition ErrorGuard.hpp:30
Opm::KeywordLocation
Definition KeywordLocation.hpp:27
Opm::ParseContext
Definition ParseContext.hpp:84
Opm::RPTKeywordNormalisation::IntegerControlHandler
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
Opm::RPTKeywordNormalisation::MnemonicMap
std::vector< std::pair< std::string, int > > MnemonicMap
Mnemonic sequence. Preserves input ordering.
Definition RPTKeywordNormalisation.hpp:45
Opm::RPTKeywordNormalisation::normaliseKeyword
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
Opm::RPTKeywordNormalisation::RPTKeywordNormalisation
RPTKeywordNormalisation(IntegerControlHandler integerControlHandler, MnemonicPredicate isMnemonic)
Constructor.
Definition RPTKeywordNormalisation.hpp:64
Opm::RPTKeywordNormalisation::MnemonicPredicate
std::function< bool(const std::string &)> MnemonicPredicate
Mnemonic validity predicate.
Definition RPTKeywordNormalisation.hpp:52
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30