Skip to content

Commit

Permalink
changed: only store keywords in sched_deck if there are actions
Browse files Browse the repository at this point in the history
  • Loading branch information
akva2 committed Sep 26, 2024
1 parent 27a6e80 commit 184885a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions opm/input/eclipse/Schedule/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ namespace Opm {
this->snapshots[restart_step].update_events(this->snapshots[prev_step].events());
} else {
this->iterateScheduleSection( 0, this->m_sched_deck.size(), parseContext, errors, grid, nullptr, "");
const auto& section = SCHEDULESection(deck);
const bool has_actions = section.has_keyword("ACTIONX") ||
section.has_keyword("PYACTION");
if (!has_actions) {
m_sched_deck.clearKeywords();
}
}
}
catch (const OpmInputError& opm_error) {
Expand Down
5 changes: 5 additions & 0 deletions opm/input/eclipse/Schedule/ScheduleBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,9 @@ TSTEP
output.write_string(tstep_string);
}

void ScheduleBlock::clearKeywords()
{
m_keywords.clear();
}

} // namespace Opm
2 changes: 2 additions & 0 deletions opm/input/eclipse/Schedule/ScheduleBlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class ScheduleBlock
bool operator==(const ScheduleBlock& other) const;
static ScheduleBlock serializationTestObject();

void clearKeywords();

template<class Serializer>
void serializeOp(Serializer& serializer)
{
Expand Down
17 changes: 15 additions & 2 deletions opm/input/eclipse/Schedule/ScheduleDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ScheduleDeck::ScheduleDeck(time_point start_time, const Deck& deck, const Schedu
this->m_blocks.emplace_back(KeywordLocation{}, ScheduleTimeType::START, start_time);

ScheduleDeckContext context(this->skiprest, this->m_blocks.back().start_time());
const auto& section = SCHEDULESection(deck);
for( const auto& keyword : SCHEDULESection(deck)) {
if (keyword.name() == "DATES") {
for (size_t recordIndex = 0; recordIndex < keyword.size(); recordIndex++) {
Expand Down Expand Up @@ -128,8 +129,9 @@ ScheduleDeck::ScheduleDeck(time_point start_time, const Deck& deck, const Schedu
if (context.rst_skip) {
if (skiprest_include.count(keyword.name()) != 0)
this->m_blocks[0].push_back(keyword);
} else
} else {
this->m_blocks.back().push_back(keyword);
}
}
}

Expand Down Expand Up @@ -178,7 +180,11 @@ namespace {
}
}

void ScheduleDeck::add_block(ScheduleTimeType time_type, const time_point& t, ScheduleDeckContext& context, const KeywordLocation& location) {
void ScheduleDeck::add_block(ScheduleTimeType time_type,
const time_point& t,
ScheduleDeckContext& context,
const KeywordLocation& location)
{
context.last_time = t;
if (context.rst_skip) {
if (t < this->m_restart_time)
Expand Down Expand Up @@ -287,5 +293,12 @@ void ScheduleDeck::dump_deck(std::ostream& os,
}
}

void ScheduleDeck::clearKeywords()
{
for (auto& block : m_blocks) {
block.clearKeywords();
}
}


}
2 changes: 2 additions & 0 deletions opm/input/eclipse/Schedule/ScheduleDeck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ namespace Opm {

void dump_deck(std::ostream& os, const UnitSystem& usys) const;

void clearKeywords();

private:
time_point m_restart_time;
std::size_t m_restart_offset;
Expand Down

0 comments on commit 184885a

Please sign in to comment.