opm-common
Loading...
Searching...
No Matches
ParseContext.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_PARSE_CONTEXT_HPP
21#define OPM_PARSE_CONTEXT_HPP
22
23#include <map>
24#include <optional>
25#include <set>
26#include <string>
27#include <utility>
28#include <vector>
29
30namespace Opm {
31
32enum class InputErrorAction;
33
34class ErrorGuard;
35class KeywordLocation;
36
37} // namespace Opm
38
39namespace Opm {
40
115 {
116 public:
122 ParseContext();
123
132 explicit ParseContext(InputErrorAction default_action);
133
144 explicit ParseContext(const std::vector<std::pair<std::string, InputErrorAction>>& initial);
145
166 void handleError(const std::string& errorKey,
167 const std::string& msg,
168 const std::optional<KeywordLocation>& location,
169 ErrorGuard& errors) const;
170
184 void handleUnknownKeyword(const std::string& keyword,
185 const std::optional<KeywordLocation>& location,
186 ErrorGuard& errors) const;
187
194 bool hasKey(const std::string& key) const;
195
204 void updateKey(const std::string& key, InputErrorAction action);
205
209 void update(InputErrorAction action);
210
236 void update(const std::string& keyString, InputErrorAction action);
237
250 void ignoreKeyword(const std::string& keyword);
251
257 InputErrorAction get(const std::string& key) const;
258
268 void addKey(const std::string& key, InputErrorAction default_action);
269
287 void setInputSkipMode(const std::string& skip_mode);
288
297 bool isActiveSkipKeyword(const std::string& deck_name) const;
298
316 const static std::string PARSE_EXTRA_RECORDS;
317
334 const static std::string PARSE_UNKNOWN_KEYWORD;
335
338 const static std::string PARSE_RANDOM_TEXT;
339
343 const static std::string PARSE_RANDOM_SLASH;
344
355 const static std::string PARSE_MISSING_DIMS_KEYWORD;
356
363 const static std::string PARSE_EXTRA_DATA;
364
368 const static std::string PARSE_MISSING_INCLUDE;
369
374 const static std::string PARSE_INVALID_KEYWORD_COMBINATION;
375
378 const static std::string RUNSPEC_NUMWELLS_TOO_LARGE;
379
382 const static std::string RUNSPEC_CONNS_PER_WELL_TOO_LARGE;
383
386 const static std::string RUNSPEC_NUMGROUPS_TOO_LARGE;
387
390 const static std::string RUNSPEC_GROUPSIZE_TOO_LARGE;
391
394 const static std::string RUNSPEC_NUMMSW_TOO_LARGE;
395
398 const static std::string RUNSPEC_NUMSEG_PER_WELL_TOO_LARGE;
399
402 const static std::string RUNSPEC_NUMBRANCH_TOO_LARGE;
403
407 const static std::string PARSE_LONG_KEYWORD;
408
411 const static std::string UNIT_SYSTEM_MISMATCH;
412
416 const static std::string UNSUPPORTED_INITIAL_THPRES;
417
422 const static std::string UNSUPPORTED_TERMINATE_IF_BHP;
423
425 const static std::string UDQ_PARSE_ERROR;
426
429 const static std::string UDQ_TYPE_ERROR;
430
433 const static std::string UDQ_DEFINE_CANNOT_EVAL;
434
439 const static std::string INTERNAL_ERROR_UNINITIALIZED_THPRES;
440
444 const static std::string PARSE_MISSING_SECTIONS;
445
451 const static std::string PARSE_WGNAME_SPACE;
452
454 const static std::string SUMMARY_UNKNOWN_WELL;
455
457 const static std::string SUMMARY_UNKNOWN_GROUP;
458
460 const static std::string SUMMARY_UNKNOWN_NODE;
461
464 const static std::string SUMMARY_UNKNOWN_AQUIFER;
465
467 const static std::string SUMMARY_UNHANDLED_KEYWORD;
468
470 const static std::string SUMMARY_UNDEFINED_UDQ;
471
474 const static std::string SUMMARY_UDQ_MISSING_UNIT;
475
477 const static std::string SUMMARY_INVALID_FIPNUM;
478
480 const static std::string SUMMARY_EMPTY_REGION;
481
483 const static std::string SUMMARY_REGION_TOO_LARGE;
484
487 const static std::string SCHEDULE_INVALID_NAME;
488
489 // Only explicitly supported keywords can be included in an ACTIONX
490 // or PYACTION block. These categories control what should happen
491 // when encountering an illegal keyword in such blocks.
492
494 const static std::string ACTIONX_ILLEGAL_KEYWORD;
495
497 const static std::string PYACTION_ILLEGAL_KEYWORD;
498
500 const static std::string ACTIONX_CONDITION_ERROR;
501
503 const static std::string ACTIONX_NO_CONDITION;
504
538 const static std::string RPT_MIXED_STYLE;
539
541 const static std::string RPT_UNKNOWN_MNEMONIC;
542
544 const static std::string SCHEDULE_GROUP_ERROR;
545
547 const static std::string SCHEDULE_IGNORED_GUIDE_RATE;
548
552 const static std::string SCHEDULE_WELL_IN_FIELD_GROUP;
553
558 const static std::string SCHEDULE_COMPSEGS_INVALID;
559
563 const static std::string SCHEDULE_COMPSEGS_NOT_SUPPORTED;
564
566 const static std::string SCHEDULE_COMPDAT_INVALID;
567
569 const static std::string SCHEDULE_COMPDAT_ZERO_PERM;
570
577 const static std::string SCHEDULE_ICD_MISSING_SEGMENT;
578
582
583 // The SIMULATOR_KEYWORD_ categories are intended to define the
584 // parser behaviour for when the parser itself recognises an input
585 // keyword, but the simulator does not support the intended use of
586 // that keyword.
587
589 const static std::string SIMULATOR_KEYWORD_NOT_SUPPORTED;
590
594
596 const static std::string SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED;
597
601
602 private:
604 std::map<std::string, InputErrorAction> m_errorContexts{};
605
608 std::set<std::string> ignore_keywords{};
609
622 std::string m_input_skip_mode{"100"};
623
625 void initDefault();
626
636 void initEnv();
637
645 void envUpdate(const std::string& envVariable, InputErrorAction action);
646
654 void patternUpdate(const std::string& pattern, InputErrorAction action);
655 };
656
657} // namespace Opm
658
659#endif // OPM_PARSE_CONTEXT_HPP
Definition ErrorGuard.hpp:30
Definition KeywordLocation.hpp:27
static const std::string RUNSPEC_NUMMSW_TOO_LARGE
Dynamic number of multi-segmented wells exceeds maximum declared in RUNSPEC keyword WSEGDIMS (item 1)...
Definition ParseContext.hpp:394
static const std::string PARSE_RANDOM_TEXT
Random text is an input deck string not correctly formatted as a keyword heading.
Definition ParseContext.hpp:338
static const std::string UDQ_DEFINE_CANNOT_EVAL
Cannot evaluate the defining expression of a UDQ at the point of definition due to missing objects,...
Definition ParseContext.hpp:433
bool isActiveSkipKeyword(const std::string &deck_name) const
Whether or not a particular keyword activates keyword suppression.
Definition ParseContext.cpp:318
static const std::string RUNSPEC_NUMWELLS_TOO_LARGE
Dynamic number of wells exceeds maximum declared in RUNSPEC keyword WELLDIMS (item 1).
Definition ParseContext.hpp:378
static const std::string SIMULATOR_KEYWORD_NOT_SUPPORTED
Keyword that is not supported in the simulator.
Definition ParseContext.hpp:589
static const std::string PARSE_RANDOM_SLASH
It turns out that random '/'–i.e.
Definition ParseContext.hpp:343
static const std::string PARSE_MISSING_SECTIONS
If the deck does not have all sections, whence complete EclipseState and Schedule objects cannot be c...
Definition ParseContext.hpp:444
static const std::string SUMMARY_UNKNOWN_AQUIFER
Aquifer level summary vector references an unknown aquifer (analytic or numeric).
Definition ParseContext.hpp:464
void update(InputErrorAction action)
Reset action for all context categories.
Definition ParseContext.cpp:276
static const std::string SCHEDULE_GROUP_ERROR
Operation applied to incorrect/unknown group.
Definition ParseContext.hpp:544
static const std::string SUMMARY_UDQ_MISSING_UNIT
User-defined quantity does not have an associated unit of measure and will thus be reported without a...
Definition ParseContext.hpp:474
static const std::string PARSE_MISSING_INCLUDE
If an include file is not found we can configure the parser to continue reading.
Definition ParseContext.hpp:368
static const std::string RUNSPEC_CONNS_PER_WELL_TOO_LARGE
Dynamic number of connections per well exceeds maximum declared in RUNSPEC keyword WELLDIMS (item 2).
Definition ParseContext.hpp:382
void updateKey(const std::string &key, InputErrorAction action)
Reset action for particular context category.
Definition ParseContext.cpp:252
static const std::string SIMULATOR_KEYWORD_NOT_SUPPORTED_CRITICAL
Keyword that is not supported in the simulator, and which should be treated as a critical failure if ...
Definition ParseContext.hpp:593
static const std::string PARSE_UNKNOWN_KEYWORD
The unknown keyword category controls the parser's behaviour on encountering an unknown keyword.
Definition ParseContext.hpp:334
static const std::string UNIT_SYSTEM_MISMATCH
The unit system specified via the FILEUNIT keyword is different from the unit system used by the deck...
Definition ParseContext.hpp:411
bool hasKey(const std::string &key) const
Existence predicate for particular context category.
Definition ParseContext.cpp:212
static const std::string PARSE_MISSING_DIMS_KEYWORD
For some keywords the number of records (i.e., size) is given as an item in another keyword.
Definition ParseContext.hpp:355
ParseContext()
Default constructor.
Definition ParseContext.cpp:37
static const std::string PARSE_EXTRA_RECORDS
The PARSE_EXTRA_RECORDS field controls the parser's response to keywords whose size has been defined ...
Definition ParseContext.hpp:316
static const std::string SUMMARY_EMPTY_REGION
Summary vector references an empty region.
Definition ParseContext.hpp:480
static const std::string RUNSPEC_NUMBRANCH_TOO_LARGE
Dynamic number of branches exceeds maximum number declared in RUNSPEC keyword WSEGDIMS (item 3).
Definition ParseContext.hpp:402
static const std::string UNSUPPORTED_TERMINATE_IF_BHP
If the second item in the WHISTCTL keyword is set to YES.
Definition ParseContext.hpp:422
static const std::string RUNSPEC_GROUPSIZE_TOO_LARGE
Dynamic group size exceeds maximum number declared in RUNSPEC keyword WELLDIMS (item 4).
Definition ParseContext.hpp:390
static const std::string UDQ_TYPE_ERROR
Parser unable to establish a coherent UDQ set type for a user-defined quantity.
Definition ParseContext.hpp:429
static const std::string RPT_UNKNOWN_MNEMONIC
An unknown mnemonic in one of the RPT* keywords.
Definition ParseContext.hpp:541
void handleUnknownKeyword(const std::string &keyword, const std::optional< KeywordLocation > &location, ErrorGuard &errors) const
Handle an unknown keyword in the input stream.
Definition ParseContext.cpp:202
static const std::string SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED
Keyword item setting that is not supported in the simulator.
Definition ParseContext.hpp:596
static const std::string SCHEDULE_WELL_IN_FIELD_GROUP
Well parented directly to the FIELD group.
Definition ParseContext.hpp:552
void addKey(const std::string &key, InputErrorAction default_action)
Define action for user-specified category.
Definition ParseContext.cpp:217
InputErrorAction get(const std::string &key) const
Retrieve category action for particular context category.
Definition ParseContext.cpp:229
static const std::string SUMMARY_REGION_TOO_LARGE
Summary vector references an out-of-bounds region ID.
Definition ParseContext.hpp:483
static const std::string SUMMARY_INVALID_FIPNUM
Summary vector references an unknown FIP region.
Definition ParseContext.hpp:477
static const std::string UDQ_PARSE_ERROR
Parser fails to analyse the defining expression of a UDQ.
Definition ParseContext.hpp:425
static const std::string SCHEDULE_ICD_INCOMPATIBLE_PDROP_MODEL
ICD keyword (WSEGAICD, WSEGSICD, WSEGVALV) is not compatible with the pressure drop model chosen for ...
Definition ParseContext.hpp:581
void handleError(const std::string &errorKey, const std::string &msg, const std::optional< KeywordLocation > &location, ErrorGuard &errors) const
Handle an input error.
Definition ParseContext.cpp:154
static const std::string SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED_CRITICAL
Keyword item setting that is not supported in the simulator and which should be treated as a critical...
Definition ParseContext.hpp:600
static const std::string ACTIONX_ILLEGAL_KEYWORD
ACTIONX block uses an unsupported schedule keyword.
Definition ParseContext.hpp:494
static const std::string SCHEDULE_COMPDAT_INVALID
Connection data (COMPDAT keyword) invalid in some way.
Definition ParseContext.hpp:566
static const std::string ACTIONX_NO_CONDITION
Error flag marking that an ACTIONX has no condition.
Definition ParseContext.hpp:503
static const std::string ACTIONX_CONDITION_ERROR
Error flag marking parser errors ic ACTIONX conditions.
Definition ParseContext.hpp:500
static const std::string SCHEDULE_INVALID_NAME
A well or group name used before it has been fully defined through WELSPECS/COMPDAT/GRUPTREE.
Definition ParseContext.hpp:487
static const std::string SUMMARY_UNKNOWN_NODE
Summary vector references an unknown network node.
Definition ParseContext.hpp:460
void setInputSkipMode(const std::string &skip_mode)
Define how to handle simulator specific keyword suppression.
Definition ParseContext.cpp:313
static const std::string PYACTION_ILLEGAL_KEYWORD
PYACTION block uses an unsupported schedule keyword.
Definition ParseContext.hpp:497
static const std::string SUMMARY_UNKNOWN_GROUP
Group level summary vector references an unknown group.
Definition ParseContext.hpp:457
static const std::string UNSUPPORTED_INITIAL_THPRES
If the third item in the THPRES keyword is defaulted, the threshold pressure is inferred from the ini...
Definition ParseContext.hpp:416
static const std::string RPT_MIXED_STYLE
The RPTRST, RPTSOL and RPTSCHED keywords have two alternative forms.
Definition ParseContext.hpp:538
static const std::string PARSE_WGNAME_SPACE
When defining wells and groups with the WELSPECS and GRUPTREE keywords we do not allow leading or tra...
Definition ParseContext.hpp:451
static const std::string SCHEDULE_COMPSEGS_NOT_SUPPORTED
COMPSEGS definition not supported.
Definition ParseContext.hpp:563
static const std::string PARSE_LONG_KEYWORD
Should we allow keywords of length more than eight characters?
Definition ParseContext.hpp:407
static const std::string SUMMARY_UNHANDLED_KEYWORD
Summary vector name is unknown.
Definition ParseContext.hpp:467
static const std::string RUNSPEC_NUMGROUPS_TOO_LARGE
Dynamic number of groups exceeds maximum number declared in RUNSPEC keyword WELLDIMS (item 3).
Definition ParseContext.hpp:386
static const std::string INTERNAL_ERROR_UNINITIALIZED_THPRES
If the third item in the THPRES keyword is defaulted the threshold pressure is inferred from the init...
Definition ParseContext.hpp:439
static const std::string RUNSPEC_NUMSEG_PER_WELL_TOO_LARGE
Dynamic number of segments per MS well exceeds maximum declared in RUNSPEC keyword WSEGDIMS (item 2).
Definition ParseContext.hpp:398
static const std::string SCHEDULE_IGNORED_GUIDE_RATE
Explicitly supplied guide rate will be ignored.
Definition ParseContext.hpp:547
static const std::string PARSE_EXTRA_DATA
If the number of elements in the input record exceeds the number of items in the keyword configuratio...
Definition ParseContext.hpp:363
static const std::string SCHEDULE_ICD_MISSING_SEGMENT
ICD keyword (WSEGAICD, WSEGSICD, WSEGVALV) references a missing well segment.
Definition ParseContext.hpp:577
static const std::string SCHEDULE_COMPSEGS_INVALID
COMPSEGS data invalid in some way.
Definition ParseContext.hpp:558
static const std::string SCHEDULE_COMPDAT_ZERO_PERM
Connection in zero-permeability cell (COMPDAT keyword).
Definition ParseContext.hpp:569
static const std::string SUMMARY_UNDEFINED_UDQ
Summary vector references an undefined UDQ.
Definition ParseContext.hpp:470
static const std::string SUMMARY_UNKNOWN_WELL
Well level summary vector references an unknown well.
Definition ParseContext.hpp:454
static const std::string PARSE_INVALID_KEYWORD_COMBINATION
Certain keywords require, or prohibit, other specific keywords.
Definition ParseContext.hpp:374
void ignoreKeyword(const std::string &keyword)
Ignore particular unknown input keyword if encountered during parsing.
Definition ParseContext.cpp:149
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30