Merge pull request #2872 from joakim-hove/schedule-deck-start

Schedule deck start
This commit is contained in:
Joakim Hove 2021-11-26 12:15:01 +01:00 committed by GitHub
commit 4e4f7fc94c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 22 deletions

View File

@ -64,8 +64,8 @@ namespace Opm {
const_iterator begin() const;
const_iterator end() const;
void write(DeckOutput& writer) const;
void write_data(DeckOutput& writer) const;
void write(DeckOutput& writer, std::size_t item_offset = 0) const;
void write_data(DeckOutput& writer, std::size_t item_offset = 0) const;
friend std::ostream& operator<<(std::ostream& os, const DeckRecord& record);
bool equal(const DeckRecord& other, bool cmp_default, bool cmp_numeric) const;

View File

@ -79,6 +79,7 @@ namespace Opm {
m_location.serializeOp(serializer);
}
void dump_time(time_point current_time, DeckOutput& output) const;
void dump_deck(DeckOutput& output, time_point& current_time) const;
private:
ScheduleTimeType m_time_type;
@ -123,7 +124,7 @@ namespace Opm {
class ScheduleDeck {
public:
explicit ScheduleDeck(const Runspec& runspec, const Deck& deck, const ScheduleRestartInfo& rst_info);
explicit ScheduleDeck(time_point start_time, const Deck& deck, const ScheduleRestartInfo& rst_info);
ScheduleDeck();
void add_block(ScheduleTimeType time_type, const time_point& t, ScheduleDeckContext& context, const KeywordLocation& location);
void add_TSTEP(const DeckKeyword& TSTEPKeyword, ScheduleDeckContext& context);

View File

@ -142,14 +142,17 @@ namespace Opm {
}
void DeckRecord::write_data(DeckOutput& writer) const {
for (const auto& item : *this)
void DeckRecord::write_data(DeckOutput& writer, std::size_t item_offset) const {
for (std::size_t item_index = item_offset; item_index < this->size(); item_index++) {
const auto& item = this->getItem(item_index);
item.write( writer );
}
}
void DeckRecord::write(DeckOutput& writer) const {
writer.start_record( );
this->write_data( writer );
void DeckRecord::write(DeckOutput& writer, std::size_t item_offset) const {
if (item_offset == 0)
writer.start_record( );
this->write_data( writer, item_offset );
writer.end_record( );
}

View File

@ -158,7 +158,7 @@ namespace Opm {
const RestartIO::RstState * rst)
try :
m_static( python, ScheduleRestartInfo(rst, deck), deck, runspec, output_interval, parseContext, errors ),
m_sched_deck(runspec, deck, m_static.rst_info ),
m_sched_deck(TimeService::from_time_t(runspec.start_time()), deck, m_static.rst_info ),
completed_cells(ecl_grid.getNX(), ecl_grid.getNY(), ecl_grid.getNZ())
{
this->restart_output.resize(this->m_sched_deck.size());

View File

@ -112,14 +112,12 @@ bool ScheduleBlock::operator==(const ScheduleBlock& other) const {
this->m_keywords == other.m_keywords;
}
namespace {
void dump_time(time_point tp, ScheduleTimeType time_type, time_point current_time, DeckOutput& output) {
if (time_type == ScheduleTimeType::START)
void ScheduleBlock::dump_time(time_point current_time, DeckOutput& output) const {
if (this->m_time_type == ScheduleTimeType::START)
return;
if (time_type == ScheduleTimeType::DATES) {
TimeStampUTC ts(TimeService::to_time_t(tp));
if (this->m_time_type == ScheduleTimeType::DATES) {
TimeStampUTC ts(TimeService::to_time_t(this->start_time()));
auto ecl_month = TimeService::eclipseMonthNames().at(ts.month());
std::string dates_string = fmt::format(R"(
DATES
@ -128,7 +126,7 @@ DATES
)", ts.day(), ecl_month, ts.year());
output.write_string(dates_string);
} else {
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(tp - current_time);
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(this->start_time() - current_time);
double days = seconds.count() / 86400.0;
std::string tstep_string = fmt::format(R"(
TSTEP
@ -138,11 +136,9 @@ TSTEP
}
}
}
void ScheduleBlock::dump_deck(DeckOutput& output, time_point& current_time) const {
dump_time(this->start_time(), this->m_time_type, current_time, output);
this->dump_time(current_time, output);
if (!this->end_time().has_value())
return;
@ -199,9 +195,8 @@ std::size_t ScheduleDeck::restart_offset() const {
}
ScheduleDeck::ScheduleDeck(const Runspec& runspec, const Deck& deck, const ScheduleRestartInfo& rst_info) {
ScheduleDeck::ScheduleDeck(time_point start_time, const Deck& deck, const ScheduleRestartInfo& rst_info) {
const std::unordered_set<std::string> skiprest_include = {"VFPPROD", "VFPINJ", "RPTSCHED", "RPTRST", "TUNING", "MESSAGES"};
time_point start_time = TimeService::from_time_t(runspec.start_time());
this->m_restart_time = TimeService::from_time_t(rst_info.time);
this->m_restart_offset = rst_info.report_step;

View File

@ -4687,7 +4687,8 @@ BOOST_AUTO_TEST_CASE(ScheduleDeckTest) {
{
Parser parser;
auto deck = parser.parseString( createDeckWTEST() );
ScheduleDeck sched_deck( Runspec{deck}, deck, {} );
Runspec runspec{deck};
ScheduleDeck sched_deck( TimeService::from_time_t(runspec.start_time()), deck, {} );
BOOST_CHECK_EQUAL( sched_deck.size(), 6 );
std::vector<std::string> first_kw = {"WELSPECS", "WTEST", "SUMTHIN", "WCONINJH", "WELOPEN", "WCONINJH"};