Added ErrorGuard& arguments to library
This commit is contained in:
parent
ad001df804
commit
bf52e6d123
@ -21,6 +21,7 @@
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
@ -30,16 +31,16 @@
|
||||
|
||||
inline void loadDeck( const char * deck_file) {
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::ErrorGuard errors;
|
||||
Opm::Parser parser;
|
||||
|
||||
std::cout << "Loading deck: " << deck_file << " ..... "; std::cout.flush();
|
||||
auto deck = parser.parseFile(deck_file, parseContext);
|
||||
auto deck = parser.parseFile(deck_file, parseContext, errors);
|
||||
std::cout << "parse complete - creating EclipseState .... "; std::cout.flush();
|
||||
Opm::EclipseState state( deck, parseContext );
|
||||
Opm::Schedule schedule( deck, state.getInputGrid(), state.get3DProperties(), state.runspec(), parseContext);
|
||||
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext );
|
||||
Opm::EclipseState state( deck, parseContext, errors );
|
||||
Opm::Schedule schedule( deck, state.getInputGrid(), state.get3DProperties(), state.runspec(), parseContext, errors);
|
||||
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext, errors );
|
||||
std::cout << "complete." << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@ -29,9 +30,10 @@
|
||||
|
||||
inline void pack_deck( const char * deck_file, std::ostream& os) {
|
||||
Opm::ParseContext parseContext(Opm::InputError::WARN);
|
||||
Opm::ErrorGuard errors;
|
||||
Opm::Parser parser;
|
||||
|
||||
auto deck = parser.parseFile(deck_file, parseContext);
|
||||
auto deck = parser.parseFile(deck_file, parseContext, errors);
|
||||
os << deck;
|
||||
|
||||
}
|
||||
|
@ -30,11 +30,12 @@ namespace Opm {
|
||||
|
||||
class Deck;
|
||||
class ParseContext;
|
||||
class ErrorGuard;
|
||||
|
||||
class EclipseConfig
|
||||
{
|
||||
public:
|
||||
EclipseConfig(const Deck& deck, const ParseContext& parseContext);
|
||||
EclipseConfig(const Deck& deck, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
|
||||
const InitConfig& init() const;
|
||||
const IOConfig& io() const;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseConfig.hpp>
|
||||
@ -65,7 +66,7 @@ namespace Opm {
|
||||
AllProperties = IntProperties | DoubleProperties
|
||||
};
|
||||
|
||||
EclipseState(const Deck& deck , const ParseContext& parseContext = ParseContext());
|
||||
EclipseState(const Deck& deck , const ParseContext& parseContext, ErrorGuard& errors);
|
||||
|
||||
const IOConfig& getIOConfig() const;
|
||||
IOConfig& getIOConfig();
|
||||
|
@ -201,6 +201,7 @@ namespace Opm {
|
||||
class TimeMap;
|
||||
class Schedule;
|
||||
class ParseContext;
|
||||
class ErrorGuard;
|
||||
|
||||
/*The IOConfig class holds data about input / ouput configurations
|
||||
|
||||
@ -317,10 +318,11 @@ namespace Opm {
|
||||
public:
|
||||
|
||||
RestartConfig();
|
||||
explicit RestartConfig( const Deck&, const ParseContext& parseContext );
|
||||
RestartConfig( const Deck&, const ParseContext& parseContext, ErrorGuard& errors );
|
||||
RestartConfig( const SCHEDULESection& schedule,
|
||||
const SOLUTIONSection& solution,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
TimeMap timemap );
|
||||
|
||||
|
||||
@ -330,7 +332,7 @@ namespace Opm {
|
||||
int getKeyword( const std::string& keyword, size_t timeStep) const;
|
||||
|
||||
void overrideRestartWriteInterval(size_t interval);
|
||||
void handleSolutionSection(const SOLUTIONSection& solutionSection, const ParseContext& parseContext);
|
||||
void handleSolutionSection(const SOLUTIONSection& solutionSection, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void setWriteInitialRestartFile(bool writeInitialRestartFile);
|
||||
|
||||
RestartSchedule getNode( size_t timestep ) const;
|
||||
@ -357,7 +359,7 @@ namespace Opm {
|
||||
int m_first_restart_step;
|
||||
bool m_write_initial_RST_file = false;
|
||||
|
||||
void handleScheduleSection( const SCHEDULESection& schedule, const ParseContext& parseContext);
|
||||
void handleScheduleSection( const SCHEDULESection& schedule, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void update( size_t step, const RestartSchedule& rs);
|
||||
static RestartSchedule rptsched( const DeckKeyword& );
|
||||
|
||||
|
@ -57,6 +57,7 @@ namespace Opm
|
||||
class SummaryState;
|
||||
class TimeMap;
|
||||
class UnitSystem;
|
||||
class ErrorGuard;
|
||||
|
||||
class Schedule {
|
||||
public:
|
||||
@ -64,11 +65,13 @@ namespace Opm
|
||||
const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties,
|
||||
const Runspec &runspec,
|
||||
const ParseContext& parseContext = ParseContext());
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors);
|
||||
|
||||
Schedule(const Deck& deck,
|
||||
const EclipseState& es,
|
||||
const ParseContext& parseContext = ParseContext());
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors);
|
||||
|
||||
/*
|
||||
* If the input deck does not specify a start time, Eclipse's 1. Jan
|
||||
@ -120,7 +123,7 @@ namespace Opm
|
||||
std::vector< const Group* > getGroups(size_t timeStep) const;
|
||||
const Tuning& getTuning() const;
|
||||
const MessageLimits& getMessageLimits() const;
|
||||
void invalidNamePattern (const std::string& namePattern, const ParseContext& parseContext, const DeckKeyword& keyword) const;
|
||||
void invalidNamePattern (const std::string& namePattern, const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& keyword) const;
|
||||
|
||||
const Events& getEvents() const;
|
||||
const Deck& getModifierDeck(size_t timeStep) const;
|
||||
@ -158,41 +161,41 @@ namespace Opm
|
||||
|
||||
void updateWellStatus( Well& well, size_t reportStep , WellCommon::StatusEnum status);
|
||||
void addWellToGroup( Group& newGroup , Well& well , size_t timeStep);
|
||||
void iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& , const EclipseGrid& grid,
|
||||
void iterateScheduleSection(const ParseContext& parseContext , ErrorGuard& errors, const SCHEDULESection& , const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties);
|
||||
bool handleGroupFromWELSPECS(const std::string& groupName, GroupTree& newTree) const;
|
||||
void addGroup(const std::string& groupName , size_t timeStep);
|
||||
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder);
|
||||
void handleCOMPORD(const ParseContext& parseContext, const DeckKeyword& compordKeyword, size_t currentStep);
|
||||
void handleCOMPORD(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& compordKeyword, size_t currentStep);
|
||||
void handleWELSPECS( const SCHEDULESection&, size_t, size_t );
|
||||
void handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext);
|
||||
void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWGRUPCON( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, const ParseContext& parseContext);
|
||||
void handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleCOMPLUMP( const DeckKeyword& keyword, size_t currentStep );
|
||||
void handleWELSEGS( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleCOMPSEGS( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid);
|
||||
void handleWCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWTRACER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWPMITAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWSKPTAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWINJTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWCONINJH( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext );
|
||||
void handleWELTARG( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleGCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWTRACER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWPMITAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWSKPTAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWINJTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWCONINJH( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors );
|
||||
void handleWELTARG( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleGCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleTUNING( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleGRUPNET( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleWRFT( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleWTEST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWTEST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWRFTPLT( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleWPIMULT( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleDRSDT( const DeckKeyword& keyword, size_t currentStep);
|
||||
@ -200,8 +203,8 @@ namespace Opm
|
||||
void handleDRSDTR( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleDRVDTR( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleVAPPARS( const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext);
|
||||
void handleWHISTCTL(const ParseContext& parseContext, const DeckKeyword& keyword);
|
||||
void handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors);
|
||||
void handleWHISTCTL(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& keyword);
|
||||
void handleMESSAGES(const DeckKeyword& keyword, size_t currentStep);
|
||||
void handleVFPPROD(const DeckKeyword& vfpprodKeyword, const UnitSystem& unit_system, size_t currentStep);
|
||||
void handleVFPINJ(const DeckKeyword& vfpprodKeyword, const UnitSystem& unit_system, size_t currentStep);
|
||||
@ -211,7 +214,7 @@ namespace Opm
|
||||
const SCHEDULESection& section,
|
||||
size_t keywordIdx,
|
||||
const DeckKeyword& keyword,
|
||||
const ParseContext& parseContext,
|
||||
const ParseContext& parseContext, ErrorGuard& errors,
|
||||
const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties,
|
||||
const UnitSystem& unit_system,
|
||||
|
@ -99,6 +99,7 @@ namespace Opm {
|
||||
class EclipseState;
|
||||
class ParserKeyword;
|
||||
class Schedule;
|
||||
class ErrorGuard;
|
||||
class ParseContext;
|
||||
class GridDims;
|
||||
|
||||
@ -109,7 +110,7 @@ namespace Opm {
|
||||
typedef keyword_list::const_iterator const_iterator;
|
||||
|
||||
SummaryConfig( const Deck&, const Schedule&,
|
||||
const TableManager&, const ParseContext&);
|
||||
const TableManager&, const ParseContext&, ErrorGuard&);
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
@ -141,6 +142,7 @@ namespace Opm {
|
||||
const Schedule& schedule,
|
||||
const TableManager& tables,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const GridDims& dims);
|
||||
|
||||
/*
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
stderr and throw std::runtime_error.
|
||||
*/
|
||||
~ErrorGuard();
|
||||
void terminate() const;
|
||||
|
||||
private:
|
||||
void dump() const;
|
||||
|
@ -79,14 +79,16 @@ namespace Opm {
|
||||
recognizd keys will be allowed.
|
||||
*/
|
||||
|
||||
class ErrorGuard;
|
||||
|
||||
class ParseContext {
|
||||
public:
|
||||
ParseContext();
|
||||
explicit ParseContext(InputError::Action default_action);
|
||||
explicit ParseContext(const std::vector<std::pair<std::string , InputError::Action>>& initial);
|
||||
|
||||
void handleError( const std::string& errorKey, const std::string& msg ) const;
|
||||
void handleUnknownKeyword(const std::string& keyword) const;
|
||||
void handleError( const std::string& errorKey, const std::string& msg, ErrorGuard& errors ) const;
|
||||
void handleUnknownKeyword(const std::string& keyword, ErrorGuard& errors) const;
|
||||
bool hasKey(const std::string& key) const;
|
||||
ParseContext withKey(const std::string& key, InputError::Action action = InputError::WARN) const;
|
||||
ParseContext& withKey(const std::string& key, InputError::Action action = InputError::WARN);
|
||||
|
@ -39,6 +39,7 @@ namespace Opm {
|
||||
|
||||
class Deck;
|
||||
class ParseContext;
|
||||
class ErrorGuard;
|
||||
class RawKeyword;
|
||||
|
||||
/// The hub of the parsing process.
|
||||
@ -53,10 +54,14 @@ namespace Opm {
|
||||
|
||||
/// The starting point of the parsing process. The supplied file is parsed, and the resulting Deck is returned.
|
||||
Deck parseFile(const std::string &dataFile,
|
||||
const ParseContext& = ParseContext()) const;
|
||||
const ParseContext&,
|
||||
ErrorGuard& errors) const;
|
||||
|
||||
Deck parseString(const std::string &data,
|
||||
const ParseContext& = ParseContext()) const;
|
||||
Deck parseStream(std::unique_ptr<std::istream>&& inputStream , const ParseContext& parseContext) const;
|
||||
const ParseContext&,
|
||||
ErrorGuard& errors) const;
|
||||
|
||||
Deck parseStream(std::unique_ptr<std::istream>&& inputStream , const ParseContext& parseContext, ErrorGuard& errors) const;
|
||||
|
||||
/// Method to add ParserKeyword instances, these holding type and size information about the keywords and their data.
|
||||
void addParserKeyword(const Json::JsonObject& jsonKeyword);
|
||||
@ -90,27 +95,30 @@ namespace Opm {
|
||||
addParserKeyword( std::unique_ptr< ParserKeyword >( new T ) );
|
||||
}
|
||||
|
||||
static EclipseState parse(const Deck& deck, const ParseContext& context = ParseContext());
|
||||
static EclipseState parse(const std::string &filename, const ParseContext& context = ParseContext());
|
||||
static EclipseState parseData(const std::string &data, const ParseContext& context = ParseContext());
|
||||
static EclipseState parse(const Deck& deck, const ParseContext& context, ErrorGuard& errors);
|
||||
static EclipseState parse(const std::string &filename, const ParseContext& context, ErrorGuard& errors);
|
||||
static EclipseState parseData(const std::string &data, const ParseContext& context, ErrorGuard& errors);
|
||||
|
||||
/// Parses the deck specified in filename. If context contains ParseContext::PARSE_PARTIAL_DECK,
|
||||
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
|
||||
/// fully constructed InputGrid
|
||||
static EclipseGrid parseGrid(const std::string &filename,
|
||||
const ParseContext& context = ParseContext());
|
||||
const ParseContext& context,
|
||||
ErrorGuard& errors);
|
||||
|
||||
/// Parses the provided deck. If context contains ParseContext::PARSE_PARTIAL_DECK,
|
||||
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
|
||||
/// fully constructed InputGrid
|
||||
static EclipseGrid parseGrid(const Deck& deck,
|
||||
const ParseContext& context = ParseContext());
|
||||
const ParseContext& context,
|
||||
ErrorGuard& errors);
|
||||
|
||||
/// Parses the provided deck string. If context contains ParseContext::PARSE_PARTIAL_DECK,
|
||||
/// we construct only a lean grid, otherwise, we construct a full EclipseState and return the
|
||||
/// fully constructed InputGrid
|
||||
static EclipseGrid parseGridData(const std::string &data,
|
||||
const ParseContext& context = ParseContext());
|
||||
const ParseContext& context,
|
||||
ErrorGuard& errors);
|
||||
|
||||
private:
|
||||
// associative map of the parser internal name and the corresponding ParserKeyword object
|
||||
|
@ -37,9 +37,11 @@ namespace Opm {
|
||||
class Deck;
|
||||
class DeckKeyword;
|
||||
class ParseContext;
|
||||
class ErrorGuard;
|
||||
class ParserDoubleItem;
|
||||
class RawKeyword;
|
||||
class string_view;
|
||||
class ErrorGuard;
|
||||
|
||||
/*
|
||||
Small helper struct to assemble the information needed to infer the size
|
||||
@ -122,7 +124,7 @@ namespace Opm {
|
||||
SectionNameSet::const_iterator validSectionNamesBegin() const;
|
||||
SectionNameSet::const_iterator validSectionNamesEnd() const;
|
||||
|
||||
DeckKeyword parse(const ParseContext& parseContext , std::shared_ptr< RawKeyword > rawKeyword) const;
|
||||
DeckKeyword parse(const ParseContext& parseContext, ErrorGuard& errors, std::shared_ptr< RawKeyword > rawKeyword) const;
|
||||
enum ParserKeywordSizeEnum getSizeType() const;
|
||||
const KeywordSize& getKeywordSize() const;
|
||||
bool isDataKeyword() const;
|
||||
|
@ -33,6 +33,7 @@ namespace Opm {
|
||||
class ParseContext;
|
||||
class ParserItem;
|
||||
class RawRecord;
|
||||
class ErrorGuard;
|
||||
|
||||
class ParserRecord {
|
||||
public:
|
||||
@ -42,7 +43,7 @@ namespace Opm {
|
||||
void addDataItem( ParserItem item );
|
||||
const ParserItem& get(size_t index) const;
|
||||
const ParserItem& get(const std::string& itemName) const;
|
||||
DeckRecord parse( const ParseContext&, RawRecord& ) const;
|
||||
DeckRecord parse( const ParseContext&, ErrorGuard&, RawRecord&) const;
|
||||
bool isDataRecord() const;
|
||||
bool equal(const ParserRecord& other) const;
|
||||
bool hasDimension() const;
|
||||
|
@ -28,10 +28,10 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
EclipseConfig::EclipseConfig(const Deck& deck, const ParseContext& parseContext) :
|
||||
EclipseConfig::EclipseConfig(const Deck& deck, const ParseContext& parseContext, ErrorGuard& errors) :
|
||||
m_ioConfig( deck),
|
||||
m_initConfig( deck),
|
||||
m_restartConfig( deck, parseContext )
|
||||
m_restartConfig( deck, parseContext, errors )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -49,10 +49,10 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
EclipseState::EclipseState(const Deck& deck, const ParseContext& parseContext) :
|
||||
EclipseState::EclipseState(const Deck& deck, const ParseContext& parseContext, ErrorGuard& errors) :
|
||||
m_tables( deck ),
|
||||
m_runspec( deck ),
|
||||
m_eclipseConfig( deck, parseContext ),
|
||||
m_eclipseConfig( deck, parseContext, errors ),
|
||||
m_deckUnitSystem( deck.getActiveUnitSystem() ),
|
||||
m_inputNnc( deck ),
|
||||
m_inputEditNnc( deck ),
|
||||
|
@ -296,6 +296,7 @@ RPTSCHED_integer( const std::vector< int >& ints ) {
|
||||
template< typename F, typename G >
|
||||
inline std::map< std::string, int > RPT( const DeckKeyword& keyword,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
F is_mnemonic,
|
||||
G integer_mnemonic ) {
|
||||
|
||||
@ -318,7 +319,7 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword,
|
||||
|
||||
if (ints && strs) {
|
||||
std::string msg = "Mixed style input is not allowed for keyword: " + keyword.name() + " at " + keyword.getFileName() + "(" + std::to_string( keyword.getLineNumber() ) + ")";
|
||||
parseContext.handleError(ParseContext::RPT_MIXED_STYLE, msg);
|
||||
parseContext.handleError(ParseContext::RPT_MIXED_STYLE, msg, errors);
|
||||
|
||||
std::vector<std::string> stack;
|
||||
for (size_t index=0; index < deck_items.size(); index++) {
|
||||
@ -355,7 +356,7 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword,
|
||||
|
||||
std::string base = mnemonic.substr( 0, sep_pos );
|
||||
if( !is_mnemonic( base ) ) {
|
||||
parseContext.handleError(ParseContext::RPT_UNKNOWN_MNEMONIC, "The mnemonic: " + base + " is not recognized.");
|
||||
parseContext.handleError(ParseContext::RPT_UNKNOWN_MNEMONIC, "The mnemonic: " + base + " is not recognized.", errors);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -386,8 +387,8 @@ inline void expand_RPTRST_mnemonics(std::map< std::string, int >& mnemonics) {
|
||||
|
||||
|
||||
inline std::pair< std::map< std::string, int >, RestartSchedule >
|
||||
RPTRST( const DeckKeyword& keyword, const ParseContext& parseContext, RestartSchedule prev, size_t step ) {
|
||||
auto mnemonics = RPT( keyword, parseContext, is_RPTRST_mnemonic, RPTRST_integer );
|
||||
RPTRST( const DeckKeyword& keyword, const ParseContext& parseContext, ErrorGuard& errors, RestartSchedule prev, size_t step ) {
|
||||
auto mnemonics = RPT( keyword, parseContext, errors, is_RPTRST_mnemonic, RPTRST_integer );
|
||||
|
||||
const bool has_freq = mnemonics.find( "FREQ" ) != mnemonics.end();
|
||||
const bool has_basic = mnemonics.find( "BASIC" ) != mnemonics.end();
|
||||
@ -403,8 +404,8 @@ RPTRST( const DeckKeyword& keyword, const ParseContext& parseContext, RestartSch
|
||||
}
|
||||
|
||||
inline std::pair< std::map< std::string, int >, RestartSchedule >
|
||||
RPTSCHED( const DeckKeyword& keyword, const ParseContext& parseContext ) {
|
||||
auto mnemonics = RPT( keyword, parseContext, is_RPTSCHED_mnemonic, RPTSCHED_integer );
|
||||
RPTSCHED( const DeckKeyword& keyword, const ParseContext& parseContext, ErrorGuard& errors ) {
|
||||
auto mnemonics = RPT( keyword, parseContext, errors, is_RPTSCHED_mnemonic, RPTSCHED_integer );
|
||||
|
||||
if( mnemonics.count( "NOTHING" ) )
|
||||
return { std::move( mnemonics ), { RestartSchedule(0) } };
|
||||
@ -417,7 +418,7 @@ RPTSCHED( const DeckKeyword& keyword, const ParseContext& parseContext ) {
|
||||
|
||||
|
||||
|
||||
void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const ParseContext& parseContext) {
|
||||
void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
size_t current_step = 1;
|
||||
RestartSchedule unset;
|
||||
|
||||
@ -451,8 +452,8 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const
|
||||
const bool is_RPTRST = name == "RPTRST";
|
||||
const auto& prev_sched = this->restart_schedule.back();
|
||||
|
||||
auto config = is_RPTRST ? RPTRST( keyword, parseContext, prev_sched, current_step )
|
||||
: RPTSCHED( keyword , parseContext);
|
||||
auto config = is_RPTRST ? RPTRST( keyword, parseContext, errors, prev_sched, current_step )
|
||||
: RPTSCHED( keyword , parseContext, errors);
|
||||
|
||||
/* add the missing entries from the previous step */
|
||||
{
|
||||
@ -510,10 +511,11 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const
|
||||
|
||||
|
||||
|
||||
RestartConfig::RestartConfig( const Deck& deck, const ParseContext& parseContext ) :
|
||||
RestartConfig::RestartConfig( const Deck& deck, const ParseContext& parseContext, ErrorGuard& errors ) :
|
||||
RestartConfig( SCHEDULESection( deck ),
|
||||
SOLUTIONSection( deck ),
|
||||
parseContext,
|
||||
errors,
|
||||
TimeMap{ deck } )
|
||||
{}
|
||||
|
||||
@ -521,6 +523,7 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const
|
||||
RestartConfig::RestartConfig( const SCHEDULESection& schedule,
|
||||
const SOLUTIONSection& solution,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
TimeMap timemap) :
|
||||
m_timemap( std::move( timemap ) ),
|
||||
m_first_restart_step( -1 ),
|
||||
@ -528,8 +531,8 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const
|
||||
restart_keywords( m_timemap, {} ),
|
||||
save_keywords( m_timemap.size(), false )
|
||||
{
|
||||
handleSolutionSection( solution, parseContext );
|
||||
handleScheduleSection( schedule, parseContext );
|
||||
handleSolutionSection( solution, parseContext, errors );
|
||||
handleScheduleSection( schedule, parseContext, errors );
|
||||
|
||||
initFirstOutput( );
|
||||
}
|
||||
@ -600,11 +603,11 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule, const
|
||||
}
|
||||
|
||||
|
||||
void RestartConfig::handleSolutionSection(const SOLUTIONSection& solutionSection, const ParseContext& parseContext) {
|
||||
void RestartConfig::handleSolutionSection(const SOLUTIONSection& solutionSection, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
if (solutionSection.hasKeyword("RPTRST")) {
|
||||
const auto& rptrstkeyword = solutionSection.getKeyword("RPTRST");
|
||||
|
||||
const auto rptrst = RPTRST( rptrstkeyword, parseContext, {}, 0 );
|
||||
const auto rptrst = RPTRST( rptrstkeyword, parseContext, errors, {}, 0 );
|
||||
this->restart_keywords.updateInitial( rptrst.first );
|
||||
this->restart_schedule.updateInitial( rptrst.second );
|
||||
setWriteInitialRestartFile(true); // Guessing on eclipse rules for write of initial RESTART file (at time 0):
|
||||
|
@ -70,7 +70,8 @@ namespace Opm {
|
||||
const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties,
|
||||
const Runspec &runspec,
|
||||
const ParseContext& parseContext) :
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors) :
|
||||
m_timeMap( deck ),
|
||||
m_rootGroupTree( this->m_timeMap, GroupTree{} ),
|
||||
m_oilvaporizationproperties( this->m_timeMap, OilVaporizationProperties(runspec.tabdims().getNumPVTTables()) ),
|
||||
@ -99,16 +100,17 @@ namespace Opm {
|
||||
}
|
||||
|
||||
if (Section::hasSCHEDULE(deck))
|
||||
iterateScheduleSection( parseContext, SCHEDULESection( deck ), grid, eclipseProperties );
|
||||
iterateScheduleSection( parseContext, errors, SCHEDULESection( deck ), grid, eclipseProperties );
|
||||
}
|
||||
|
||||
|
||||
Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context) :
|
||||
Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& parse_context, ErrorGuard& errors) :
|
||||
Schedule(deck,
|
||||
es.getInputGrid(),
|
||||
es.get3DProperties(),
|
||||
es.runspec(),
|
||||
parse_context)
|
||||
parse_context,
|
||||
errors)
|
||||
{}
|
||||
|
||||
|
||||
@ -133,6 +135,7 @@ namespace Opm {
|
||||
size_t keywordIdx,
|
||||
const DeckKeyword& keyword,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties,
|
||||
const UnitSystem& unit_system,
|
||||
@ -175,49 +178,49 @@ namespace Opm {
|
||||
handleWELSPECS( section, keywordIdx, currentStep );
|
||||
|
||||
else if (keyword.name() == "WHISTCTL")
|
||||
handleWHISTCTL(parseContext, keyword);
|
||||
handleWHISTCTL(parseContext, errors, keyword);
|
||||
|
||||
else if (keyword.name() == "WCONHIST")
|
||||
handleWCONHIST(keyword, currentStep, parseContext);
|
||||
handleWCONHIST(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WCONPROD")
|
||||
handleWCONPROD(keyword, currentStep, parseContext);
|
||||
handleWCONPROD(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WCONINJE")
|
||||
handleWCONINJE(section, keyword, currentStep, parseContext);
|
||||
handleWCONINJE(section, keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WPOLYMER")
|
||||
handleWPOLYMER(keyword, currentStep, parseContext);
|
||||
handleWPOLYMER(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WSOLVENT")
|
||||
handleWSOLVENT(keyword, currentStep, parseContext);
|
||||
handleWSOLVENT(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WTRACER")
|
||||
handleWTRACER(keyword, currentStep, parseContext);
|
||||
handleWTRACER(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WTEST")
|
||||
handleWTEST(keyword, currentStep, parseContext);
|
||||
handleWTEST(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WTEMP")
|
||||
handleWTEMP(keyword, currentStep, parseContext);
|
||||
handleWTEMP(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WPMITAB")
|
||||
handleWPMITAB(keyword, currentStep, parseContext);
|
||||
handleWPMITAB(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WSKPTAB")
|
||||
handleWSKPTAB(keyword, currentStep, parseContext);
|
||||
handleWSKPTAB(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WINJTEMP")
|
||||
handleWINJTEMP(keyword, currentStep, parseContext);
|
||||
handleWINJTEMP(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WCONINJH")
|
||||
handleWCONINJH(section, keyword, currentStep, parseContext);
|
||||
handleWCONINJH(section, keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WGRUPCON")
|
||||
handleWGRUPCON(keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "COMPDAT")
|
||||
handleCOMPDAT(keyword, currentStep, grid, eclipseProperties, parseContext);
|
||||
handleCOMPDAT(keyword, currentStep, grid, eclipseProperties, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WELSEGS")
|
||||
handleWELSEGS(keyword, currentStep);
|
||||
@ -226,10 +229,10 @@ namespace Opm {
|
||||
handleCOMPSEGS(keyword, currentStep, grid);
|
||||
|
||||
else if (keyword.name() == "WELOPEN")
|
||||
handleWELOPEN(keyword, currentStep, parseContext);
|
||||
handleWELOPEN(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "WELTARG")
|
||||
handleWELTARG(section, keyword, currentStep, parseContext);
|
||||
handleWELTARG(section, keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "GRUPTREE")
|
||||
handleGRUPTREE(keyword, currentStep);
|
||||
@ -238,13 +241,13 @@ namespace Opm {
|
||||
handleGRUPNET(keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "GCONINJE")
|
||||
handleGCONINJE(section, keyword, currentStep, parseContext);
|
||||
handleGCONINJE(section, keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "GCONPROD")
|
||||
handleGCONPROD(keyword, currentStep, parseContext);
|
||||
handleGCONPROD(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "GEFAC")
|
||||
handleGEFAC(keyword, currentStep, parseContext);
|
||||
handleGEFAC(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "TUNING")
|
||||
handleTUNING(keyword, currentStep);
|
||||
@ -259,7 +262,7 @@ namespace Opm {
|
||||
handleWPIMULT(keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "COMPORD")
|
||||
handleCOMPORD(parseContext , keyword, currentStep);
|
||||
handleCOMPORD(parseContext, errors , keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "COMPLUMP")
|
||||
handleCOMPLUMP(keyword, currentStep);
|
||||
@ -280,13 +283,13 @@ namespace Opm {
|
||||
handleVAPPARS(keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "WECON")
|
||||
handleWECON(keyword, currentStep, parseContext);
|
||||
handleWECON(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "MESSAGES")
|
||||
handleMESSAGES(keyword, currentStep);
|
||||
|
||||
else if (keyword.name() == "WEFAC")
|
||||
handleWEFAC(keyword, currentStep, parseContext);
|
||||
handleWEFAC(keyword, currentStep, parseContext, errors);
|
||||
|
||||
else if (keyword.name() == "VFPINJ")
|
||||
handleVFPINJ(keyword, unit_system, currentStep);
|
||||
@ -301,13 +304,13 @@ namespace Opm {
|
||||
m_events.addEvent( ScheduleEvents::GEO_MODIFIER , currentStep);
|
||||
} else {
|
||||
std::string msg = "OPM does not support grid property modifier " + keyword.name() + " in the Schedule section. Error at report: " + std::to_string( currentStep );
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , msg );
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , msg, errors );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Schedule::iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& section , const EclipseGrid& grid,
|
||||
void Schedule::iterateScheduleSection(const ParseContext& parseContext , ErrorGuard& errors, const SCHEDULESection& section , const EclipseGrid& grid,
|
||||
const Eclipse3DProperties& eclipseProperties) {
|
||||
size_t currentStep = 0;
|
||||
const auto& unit_system = section.unitSystem();
|
||||
@ -329,13 +332,13 @@ namespace Opm {
|
||||
|
||||
if (actionx_whitelist.find(action_keyword.name()) == actionx_whitelist.end()) {
|
||||
std::string msg = "The keyword " + action_keyword.name() + " is not supported in a ACTIONX block.";
|
||||
parseContext.handleError( ParseContext::ACTIONX_ILLEGAL_KEYWORD, msg);
|
||||
parseContext.handleError( ParseContext::ACTIONX_ILLEGAL_KEYWORD, msg, errors);
|
||||
} else
|
||||
action.addKeyword(action_keyword);
|
||||
}
|
||||
this->actions.add(action);
|
||||
} else
|
||||
this->handleKeyword(currentStep, section, keywordIdx, keyword, parseContext, grid, eclipseProperties, unit_system, rftProperties);
|
||||
this->handleKeyword(currentStep, section, keywordIdx, keyword, parseContext, errors, grid, eclipseProperties, unit_system, rftProperties);
|
||||
|
||||
keywordIdx++;
|
||||
if (keywordIdx == section.size())
|
||||
@ -372,7 +375,7 @@ namespace Opm {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Schedule::handleWHISTCTL(const ParseContext& parseContext, const DeckKeyword& keyword) {
|
||||
void Schedule::handleWHISTCTL(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& keyword) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& cmodeString = record.getItem("CMODE").getTrimmedString(0);
|
||||
const WellProducer::ControlModeEnum controlMode = WellProducer::ControlModeFromString( cmodeString );
|
||||
@ -390,20 +393,20 @@ namespace Opm {
|
||||
if (bhp_terminate == "YES") {
|
||||
std::string msg = "The WHISTCTL keyword does not handle 'YES'. i.e. to terminate the run";
|
||||
OpmLog::error(msg);
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_TERMINATE_IF_BHP , msg );
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_TERMINATE_IF_BHP , msg, errors );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleCOMPORD(const ParseContext& parseContext, const DeckKeyword& compordKeyword, size_t /* currentStep */) {
|
||||
void Schedule::handleCOMPORD(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& compordKeyword, size_t /* currentStep */) {
|
||||
for (const auto& record : compordKeyword) {
|
||||
const auto& methodItem = record.getItem<ParserKeywords::COMPORD::ORDER_TYPE>();
|
||||
if ((methodItem.get< std::string >(0) != "TRACK") && (methodItem.get< std::string >(0) != "INPUT")) {
|
||||
std::string msg = "The COMPORD keyword only handles 'TRACK' or 'INPUT' order.";
|
||||
OpmLog::error(msg);
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_COMPORD_TYPE , msg );
|
||||
parseContext.handleError( ParseContext::UNSUPPORTED_COMPORD_TYPE , msg, errors );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -591,7 +594,7 @@ namespace Opm {
|
||||
this->m_oilvaporizationproperties.update( currentStep, ovp );
|
||||
}
|
||||
|
||||
void Schedule::handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext) {
|
||||
void Schedule::handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern =
|
||||
record.getItem("WELL").getTrimmedString(0);
|
||||
@ -601,7 +604,7 @@ namespace Opm {
|
||||
|
||||
auto wells = getWells(wellNamePattern);
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells ) {
|
||||
WellProductionProperties properties;
|
||||
@ -637,12 +640,12 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
handleWCONProducer(keyword, currentStep, false, parseContext);
|
||||
void Schedule::handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
handleWCONProducer(keyword, currentStep, false, parseContext, errors);
|
||||
}
|
||||
|
||||
void Schedule::handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
handleWCONProducer( keyword, currentStep, true, parseContext);
|
||||
void Schedule::handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
handleWCONProducer( keyword, currentStep, true, parseContext, errors);
|
||||
}
|
||||
|
||||
void Schedule::handleWPIMULT( const DeckKeyword& keyword, size_t currentStep) {
|
||||
@ -657,13 +660,13 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
void Schedule::handleWCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
|
||||
auto wells = getWells(wellNamePattern);
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells) {
|
||||
WellInjector::TypeEnum injectorType = WellInjector::TypeFromString( record.getItem("TYPE").getTrimmedString(0) );
|
||||
@ -741,13 +744,13 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells) {
|
||||
WellPolymerProperties properties(well->getPolymerPropertiesCopy(currentStep));
|
||||
@ -771,7 +774,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWPMITAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWPMITAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
|
||||
for (const auto& record : keyword) {
|
||||
|
||||
@ -779,7 +782,7 @@ namespace Opm {
|
||||
const auto wells = getWells(wellNamePattern);
|
||||
|
||||
if (wells.empty()) {
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
}
|
||||
|
||||
for (auto* well : wells) {
|
||||
@ -794,7 +797,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWSKPTAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWSKPTAB( const DeckKeyword& keyword, const size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
|
||||
|
||||
for (const auto& record : keyword) {
|
||||
@ -802,7 +805,7 @@ namespace Opm {
|
||||
const auto wells = getWells(wellNamePattern);
|
||||
|
||||
if (wells.empty()) {
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
}
|
||||
|
||||
for (auto* well : wells) {
|
||||
@ -818,14 +821,14 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
WellEconProductionLimits econ_production_limits(record);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells ) {
|
||||
well->setEconProductionLimits(currentStep, econ_production_limits);
|
||||
@ -833,14 +836,14 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELLNAME").getTrimmedString(0);
|
||||
const double& efficiencyFactor = record.getItem("EFFICIENCY_FACTOR").get< double >(0);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells ) {
|
||||
well->setEfficiencyFactor(currentStep, efficiencyFactor);
|
||||
@ -849,14 +852,14 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleWTEST(const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWTEST(const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
const auto& current = *this->wtest_config.get(currentStep);
|
||||
std::shared_ptr<WellTestConfig> new_config(new WellTestConfig(current));
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
double test_interval = record.getItem("INTERVAL").getSIDouble(0);
|
||||
const std::string& reason = record.getItem("REASON").get<std::string>(0);
|
||||
@ -873,14 +876,14 @@ namespace Opm {
|
||||
this->wtest_config.update(currentStep, new_config);
|
||||
}
|
||||
|
||||
void Schedule::handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells) {
|
||||
WellInjectionProperties injectionProperties = well->getInjectionProperties( currentStep );
|
||||
@ -893,15 +896,15 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWTRACER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
|
||||
void Schedule::handleWTRACER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells) {
|
||||
WellTracerProperties wellTracerProperties = well->getTracerProperties( currentStep );
|
||||
@ -914,13 +917,13 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern( wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* well : wells) {
|
||||
// TODO: Is this the right approach? Setting the well temperature only
|
||||
@ -938,7 +941,7 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWINJTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWINJTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
// we do not support the "enthalpy" field yet. how to do this is a more difficult
|
||||
// question.
|
||||
for( const auto& record : keyword ) {
|
||||
@ -946,7 +949,7 @@ namespace Opm {
|
||||
auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern( wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* well : wells) {
|
||||
// TODO: Is this the right approach? Setting the well temperature only
|
||||
@ -964,7 +967,7 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWCONINJH( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleWCONINJH( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
|
||||
@ -978,7 +981,7 @@ namespace Opm {
|
||||
auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern( wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* well : wells) {
|
||||
updateWellStatus( *well, currentStep, status );
|
||||
@ -1029,7 +1032,7 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext ) {
|
||||
void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
|
||||
auto all_defaulted = []( const DeckRecord& rec ) {
|
||||
auto defaulted = []( const DeckItem& item ) {
|
||||
@ -1048,7 +1051,7 @@ namespace Opm {
|
||||
auto wells = getWells( wellNamePattern );
|
||||
|
||||
if (wells.empty())
|
||||
invalidNamePattern( wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
/* if all records are defaulted or just the status is set, only
|
||||
* well status is updated
|
||||
@ -1094,7 +1097,7 @@ namespace Opm {
|
||||
void Schedule::handleWELTARG( const SCHEDULESection& section ,
|
||||
const DeckKeyword& keyword,
|
||||
size_t currentStep,
|
||||
const ParseContext& parseContext) {
|
||||
const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
Opm::UnitSystem unitSystem = section.unitSystem();
|
||||
double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time").getSIScaling();
|
||||
double siFactorG = unitSystem.parse("GasSurfaceVolume/Time").getSIScaling();
|
||||
@ -1109,7 +1112,7 @@ namespace Opm {
|
||||
const auto wells = getWells( wellNamePattern );
|
||||
|
||||
if( wells.empty() )
|
||||
invalidNamePattern( wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for( auto* well : wells ) {
|
||||
if(well->isProducer(currentStep)){
|
||||
@ -1211,13 +1214,13 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleGCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleGCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0);
|
||||
auto groups = getGroups ( groupNamePattern );
|
||||
|
||||
if (groups.empty())
|
||||
invalidNamePattern(groupNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(groupNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* group : groups){
|
||||
{
|
||||
@ -1246,13 +1249,13 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0);
|
||||
auto groups = getGroups ( groupNamePattern );
|
||||
|
||||
if (groups.empty())
|
||||
invalidNamePattern(groupNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(groupNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* group : groups){
|
||||
{
|
||||
@ -1275,13 +1278,13 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) {
|
||||
void Schedule::handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for( const auto& record : keyword ) {
|
||||
const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0);
|
||||
auto groups = getGroups ( groupNamePattern );
|
||||
|
||||
if (groups.empty())
|
||||
invalidNamePattern(groupNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(groupNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* group : groups){
|
||||
group->setGroupEfficiencyFactor(currentStep, record.getItem("EFFICIENCY_FACTOR").get< double >(0));
|
||||
@ -1451,12 +1454,12 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, const ParseContext& parseContext) {
|
||||
void Schedule::handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, const ParseContext& parseContext, ErrorGuard& errors) {
|
||||
for (const auto& record : keyword) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
|
||||
auto wells = getWells(wellNamePattern);
|
||||
if (wells.empty())
|
||||
invalidNamePattern(wellNamePattern, parseContext, keyword);
|
||||
invalidNamePattern(wellNamePattern, parseContext, errors, keyword);
|
||||
|
||||
for (auto* well : wells) {
|
||||
well->handleCOMPDAT(currentStep, record, grid, eclipseProperties);
|
||||
@ -1573,10 +1576,10 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::invalidNamePattern( const std::string& namePattern, const ParseContext& parseContext, const DeckKeyword& keyword ) const {
|
||||
void Schedule::invalidNamePattern( const std::string& namePattern, const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& keyword ) const {
|
||||
std::string msg = "Error when handling " + keyword.name() +". No names match " +
|
||||
namePattern;
|
||||
parseContext.handleError( ParseContext::SCHEDULE_INVALID_NAME, msg );
|
||||
parseContext.handleError( ParseContext::SCHEDULE_INVALID_NAME, msg, errors );
|
||||
}
|
||||
|
||||
const TimeMap& Schedule::getTimeMap() const {
|
||||
|
@ -123,25 +123,26 @@ namespace {
|
||||
|
||||
|
||||
|
||||
void handleMissingWell( const ParseContext& parseContext , const std::string& keyword, const std::string& well) {
|
||||
void handleMissingWell( const ParseContext& parseContext, ErrorGuard& errors, const std::string& keyword, const std::string& well) {
|
||||
std::string msg = std::string("Error in keyword:") + keyword + std::string(" No such well: ") + well;
|
||||
if (parseContext.get( ParseContext::SUMMARY_UNKNOWN_WELL) == InputError::WARN)
|
||||
std::cerr << "ERROR: " << msg << std::endl;
|
||||
|
||||
parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_WELL , msg );
|
||||
parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_WELL , msg, errors );
|
||||
}
|
||||
|
||||
|
||||
void handleMissingGroup( const ParseContext& parseContext , const std::string& keyword, const std::string& group) {
|
||||
void handleMissingGroup( const ParseContext& parseContext , ErrorGuard& errors, const std::string& keyword, const std::string& group) {
|
||||
std::string msg = std::string("Error in keyword:") + keyword + std::string(" No such group: ") + group;
|
||||
if (parseContext.get( ParseContext::SUMMARY_UNKNOWN_GROUP) == InputError::WARN)
|
||||
std::cerr << "ERROR: " << msg << std::endl;
|
||||
|
||||
parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_GROUP , msg );
|
||||
parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_GROUP , msg, errors );
|
||||
}
|
||||
|
||||
inline void keywordW( SummaryConfig::keyword_list& list,
|
||||
inline void keywordW( SummaryConfig::keyword_list& list,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule ) {
|
||||
|
||||
@ -154,7 +155,7 @@ void handleMissingGroup( const ParseContext& parseContext , const std::string& k
|
||||
auto wells = schedule.getWellsMatching( pattern );
|
||||
|
||||
if( wells.empty() )
|
||||
handleMissingWell( parseContext, keyword.name(), pattern );
|
||||
handleMissingWell( parseContext, errors, keyword.name(), pattern );
|
||||
|
||||
for( const auto* well : wells )
|
||||
list.push_back( SummaryConfig::keyword_type( keyword.name(), well->name() ));
|
||||
@ -167,6 +168,7 @@ void handleMissingGroup( const ParseContext& parseContext , const std::string& k
|
||||
|
||||
inline void keywordG( SummaryConfig::keyword_list& list,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule ) {
|
||||
|
||||
@ -188,7 +190,7 @@ inline void keywordG( SummaryConfig::keyword_list& list,
|
||||
if( schedule.hasGroup( group ) )
|
||||
list.push_back( SummaryConfig::keyword_type(keyword.name(), group ));
|
||||
else
|
||||
handleMissingGroup( parseContext, keyword.name(), group );
|
||||
handleMissingGroup( parseContext, errors, keyword.name(), group );
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,10 +226,11 @@ inline void keywordB( SummaryConfig::keyword_list& list,
|
||||
|
||||
inline void keywordR2R( SummaryConfig::keyword_list& list,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword)
|
||||
{
|
||||
std::string msg = "OPM/flow does not support region to region summary keywords - " + keyword.name() + " is ignored.";
|
||||
parseContext.handleError(ParseContext::SUMMARY_UNHANDLED_KEYWORD, msg);
|
||||
parseContext.handleError(ParseContext::SUMMARY_UNHANDLED_KEYWORD, msg, errors);
|
||||
}
|
||||
|
||||
|
||||
@ -272,6 +275,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
|
||||
inline void keywordC( SummaryConfig::keyword_list& list,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule,
|
||||
const GridDims& dims) {
|
||||
@ -288,7 +292,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
: schedule.getWellsMatching( wellitem.getTrimmedString( 0 ) );
|
||||
|
||||
if( wells.empty() )
|
||||
handleMissingWell( parseContext, keyword.name(), wellitem.getTrimmedString( 0 ) );
|
||||
handleMissingWell( parseContext, errors, keyword.name(), wellitem.getTrimmedString( 0 ) );
|
||||
|
||||
for( const auto* well : wells ) {
|
||||
const auto& name = well->name();
|
||||
@ -436,6 +440,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
|
||||
void keywordSWithRecords(const std::size_t last_timestep,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule,
|
||||
SummaryConfig::keyword_list& list)
|
||||
@ -463,7 +468,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
: schedule.getWellsMatching(wellitem.getTrimmedString(0));
|
||||
|
||||
if (wells.empty()) {
|
||||
handleMissingWell(parseContext, keyword.name(),
|
||||
handleMissingWell(parseContext, errors, keyword.name(),
|
||||
wellitem.getTrimmedString(0));
|
||||
}
|
||||
|
||||
@ -478,6 +483,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
|
||||
inline void keywordS(SummaryConfig::keyword_list& list,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule)
|
||||
{
|
||||
@ -507,7 +513,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
if (keyword.size() > 0) {
|
||||
// Keyword with explicit records.
|
||||
// Handle as alternatives SOFR and SPR above
|
||||
keywordSWithRecords(last_timestep, parseContext,
|
||||
keywordSWithRecords(last_timestep, parseContext, errors,
|
||||
keyword, schedule, list);
|
||||
}
|
||||
else {
|
||||
@ -522,23 +528,24 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
|
||||
const Schedule& schedule,
|
||||
const TableManager& tables,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const GridDims& dims) {
|
||||
const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() );
|
||||
|
||||
switch( var_type ) {
|
||||
case ECL_SMSPEC_WELL_VAR: return keywordW( list, parseContext, keyword, schedule );
|
||||
case ECL_SMSPEC_GROUP_VAR: return keywordG( list, parseContext, keyword, schedule );
|
||||
case ECL_SMSPEC_WELL_VAR: return keywordW( list, parseContext, errors, keyword, schedule );
|
||||
case ECL_SMSPEC_GROUP_VAR: return keywordG( list, parseContext, errors, keyword, schedule );
|
||||
case ECL_SMSPEC_FIELD_VAR: return keywordF( list, keyword );
|
||||
case ECL_SMSPEC_BLOCK_VAR: return keywordB( list, keyword, dims );
|
||||
case ECL_SMSPEC_REGION_VAR: return keywordR( list, keyword, tables );
|
||||
case ECL_SMSPEC_REGION_2_REGION_VAR: return keywordR2R(list, parseContext, keyword);
|
||||
case ECL_SMSPEC_COMPLETION_VAR: return keywordC( list, parseContext, keyword, schedule, dims);
|
||||
case ECL_SMSPEC_SEGMENT_VAR: return keywordS( list, parseContext, keyword, schedule );
|
||||
case ECL_SMSPEC_REGION_2_REGION_VAR: return keywordR2R(list, parseContext, errors, keyword);
|
||||
case ECL_SMSPEC_COMPLETION_VAR: return keywordC( list, parseContext, errors, keyword, schedule, dims);
|
||||
case ECL_SMSPEC_SEGMENT_VAR: return keywordS( list, parseContext, errors, keyword, schedule );
|
||||
case ECL_SMSPEC_MISC_VAR: return keywordMISC( list, keyword );
|
||||
|
||||
default:
|
||||
std::string msg = "Summary keywords of type: " + std::string(ecl_smspec_get_var_type_name( var_type )) + " is not supported. Keyword: " + keyword.name() + " is ignored";
|
||||
parseContext.handleError(ParseContext::SUMMARY_UNHANDLED_KEYWORD, msg);
|
||||
parseContext.handleError(ParseContext::SUMMARY_UNHANDLED_KEYWORD, msg, errors);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -564,22 +571,23 @@ SummaryConfig::SummaryConfig( const Deck& deck,
|
||||
const Schedule& schedule,
|
||||
const TableManager& tables,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
const GridDims& dims) {
|
||||
SUMMARYSection section( deck );
|
||||
for( auto& x : section )
|
||||
handleKW( this->keywords, x, schedule, tables, parseContext, dims);
|
||||
handleKW( this->keywords, x, schedule, tables, parseContext, errors, dims);
|
||||
|
||||
if( section.hasKeyword( "ALL" ) )
|
||||
this->merge( { ALL_keywords, schedule, tables, parseContext, dims} );
|
||||
this->merge( { ALL_keywords, schedule, tables, parseContext, errors, dims} );
|
||||
|
||||
if( section.hasKeyword( "GMWSET" ) )
|
||||
this->merge( { GMWSET_keywords, schedule, tables, parseContext, dims} );
|
||||
this->merge( { GMWSET_keywords, schedule, tables, parseContext, errors, dims} );
|
||||
|
||||
if( section.hasKeyword( "FMWSET" ) )
|
||||
this->merge( { FMWSET_keywords, schedule, tables, parseContext, dims} );
|
||||
this->merge( { FMWSET_keywords, schedule, tables, parseContext, errors, dims} );
|
||||
|
||||
if (section.hasKeyword( "PERFORMA" ) )
|
||||
this->merge( { PERFORMA_keywords, schedule, tables, parseContext, dims} );
|
||||
this->merge( { PERFORMA_keywords, schedule, tables, parseContext, errors, dims} );
|
||||
|
||||
uniq( this->keywords );
|
||||
for (const auto& kw: this->keywords) {
|
||||
@ -592,8 +600,9 @@ SummaryConfig::SummaryConfig( const Deck& deck,
|
||||
SummaryConfig::SummaryConfig( const Deck& deck,
|
||||
const Schedule& schedule,
|
||||
const TableManager& tables,
|
||||
const ParseContext& parseContext) :
|
||||
SummaryConfig( deck , schedule, tables, parseContext, GridDims( deck ))
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors) :
|
||||
SummaryConfig( deck , schedule, tables, parseContext, errors, GridDims( deck ))
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -53,11 +53,15 @@ namespace Opm {
|
||||
this->error_list.clear();
|
||||
}
|
||||
|
||||
void ErrorGuard::terminate() const {
|
||||
this->dump();
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
|
||||
ErrorGuard::~ErrorGuard() {
|
||||
if (*this) {
|
||||
this->dump();
|
||||
std::terminate();
|
||||
}
|
||||
if (*this)
|
||||
this->terminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
@ -111,7 +112,8 @@ namespace Opm {
|
||||
|
||||
void ParseContext::handleError(
|
||||
const std::string& errorKey,
|
||||
const std::string& msg ) const {
|
||||
const std::string& msg,
|
||||
ErrorGuard& errors) const {
|
||||
|
||||
InputError::Action action = get( errorKey );
|
||||
|
||||
@ -133,10 +135,10 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void ParseContext::handleUnknownKeyword(const std::string& keyword) const {
|
||||
void ParseContext::handleUnknownKeyword(const std::string& keyword, ErrorGuard& errors) const {
|
||||
if (this->ignore_keywords.find(keyword) == this->ignore_keywords.end()) {
|
||||
std::string msg = "Unknown keyword: " + keyword;
|
||||
this->handleError(ParseContext::PARSE_UNKNOWN_KEYWORD, msg);
|
||||
this->handleError(ParseContext::PARSE_UNKNOWN_KEYWORD, msg, errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,8 @@ void InputStack::push( std::string&& input, boost::filesystem::path p ) {
|
||||
|
||||
class ParserState {
|
||||
public:
|
||||
ParserState( const ParseContext& );
|
||||
ParserState( const ParseContext&, boost::filesystem::path );
|
||||
ParserState( const ParseContext&, ErrorGuard& );
|
||||
ParserState( const ParseContext&, ErrorGuard&, boost::filesystem::path );
|
||||
|
||||
void loadString( const std::string& );
|
||||
void loadFile( const boost::filesystem::path& );
|
||||
@ -234,10 +234,11 @@ class ParserState {
|
||||
std::shared_ptr< RawKeyword > rawKeyword;
|
||||
ParserKeywordSizeEnum lastSizeType = SLASH_TERMINATED;
|
||||
std::string lastKeyWord;
|
||||
|
||||
|
||||
string_view nextKeyword = emptystr;
|
||||
Deck deck;
|
||||
const ParseContext& parseContext;
|
||||
ErrorGuard& errors;
|
||||
bool unknown_keyword = false;
|
||||
};
|
||||
|
||||
@ -272,14 +273,17 @@ void ParserState::closeFile() {
|
||||
this->input_stack.pop();
|
||||
}
|
||||
|
||||
ParserState::ParserState(const ParseContext& __parseContext) :
|
||||
parseContext( __parseContext )
|
||||
ParserState::ParserState(const ParseContext& __parseContext, ErrorGuard& errors) :
|
||||
parseContext( __parseContext ),
|
||||
errors( errors )
|
||||
{}
|
||||
|
||||
ParserState::ParserState( const ParseContext& context,
|
||||
ErrorGuard& errors,
|
||||
boost::filesystem::path p ) :
|
||||
rootPath( boost::filesystem::canonical( p ).parent_path() ),
|
||||
parseContext( context )
|
||||
parseContext( context ),
|
||||
errors( errors )
|
||||
{
|
||||
openRootFile( p );
|
||||
}
|
||||
@ -295,7 +299,7 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
inputFileCanonical = boost::filesystem::canonical(inputFile);
|
||||
} catch (boost::filesystem::filesystem_error fs_error) {
|
||||
std::string msg = "Could not open file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , msg);
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , msg, errors);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -308,7 +312,8 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
// make sure the file we'd like to parse is readable
|
||||
if( !ufp ) {
|
||||
std::string msg = "Could not read from file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , msg);
|
||||
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , msg, errors);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -368,7 +373,7 @@ void ParserState::handleRandomText(const string_view& keywordString ) const {
|
||||
<< this->current_path()
|
||||
<< ":" << this->line();
|
||||
}
|
||||
parseContext.handleError( errorKey , msg.str() );
|
||||
parseContext.handleError( errorKey , msg.str(), errors );
|
||||
}
|
||||
|
||||
void ParserState::openRootFile( const boost::filesystem::path& inputFile) {
|
||||
@ -417,7 +422,7 @@ std::shared_ptr< RawKeyword > createRawKeyword( const string_view& kw, ParserSta
|
||||
if( !parser.isRecognizedKeyword( keywordString ) ) {
|
||||
if( ParserKeyword::validDeckName( keywordString ) ) {
|
||||
std::string msg = "Keyword " + keywordString + " not recognized.";
|
||||
parserState.parseContext.handleUnknownKeyword( keywordString.string() );
|
||||
parserState.parseContext.handleUnknownKeyword( keywordString.string(), parserState.errors );
|
||||
parserState.unknown_keyword = true;
|
||||
return {};
|
||||
}
|
||||
@ -467,7 +472,7 @@ std::shared_ptr< RawKeyword > createRawKeyword( const string_view& kw, ParserSta
|
||||
|
||||
std::string msg = "Expected the kewyord: " +keyword_size.keyword
|
||||
+ " to infer the number of records in: " + keywordString;
|
||||
parserState.parseContext.handleError(ParseContext::PARSE_MISSING_DIMS_KEYWORD , msg );
|
||||
parserState.parseContext.handleError(ParseContext::PARSE_MISSING_DIMS_KEYWORD , msg, parserState.errors );
|
||||
|
||||
const auto* keyword = parser.getKeyword( keyword_size.keyword );
|
||||
const auto& record = keyword->getRecord(0);
|
||||
@ -582,7 +587,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) {
|
||||
const auto& kwname = parserState.rawKeyword->getKeywordName();
|
||||
const auto* parserKeyword = parser.getParserKeywordFromDeckName( kwname );
|
||||
try {
|
||||
parserState.deck.addKeyword( parserKeyword->parse( parserState.parseContext, parserState.rawKeyword ) );
|
||||
parserState.deck.addKeyword( parserKeyword->parse( parserState.parseContext, parserState.errors, parserState.rawKeyword ) );
|
||||
} catch (const std::exception& exc) {
|
||||
/*
|
||||
This catch-all of parsing errors is to be able to write a good
|
||||
@ -639,55 +644,55 @@ bool parseState( ParserState& parserState, const Parser& parser ) {
|
||||
throw new std::logic_error("Cannot construct a state in partial deck context");
|
||||
}
|
||||
|
||||
EclipseState Parser::parse(const std::string &filename, const ParseContext& context) {
|
||||
EclipseState Parser::parse(const std::string &filename, const ParseContext& context, ErrorGuard& errors) {
|
||||
assertFullDeck(context);
|
||||
return EclipseState( Parser{}.parseFile( filename, context ), context );
|
||||
return EclipseState( Parser{}.parseFile( filename, context, errors ), context, errors );
|
||||
}
|
||||
|
||||
EclipseState Parser::parse(const Deck& deck, const ParseContext& context) {
|
||||
EclipseState Parser::parse(const Deck& deck, const ParseContext& context, ErrorGuard& errors) {
|
||||
assertFullDeck(context);
|
||||
return EclipseState(deck, context);
|
||||
return EclipseState(deck, context, errors);
|
||||
}
|
||||
|
||||
EclipseState Parser::parseData(const std::string &data, const ParseContext& context) {
|
||||
EclipseState Parser::parseData(const std::string &data, const ParseContext& context, ErrorGuard& errors) {
|
||||
assertFullDeck(context);
|
||||
Parser p;
|
||||
auto deck = p.parseString(data, context);
|
||||
return parse(deck, context);
|
||||
auto deck = p.parseString(data, context, errors);
|
||||
return parse(deck, context, errors);
|
||||
}
|
||||
|
||||
EclipseGrid Parser::parseGrid(const std::string &filename, const ParseContext& context) {
|
||||
EclipseGrid Parser::parseGrid(const std::string &filename, const ParseContext& context, ErrorGuard& errors) {
|
||||
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS))
|
||||
return EclipseGrid{ filename };
|
||||
return parse(filename, context).getInputGrid();
|
||||
return parse(filename, context, errors).getInputGrid();
|
||||
}
|
||||
|
||||
EclipseGrid Parser::parseGrid(const Deck& deck, const ParseContext& context)
|
||||
EclipseGrid Parser::parseGrid(const Deck& deck, const ParseContext& context, ErrorGuard& errors)
|
||||
{
|
||||
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS))
|
||||
return EclipseGrid{ deck };
|
||||
return parse(deck, context).getInputGrid();
|
||||
return parse(deck, context, errors).getInputGrid();
|
||||
}
|
||||
|
||||
EclipseGrid Parser::parseGridData(const std::string &data, const ParseContext& context) {
|
||||
EclipseGrid Parser::parseGridData(const std::string &data, const ParseContext& context, ErrorGuard& errors) {
|
||||
Parser parser;
|
||||
auto deck = parser.parseString(data, context);
|
||||
auto deck = parser.parseString(data, context, errors);
|
||||
if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS)) {
|
||||
return EclipseGrid{ deck };
|
||||
}
|
||||
return parse(deck, context).getInputGrid();
|
||||
return parse(deck, context, errors).getInputGrid();
|
||||
}
|
||||
|
||||
Deck Parser::parseFile(const std::string &dataFileName, const ParseContext& parseContext) const {
|
||||
ParserState parserState( parseContext, dataFileName );
|
||||
Deck Parser::parseFile(const std::string &dataFileName, const ParseContext& parseContext, ErrorGuard& errors) const {
|
||||
ParserState parserState( parseContext, errors, dataFileName );
|
||||
parseState( parserState, *this );
|
||||
applyUnitsToDeck( parserState.deck );
|
||||
|
||||
return std::move( parserState.deck );
|
||||
}
|
||||
|
||||
Deck Parser::parseString(const std::string &data, const ParseContext& parseContext) const {
|
||||
ParserState parserState( parseContext );
|
||||
Deck Parser::parseString(const std::string &data, const ParseContext& parseContext, ErrorGuard& errors) const {
|
||||
ParserState parserState( parseContext, errors );
|
||||
parserState.loadString( data );
|
||||
|
||||
parseState( parserState, *this );
|
||||
|
@ -478,6 +478,7 @@ void set_dimensions( ParserItem& item,
|
||||
}
|
||||
|
||||
DeckKeyword ParserKeyword::parse(const ParseContext& parseContext,
|
||||
ErrorGuard& errors,
|
||||
std::shared_ptr< RawKeyword > rawKeyword) const {
|
||||
if( !rawKeyword->isFinished() )
|
||||
throw std::invalid_argument("Tried to create a deck keyword from an incomplete raw keyword " + rawKeyword->getKeywordName());
|
||||
@ -491,7 +492,7 @@ void set_dimensions( ParserItem& item,
|
||||
if( m_records.size() == 0 && rawRecord.size() > 0 )
|
||||
throw std::invalid_argument("Missing item information " + rawKeyword->getKeywordName());
|
||||
|
||||
keyword.addRecord( getRecord( record_nr ).parse( parseContext, rawRecord ) );
|
||||
keyword.addRecord( getRecord( record_nr ).parse( parseContext, errors, rawRecord ) );
|
||||
record_nr++;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ namespace {
|
||||
return *itr;
|
||||
}
|
||||
|
||||
DeckRecord ParserRecord::parse(const ParseContext& parseContext , RawRecord& rawRecord ) const {
|
||||
DeckRecord ParserRecord::parse(const ParseContext& parseContext , ErrorGuard& errors , RawRecord& rawRecord) const {
|
||||
std::vector< DeckItem > items;
|
||||
items.reserve( this->size() + 20 );
|
||||
for( const auto& parserItem : *this )
|
||||
@ -133,7 +133,7 @@ namespace {
|
||||
std::string msg = "The RawRecord for keyword \"" + rawRecord.getKeywordName() + "\" in file\"" + rawRecord.getFileName() + "\" contained " +
|
||||
std::to_string(rawRecord.size()) +
|
||||
" too many items according to the spec. RawRecord was: " + rawRecord.getRecordString();
|
||||
parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msg);
|
||||
parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msg, errors);
|
||||
}
|
||||
|
||||
return { std::move( items ) };
|
||||
|
Loading…
Reference in New Issue
Block a user