Merge pull request #2872 from joakim-hove/schedule-deck-start
Schedule deck start
This commit is contained in:
commit
4e4f7fc94c
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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( );
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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"};
|
||||
|
Loading…
Reference in New Issue
Block a user