From 413a16157cf5dcb1acbb7436df290f45c0180248 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 21 Oct 2020 13:49:07 +0200 Subject: [PATCH] Make sure UDQ define statements are evaluated in definition order --- .../EclipseState/Schedule/UDQ/UDQConfig.cpp | 20 ++++++++++++------- tests/parser/UDQTests.cpp | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp index 9fd484da6..6a2c3e4ea 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp @@ -154,20 +154,26 @@ namespace Opm { std::vector UDQConfig::definitions() const { std::vector ret; - for (const auto& key : this->define_order) { - if (this->action_type(key) == UDQAction::DEFINE) - ret.push_back(this->m_definitions.at(key)); + for (const auto& index_pair : this->input_index) { + if (index_pair.second.action == UDQAction::DEFINE) { + const std::string& key = index_pair.first; + ret.push_back( this->m_definitions.at(key) ); + } } + return ret; } std::vector UDQConfig::definitions(UDQVarType var_type) const { std::vector filtered_defines; - for (const auto& key : this->define_order) { - const auto& udq_define = this->m_definitions.at(key); - if (udq_define.var_type() == var_type && this->action_type(key) == UDQAction::DEFINE) - filtered_defines.push_back(udq_define); + for (const auto& index_pair : this->input_index) { + if (index_pair.second.action == UDQAction::DEFINE) { + const std::string& key = index_pair.first; + const auto& udq_define = this->m_definitions.at(key); + if (udq_define.var_type() == var_type) + filtered_defines.push_back(udq_define); + } } return filtered_defines; } diff --git a/tests/parser/UDQTests.cpp b/tests/parser/UDQTests.cpp index 75d5db8e7..c41d26135 100644 --- a/tests/parser/UDQTests.cpp +++ b/tests/parser/UDQTests.cpp @@ -1809,8 +1809,8 @@ BOOST_AUTO_TEST_CASE(UDQ_DEFINE_ORDER) { SCHEDULE UDQ ASSIGN FU_PAR1 1.0 / -ASSIGN FU_PAR2 0.0 / DEFINE FU_PAR3 FMWPR / +ASSIGN FU_PAR2 0.0 / DEFINE FU_PAR2 FU_PAR3 / / )";