Write restart when SAVE keyword is in the schedule file

This commit is contained in:
Tor Harald Sandve 2018-09-14 09:17:56 +02:00
parent 142994dde6
commit fdc4b0142e
4 changed files with 52 additions and 1 deletions

View File

@ -362,6 +362,7 @@ namespace Opm {
DynamicState< RestartSchedule > restart_schedule;
DynamicState< std::map< std::string, int > > restart_keywords;
std::vector< bool > save_keywords;
};
} //namespace Opm

View File

@ -397,6 +397,12 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule) {
continue;
}
if (name == "SAVE") {
this->save_keywords[current_step] = true;
} else {
this->save_keywords[current_step]= false;
}
if( !( name == "RPTRST" || name == "RPTSCHED" ) ) continue;
if( this->m_timemap.size() <= current_step ) continue;
@ -476,7 +482,8 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule) {
m_timemap( std::move( timemap ) ),
m_first_restart_step( -1 ),
restart_schedule( m_timemap, { 0, 0, 1 } ),
restart_keywords( m_timemap, {} )
restart_keywords( m_timemap, {} ),
save_keywords( m_timemap.numTimesteps(), false )
{
handleSolutionSection( solution );
handleScheduleSection( schedule );
@ -494,6 +501,12 @@ void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule) {
if (0 == timestep)
return m_write_initial_RST_file;
if (save_keywords[timestep]) {
std::string logstring = "Fast restart using SAVE is not supported. Standard restart file is written instead";
Opm::OpmLog::warning("Unhandled output keyword", logstring);
return true;
}
{
RestartSchedule ts_restart_config = getNode( timestep );
return ts_restart_config.writeRestartFile( timestep , m_timemap );

View File

@ -897,5 +897,40 @@ BOOST_AUTO_TEST_CASE(RESTART_BASIC_LEQ_2) {
BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) );
}
BOOST_AUTO_TEST_CASE(RESTART_SAVE) {
const char* data = "RUNSPEC\n"
"DIMENS\n"
" 10 10 10 /\n"
"GRID\n"
"START\n"
" 21 MAY 1981 /\n"
"\n"
"SCHEDULE\n"
"DATES\n"
" 22 MAY 1981 /\n"
"/\n"
"DATES\n"
" 23 MAY 1981 /\n"
" 24 MAY 1981 /\n"
" 23 MAY 1982 /\n"
" 24 MAY 1982 /\n"
" 24 MAY 1983 /\n"
" 25 MAY 1984 /\n"
" 26 MAY 1984 /\n"
" 26 MAY 1985 /\n"
" 27 MAY 1985 /\n"
" 1 JAN 1986 /\n"
"/\n"
"SAVE \n"
"TSTEP \n"
" 1 /\n";
auto deck = Parser().parseString( data, ParseContext() );
RestartConfig ioConfig( deck );
for( size_t ts = 1; ts < 11; ++ts )
BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) );
BOOST_CHECK( ioConfig.getWriteRestartFile( 12 ) );
}

View File

@ -345,6 +345,8 @@ BOOST_AUTO_TEST_CASE( RestartConfig2 ) {
else if (234 == report_step) rptConfig.push_back( std::make_tuple(report_step, true, boost::gregorian::date(2012,1,1)));
else if (240 == report_step) rptConfig.push_back( std::make_tuple(report_step, true, boost::gregorian::date(2012,7,1)));
else if (246 == report_step) rptConfig.push_back( std::make_tuple(report_step, true, boost::gregorian::date(2013,1,1)));
// output when SAVE is in the deck
else if (251 == report_step) rptConfig.push_back( std::make_tuple(report_step, true, boost::gregorian::date(2013,5,2)));
else rptConfig.push_back( std::make_tuple(report_step, false, boost::gregorian::date(2000,1,1)));
}