Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RPTSCHED mnemonics instead of replace (support WELLS=N) #4220

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions opm/input/eclipse/Schedule/RPTConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace {
const auto int_value { std::stoi(mnemonic.substr(pivot + 1)) } ;

if (!(int_value >= 0)) {
OPM_THROW(std::invalid_argument, "RPTSCHED - " + mnemonic + " - mnemonic value must be an integer greater than 1");
OPM_THROW(std::invalid_argument, "RPTSCHED - " + mnemonic + " - mnemonic value must be an integer >= 0");
}

return { mnemonic.substr(0, pivot), int_value } ;
Expand All @@ -51,13 +51,18 @@ RPTConfig RPTConfig::serializationTestObject() {
}


RPTConfig::RPTConfig(const DeckKeyword& keyword) {
RPTConfig::RPTConfig(const DeckKeyword& keyword, const RPTConfig* prev) {
if (prev)
this->m_mnemonics = prev->m_mnemonics;

const auto& mnemonics { keyword.getStringData() } ;
for (const auto& mnemonic : mnemonics) {
if (mnemonic == "NOTHING")
this->m_mnemonics.clear();
else
this->m_mnemonics.emplace(parse_mnemonic(mnemonic));
else {
const auto key_value = parse_mnemonic(mnemonic);
this->m_mnemonics.insert_or_assign(key_value.first, key_value.second);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion opm/input/eclipse/Schedule/RPTConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RPTConfig {
public:
using Map = std::unordered_map<std::string, unsigned>;
RPTConfig() = default;
explicit RPTConfig(const DeckKeyword&);
explicit RPTConfig(const DeckKeyword&, const RPTConfig* prev = nullptr);
bool contains(const std::string& key) const;

template<class Serializer>
Expand All @@ -43,6 +43,7 @@ class RPTConfig {
std::unordered_map<std::string, unsigned>::const_iterator end() const { return this->m_mnemonics.end(); };
std::size_t size() const { return this->m_mnemonics.size(); };
unsigned& at(const std::string& key) { return this->m_mnemonics.at(key); };
unsigned at(const std::string& key) const { return this->m_mnemonics.at(key); };

static RPTConfig serializationTestObject();
bool operator==(const RPTConfig& other) const;
Expand Down
3 changes: 2 additions & 1 deletion opm/input/eclipse/Schedule/RXXKeywordHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void handleRPTONLYO(HandlerContext& handlerContext)

void handleRPTSCHED(HandlerContext& handlerContext)
{
handlerContext.state().rpt_config.update( RPTConfig(handlerContext.keyword ));
const RPTConfig& prev = handlerContext.state().rpt_config.get();
handlerContext.state().rpt_config.update( RPTConfig(handlerContext.keyword, &prev));
auto rst_config = handlerContext.state().rst_config();
rst_config.update(handlerContext.keyword,
handlerContext.parseContext,
Expand Down