From 9eb13cfe0604da244f14a9a5ee3093de7dfec894 Mon Sep 17 00:00:00 2001 From: chflo Date: Fri, 29 May 2015 11:45:05 +0200 Subject: [PATCH] OPM-205: Added handling of RPTSCHED RESTART and RPTSCHED NOTHING --- .../EclipseState/Schedule/Schedule.cpp | 58 ++++++++++++++++++- .../EclipseState/Schedule/Schedule.hpp | 1 + 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 86c390329..b31c63afa 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -136,6 +136,9 @@ namespace Opm { if (keyword->name() == "RPTRST") handleRPTRST(keyword, currentStep, ioConfig); + if (keyword->name() == "RPTSCHED") + handleRPTSCHED(keyword, currentStep, ioConfig); + if (keyword->name() == "WRFT") rftProperties.push_back( std::make_pair( keyword , currentStep )); @@ -760,6 +763,7 @@ namespace Opm { size_t basic = 1; size_t freq = 0; + bool handle_RPTRST_BASIC = false; DeckItemConstPtr item = record->getItem(0); @@ -770,6 +774,7 @@ namespace Opm { if (found_basic != std::string::npos) { std::string basic_no = mnemonic.substr(found_basic+6, mnemonic.size()); basic = boost::lexical_cast(basic_no); + handle_RPTRST_BASIC = true; } size_t found_freq = mnemonic.find("FREQ="); @@ -779,10 +784,61 @@ namespace Opm { } } - ioConfig->handleRPTRSTBasic(m_timeMap, currentStep, basic, freq); + if (handle_RPTRST_BASIC) { + ioConfig->handleRPTRSTBasic(m_timeMap, currentStep, basic, freq); + } } + void Schedule::handleRPTSCHED(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig) { + DeckRecordConstPtr record = keyword->getRecord(0); + + size_t restart = 0; + size_t found_mnemonic_RESTART = 0; + size_t found_mnemonic_NOTHING = 0; + DeckItemConstPtr item = record->getItem(0); + bool handle_RPTSCHED_RESTART = false; + + for (size_t index = 0; index < item->size(); ++index) { + const std::string& mnemonic = item->getString(index); + + found_mnemonic_RESTART = mnemonic.find("RESTART="); + if (found_mnemonic_RESTART != std::string::npos) { + std::string restart_no = mnemonic.substr(found_mnemonic_RESTART+8, mnemonic.size()); + restart = boost::lexical_cast(restart_no); + handle_RPTSCHED_RESTART = true; + } + found_mnemonic_NOTHING = mnemonic.find("NOTHING"); + if (found_mnemonic_NOTHING != std::string::npos) { + restart = 0; + handle_RPTSCHED_RESTART = true; + } + } + + + /* If no RESTART mnemonic is found, either it is not present or we might + have an old data set containing integer controls instead of mnemonics. + Restart integer switch is integer control nr 7 */ + + if (found_mnemonic_RESTART == std::string::npos) { + if (item->size() >= 7) { + const std::string& integer_control = item->getString(6); + try { + restart = boost::lexical_cast(integer_control); + handle_RPTSCHED_RESTART = true; + } catch (boost::bad_lexical_cast &) { + //do nothing + } + } + } + + + if (handle_RPTSCHED_RESTART) { + ioConfig->handleRPTSCHEDRestart(m_timeMap, currentStep, restart); + } + + } + void Schedule::handleCOMPDAT(DeckKeywordConstPtr keyword, size_t currentStep) { std::map > completionMapList = Completion::completionsFromCOMPDATKeyword( keyword ); std::map >::iterator iter; diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 4ab3eb038..3075a2955 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -102,6 +102,7 @@ namespace Opm void handleTUNING(DeckKeywordConstPtr keyword, size_t currentStep); void handleNOSIM(); void handleRPTRST(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig); + void handleRPTSCHED(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig); void handleDATES(DeckKeywordConstPtr keyword); void handleTSTEP(DeckKeywordConstPtr keyword); void handleGRUPTREE(DeckKeywordConstPtr keyword, size_t currentStep);