OPM-218: Fixed restart interval write for RPTRST
This commit is contained in:
@@ -50,32 +50,38 @@ namespace Opm {
|
||||
if (m_restart_output_config) {
|
||||
restartConfig ts_restart_config = m_restart_output_config->get(timestep);
|
||||
|
||||
switch (ts_restart_config.basic) {
|
||||
case 0: //Do not write restart files
|
||||
write_restart_ts = false;
|
||||
break;
|
||||
case 1: //Write restart file every report time
|
||||
//Look at rptsched restart setting
|
||||
if (ts_restart_config.rptsched_restart_set) {
|
||||
if (ts_restart_config.rptsched_restart > 0) {
|
||||
write_restart_ts = true;
|
||||
break;
|
||||
case 2: //Write restart file every report time
|
||||
write_restart_ts = true;
|
||||
break;
|
||||
case 3: //Every n'th report time
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency);
|
||||
break;
|
||||
case 4: //First reportstep of every year, or if n > 1, n'th years
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, true);
|
||||
break;
|
||||
case 5: //First reportstep of every month, or if n > 1, n'th months
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, false, true);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
} else { //Look at rptrst basic setting
|
||||
switch (ts_restart_config.basic) {
|
||||
case 0: //Do not write restart files
|
||||
write_restart_ts = false;
|
||||
break;
|
||||
case 1: //Write restart file every report time
|
||||
write_restart_ts = true;
|
||||
break;
|
||||
case 2: //Write restart file every report time
|
||||
write_restart_ts = true;
|
||||
break;
|
||||
case 3: //Every n'th report time
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency);
|
||||
break;
|
||||
case 4: //First reportstep of every year, or if n > 1, n'th years
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, true);
|
||||
break;
|
||||
case 5: //First reportstep of every month, or if n > 1, n'th months
|
||||
write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, false, true);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return write_restart_ts;
|
||||
}
|
||||
|
||||
@@ -135,6 +141,8 @@ namespace Opm {
|
||||
rs.timestep = timestep;
|
||||
rs.basic = basic;
|
||||
rs.frequency = frequency;
|
||||
rs.rptsched_restart_set = false;
|
||||
rs.rptsched_restart = 0;
|
||||
|
||||
if (update_default) {
|
||||
m_restart_output_config->updateInitial(rs);
|
||||
@@ -162,12 +170,12 @@ namespace Opm {
|
||||
initRestartOutputConfig(timemap);
|
||||
}
|
||||
|
||||
//RPTSCHED Restart mnemonic == 0: same logic as RPTRST Basic mnemonic = 0
|
||||
//RPTSCHED Restart mnemonic >= 1; same logic as RPTRST Basic mnemonic = 1
|
||||
|
||||
restartConfig rs;
|
||||
rs.timestep = timestep;
|
||||
rs.basic = (restart == 0) ? 0 : 1;
|
||||
rs.timestep = 0;
|
||||
rs.basic = 0;
|
||||
rs.frequency = 0;
|
||||
rs.rptsched_restart = restart;
|
||||
rs.rptsched_restart_set = true;
|
||||
|
||||
m_restart_output_config->update(timestep, rs);
|
||||
}
|
||||
@@ -178,6 +186,8 @@ namespace Opm {
|
||||
rs.timestep = 0;
|
||||
rs.basic = 0;
|
||||
rs.frequency = 1;
|
||||
rs.rptsched_restart_set = false;
|
||||
rs.rptsched_restart = 0;
|
||||
|
||||
m_timemap = timemap;
|
||||
m_restart_output_config = std::make_shared<DynamicState<restartConfig>>(timemap, rs);
|
||||
|
||||
@@ -87,6 +87,8 @@ namespace Opm {
|
||||
size_t timestep;
|
||||
size_t basic;
|
||||
size_t frequency;
|
||||
bool rptsched_restart_set;
|
||||
size_t rptsched_restart;
|
||||
|
||||
bool operator!=(const restartConfig& rhs) {
|
||||
bool ret = true;
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace Opm {
|
||||
void Schedule::iterateScheduleSection(DeckConstPtr deck, IOConfigPtr ioConfig) {
|
||||
size_t currentStep = 0;
|
||||
std::vector<std::pair<DeckKeywordConstPtr , size_t> > rftProperties;
|
||||
std::vector<std::pair<DeckKeywordConstPtr , size_t> > IOConfigSettings;
|
||||
|
||||
for (size_t keywordIdx = 0; keywordIdx < deck->size(); ++keywordIdx) {
|
||||
DeckKeywordConstPtr keyword = deck->getKeyword(keywordIdx);
|
||||
@@ -134,10 +135,10 @@ namespace Opm {
|
||||
handleNOSIM();
|
||||
|
||||
if (keyword->name() == "RPTRST")
|
||||
handleRPTRST(keyword, currentStep, ioConfig);
|
||||
IOConfigSettings.push_back( std::make_pair( keyword , currentStep ));
|
||||
|
||||
if (keyword->name() == "RPTSCHED")
|
||||
handleRPTSCHED(keyword, currentStep, ioConfig);
|
||||
IOConfigSettings.push_back( std::make_pair( keyword , currentStep ));
|
||||
|
||||
if (keyword->name() == "WRFT")
|
||||
rftProperties.push_back( std::make_pair( keyword , currentStep ));
|
||||
@@ -163,6 +164,17 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (auto restartPair = IOConfigSettings.begin(); restartPair != IOConfigSettings.end(); ++restartPair) {
|
||||
DeckKeywordConstPtr keyword = restartPair->first;
|
||||
size_t timeStep = restartPair->second;
|
||||
if ((keyword->name() == "RPTRST") && (m_timeMap->size() > timeStep+1 )) {
|
||||
handleRPTRST(keyword, timeStep + 1, ioConfig);
|
||||
} else if ((keyword->name() == "RPTSCHED") && (m_timeMap->size() > timeStep+1 )){
|
||||
handleRPTSCHED(keyword, timeStep + 1, ioConfig);
|
||||
}
|
||||
}
|
||||
|
||||
checkUnhandledKeywords(deck);
|
||||
}
|
||||
|
||||
@@ -850,14 +862,16 @@ namespace Opm {
|
||||
|
||||
size_t basic = 1;
|
||||
size_t freq = 0;
|
||||
size_t found_basic = 0;
|
||||
bool handle_RPTRST_BASIC = false;
|
||||
|
||||
DeckItemConstPtr item = record->getItem(0);
|
||||
|
||||
|
||||
for (size_t index = 0; index < item->size(); ++index) {
|
||||
const std::string& mnemonic = item->getString(index);
|
||||
|
||||
size_t found_basic = mnemonic.find("BASIC=");
|
||||
found_basic = mnemonic.find("BASIC=");
|
||||
if (found_basic != std::string::npos) {
|
||||
std::string basic_no = mnemonic.substr(found_basic+6, mnemonic.size());
|
||||
basic = boost::lexical_cast<size_t>(basic_no);
|
||||
@@ -871,13 +885,48 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If no BASIC mnemonic is found, either it is not present or we might
|
||||
have an old data set containing integer controls instead of mnemonics.
|
||||
BASIC integer switch is integer control nr 1, FREQUENCY is integer
|
||||
control nr 6 */
|
||||
|
||||
|
||||
if (found_basic == std::string::npos) {
|
||||
if (item->size() >= 1) {
|
||||
const std::string& integer_control_basic = item->getString(0);
|
||||
try {
|
||||
basic = boost::lexical_cast<size_t>(integer_control_basic);
|
||||
if (0 != basic ) // Peculiar special case in eclipse, - not documented
|
||||
// This ignore of basic = 0 for the integer mnemonics case
|
||||
// is done to make flow write restart file at the same intervals
|
||||
// as eclipse for the Norne data set. There might be some rules
|
||||
// we are missing here.
|
||||
{
|
||||
handle_RPTRST_BASIC = true;
|
||||
}
|
||||
} catch (boost::bad_lexical_cast &) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
if (item->size() >= 6) { //if frequency is set
|
||||
const std::string& integer_control_frequency = item->getString(5);
|
||||
try {
|
||||
freq = boost::lexical_cast<size_t>(integer_control_frequency);
|
||||
} catch (boost::bad_lexical_cast &) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (handle_RPTRST_BASIC) {
|
||||
ioConfig->handleRPTRSTBasic(m_timeMap, currentStep, basic, freq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Schedule::handleRPTSCHED(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig) {
|
||||
void Schedule::handleRPTSCHED(DeckKeywordConstPtr keyword, size_t step, IOConfigPtr ioConfig) {
|
||||
DeckRecordConstPtr record = keyword->getRecord(0);
|
||||
|
||||
size_t restart = 0;
|
||||
@@ -921,7 +970,7 @@ namespace Opm {
|
||||
|
||||
|
||||
if (handle_RPTSCHED_RESTART) {
|
||||
ioConfig->handleRPTSCHEDRestart(m_timeMap, currentStep, restart);
|
||||
ioConfig->handleRPTSCHEDRestart(m_timeMap, step, restart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -846,7 +846,30 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTRST) {
|
||||
"DATES -- 3\n"
|
||||
" 20 JAN 2011 / \n"
|
||||
"/\n"
|
||||
"/\n";;
|
||||
"/\n";
|
||||
|
||||
const char *deckData3 =
|
||||
"RUNSPEC\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"GRID\n"
|
||||
"START -- 0 \n"
|
||||
"19 JUN 2007 / \n"
|
||||
"SCHEDULE\n"
|
||||
"DATES -- 1\n"
|
||||
" 10 OKT 2008 / \n"
|
||||
"/\n"
|
||||
"RPTRST\n"
|
||||
"3 0 0 0 0 2\n"
|
||||
"/\n"
|
||||
"DATES -- 2\n"
|
||||
" 20 JAN 2010 / \n"
|
||||
"/\n"
|
||||
"DATES -- 3\n"
|
||||
" 20 JAN 2011 / \n"
|
||||
"/\n"
|
||||
"/\n";
|
||||
|
||||
|
||||
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>( 10 , 10 , 10 );
|
||||
Opm::Parser parser;
|
||||
@@ -856,7 +879,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTRST) {
|
||||
Schedule schedule(grid , deck, ioConfig);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
|
||||
|
||||
@@ -865,11 +888,22 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTRST) {
|
||||
Schedule schedule2(grid , deck2, ioConfig2);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig2->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig2->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig2->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig2->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig2->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig2->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig2->getWriteRestartFile(3));
|
||||
|
||||
|
||||
DeckPtr deck3 = parser.parseString(deckData3) ;
|
||||
IOConfigPtr ioConfig3 = std::make_shared<IOConfig>();
|
||||
Schedule schedule3(grid , deck3, ioConfig3);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig3->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig3->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig3->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig3->getWriteRestartFile(3));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(createDeckWithRPTSCHED) {
|
||||
|
||||
const char *deckData =
|
||||
@@ -956,9 +990,9 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTSCHED) {
|
||||
Schedule schedule(grid , deck, ioConfig);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(3));
|
||||
|
||||
|
||||
DeckPtr deck1 = parser.parseString(deckData1);
|
||||
@@ -966,23 +1000,24 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTSCHED) {
|
||||
Schedule schedule1(grid , deck1, ioConfig1);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig1->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig1->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig1->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig1->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig1->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig1->getWriteRestartFile(3));
|
||||
|
||||
|
||||
/*Older ECLIPSE 100 data set may use integer controls instead of mnemonics*/
|
||||
//Older ECLIPSE 100 data set may use integer controls instead of mnemonics
|
||||
|
||||
DeckPtr deck2 = parser.parseString(deckData2) ;
|
||||
IOConfigPtr ioConfig2 = std::make_shared<IOConfig>();
|
||||
Schedule schedule2(grid , deck2, ioConfig2);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(3));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(createDeckWithRPTSCHEDandRPTRST) {
|
||||
const char *deckData =
|
||||
"RUNSPEC\n"
|
||||
@@ -1018,8 +1053,8 @@ BOOST_AUTO_TEST_CASE(createDeckWithRPTSCHEDandRPTRST) {
|
||||
Schedule schedule(grid , deck, ioConfig);
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3));
|
||||
}
|
||||
|
||||
|
||||
@@ -446,9 +446,9 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreation) {
|
||||
IOConfigConstPtr ioConfig = state.getIOConfigConst();
|
||||
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3));
|
||||
}
|
||||
|
||||
|
||||
@@ -493,9 +493,9 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTRST) {
|
||||
IOConfigConstPtr ioConfig = state.getIOConfigConst();
|
||||
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(0));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(1));
|
||||
BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(2));
|
||||
BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(3));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user