20 #ifndef OPM_KEYWORDVALIDATION_HEADER_INCLUDED 21 #define OPM_KEYWORDVALIDATION_HEADER_INCLUDED 23 #include <opm/input/eclipse/Deck/DeckItem.hpp> 24 #include <opm/common/OpmLog/KeywordLocation.hpp> 25 #include <opm/simulators/flow/ValidationFunctions.hpp> 30 #include <initializer_list> 34 #include <unordered_map> 45 namespace KeywordValidation
50 std::optional<std::string> message;
57 std::function<bool(T)> validator;
58 std::optional<std::string> message;
62 using UnsupportedKeywords = std::map<std::string, UnsupportedKeywordProperties>;
66 using SupportedSingleKeywordItems = std::map<std::size_t, SupportedKeywordProperties<T>>;
70 using SupportedKeywordItems = std::map<std::string, SupportedSingleKeywordItems<T>>;
77 KeywordLocation location;
78 std::size_t record_number;
79 std::optional<std::size_t> item_number;
80 std::optional<std::string> item_value;
81 std::optional<std::string> user_message;
88 std::string get_error_report(
const std::vector<ValidationError>& errors,
89 const bool include_noncritical,
90 const bool include_critical);
93 const SupportedKeywordItems<std::string> string_items;
94 const SupportedKeywordItems<int> int_items;
95 const SupportedKeywordItems<double> double_items;
104 const std::unordered_map<std::string, ValidationFunction>& special_validation)
105 : m_unsupported_keywords(unsupported_keywords)
106 , m_partially_supported_keywords(partially_supported_keywords)
107 , m_fully_supported_keywords(fully_supported_keywords)
108 , m_special_validation(special_validation)
117 void validateDeck(
const Deck& deck,
118 const ParseContext& parse_context,
119 const bool treat_critical_as_noncritical,
120 ErrorGuard& error_guard)
const;
124 void validateDeckKeyword(
const DeckKeyword& keyword, std::vector<ValidationError>& errors)
const;
127 template <
typename T>
128 void validateKeywordItem(
const DeckKeyword& keyword,
130 const bool multiple_records,
131 const std::size_t record_number,
132 const std::size_t item_number,
134 std::vector<ValidationError>& errors)
const;
136 void validateKeywordItems(
const DeckKeyword& keyword,
138 std::vector<ValidationError>& errors)
const;
140 template <
typename T>
141 void validateKeywordItems(
const DeckKeyword& keyword,
142 const SupportedKeywordItems<T>& supported_options,
143 std::vector<ValidationError>& errors)
const;
145 const UnsupportedKeywords m_unsupported_keywords;
148 const std::unordered_map<std::string, ValidationFunction> m_special_validation;
153 template <
typename T>
157 allow_values(
const std::initializer_list<T>& allowed_values)
159 std::ranges::copy(allowed_values, std::back_inserter(m_allowed_values));
162 bool operator()(
const T& value)
const 164 return std::ranges::find(m_allowed_values, value) != m_allowed_values.end();
168 std::vector<T> m_allowed_values;
174 bool operator()(
const std::string& value)
const {
176 return DeckItem::to_bool(value) ||
true;
177 }
catch (
const std::invalid_argument& e) {
Definition: KeywordValidation.hpp:92
Definition: KeywordValidation.hpp:98
Definition: KeywordValidation.hpp:172
Definition: KeywordValidation.hpp:55
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Definition: KeywordValidation.hpp:154
Definition: KeywordValidation.hpp:75
Definition: KeywordValidation.hpp:48