From b1ddf6deb521cecf8522dd4f70b509713e763520 Mon Sep 17 00:00:00 2001 From: chflo Date: Mon, 21 Sep 2015 11:36:04 +0200 Subject: [PATCH] OPM-218-fix: Fix in method getWriteRestartFileFrequency() for rptrst basic=3/4/5 --- .../EclipseState/IOConfig/IOConfig.cpp | 29 ++---- .../EclipseState/IOConfig/IOConfig.hpp | 88 ++++++++++++++++++- 2 files changed, 91 insertions(+), 26 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp index 059d38977..feaeceebf 100644 --- a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp +++ b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp @@ -91,33 +91,16 @@ namespace Opm { bool IOConfig::getWriteRestartFileFrequency(size_t timestep, - size_t start_index, + size_t start_timestep, size_t frequency, - bool first_timesteps_years, - bool first_timesteps_months) const { + bool years, + bool months) const { bool write_restart_file = false; - if (!first_timesteps_years && !first_timesteps_months) { - write_restart_file = (((timestep-start_index) % frequency) == 0) ? true : false; + if ((!years && !months) && (timestep >= start_timestep)) { + write_restart_file = ((timestep % frequency) == 0) ? true : false; } else { - std::vector timesteps; - if (first_timesteps_years) { - m_timemap->initFirstTimestepsYears(timesteps, start_index); - } else { - m_timemap->initFirstTimestepsMonths(timesteps, start_index); - } - std::vector::const_iterator ci_timestep = std::find(timesteps.begin(), timesteps.end(), timestep); + write_restart_file = m_timemap->isTimestepInFirstOfMonthsYearsSequence(timestep, years, start_timestep, frequency); - if (ci_timestep != timesteps.end()) { - if (1 >= frequency) { - write_restart_file = true; - } else { - std::vector::const_iterator ci_start = timesteps.begin(); - int dist = std::distance( ci_start, ci_timestep ) + 1; - if( ( (dist > 0) && ((dist % frequency) == 0) ) ) { - write_restart_file = true; - } - } - } } return write_restart_file; } diff --git a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp index 60feddfb0..2f3ffa5e2 100644 --- a/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp +++ b/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp @@ -27,6 +27,87 @@ namespace Opm { + /*The IOConfig class holds data about input / ouput configurations + + Amongst these configuration settings, a IOConfig object knows if + a restart file should be written for a specific report step + + The write of restart files is governed by several eclipse keywords. + These keywords are all described in the eclipse manual, but some + of them are rather porly described there. + To have equal sets of restart files written from Eclipse and Flow for various + configurations, we have made a qualified guess on the behaviour + for some of the keywords (by running eclipse for different configurations, + and looked at which restart files that have been written). + + + ------ RPTSOL RESTART (solution section) ------ + If RPTSOL RESTART > 1 initial restart file is written. + + + ------ RPTRST (solution section) ------ + Eclipse manual states that the initial restart file is to be written + if RPTSOL RESTART > 1. But - due to that the initial restart file + is written from Eclipse for data where RPTSOL RESTART is not set, - we + have made a guess that when RPTRST is set in SOLUTION (no basic though...), + it means that the initial restart file should be written. + Running of eclipse with different settings have proven this to be a qualified guess. + + + ------ RPTRST BASIC=0 (solution or schedule section) ------ + No restart files are written + + + ------ RPTRST BASIC=1 or RPTRST BASIC=2 (solution or schedule section) ------ + Restart files are written for every timestep, from timestep 1 to number of timesteps. + (Write of inital timestep is governed by a separate setting) + + Notice! Eclipse simulator RPTRST BASIC=1 writes restart files for every + report step, but only keeps the last one written. This functionality is + not supported in Flow; so to compare Eclipse results with Flow results + for every report step, set RPTRST BASIC=2 for the eclipse run + + + ------ RPTRST BASIC=3 FREQ=n (solution or schedule section) ------ + Restart files are created every nth report time. Default frequency is 1 (every report step) + + If a frequency higher than 1 is given: + start_rs = report step the setting was given. + write report step rstep if (rstep >= start_rs) && ((rstep % frequency) == 0). + + + ------ RPTRST BASIC=4 FREQ=n or RPTRST BASIC=5 FREQ=n (solution or schedule section) ------ + For the settings BASIC 4 or BASIC 5, - first report step of every new year(4) or new month(5), + the first report step is compared with report step 0 (start), and then every report step is + compared with the previous one to see if year/month has changed. + + This leaves us with a set of timesteps. + All timesteps in the set that are higher or equal to the timestep the RPTRST keyword was set on is written. + + If in addition FREQUENCY is given (higher than 1), every n'the value of this set are to be written. + + If the setting BASIC=4 or BASIC=5 is set on a timestep that is a member of the set "first timestep of + each year" / "First timestep of each month", then the timestep that is freq-1 timesteps (within the set) from + this start timestep will be written, and then every n'the timestep (within the set) from this one will be written. + + If the setting BASIC=4 or BASIC=5 is set on a timestep that is not a member of the list "first timestep of + each year" / "First timestep of each month", then the list is searched for the closest timestep that are + larger than the timestep that introduced the setting, and then; same as above - the timestep that is freq-1 + timesteps from this one (within the set) will be written, and then every n'the timestep (within the set) from + this one will be written. + + + ------ RPTRST BASIC=6 (solution or schedule section) ------ + Not supported in Flow + + + ------ Default ------ + If no keywords for config of writing restart files have been handled; no restart files are written. + + */ + + + class IOConfig { public: @@ -66,10 +147,10 @@ namespace Opm { void assertTimeMap(TimeMapConstPtr timemap); bool getWriteRestartFileFrequency(size_t timestep, - size_t start_index, + size_t start_timestep, size_t frequency, - bool first_timesteps_years = false, - bool first_timesteps_months = false) const; + bool years = false, + bool months = false) const; void handleRPTSOL(DeckKeywordConstPtr keyword); @@ -115,6 +196,7 @@ namespace Opm { std::shared_ptr> m_restart_output_config; + };