Merge pull request #2037 from joakim-hove/udq-define-order

Make sure UDQ define statements are evaluated in definition order
This commit is contained in:
Joakim Hove 2020-10-21 17:32:55 +02:00 committed by GitHub
commit ee7f50a51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -154,20 +154,26 @@ namespace Opm {
std::vector<UDQDefine> UDQConfig::definitions() const { std::vector<UDQDefine> UDQConfig::definitions() const {
std::vector<UDQDefine> ret; std::vector<UDQDefine> ret;
for (const auto& key : this->define_order) { for (const auto& index_pair : this->input_index) {
if (this->action_type(key) == UDQAction::DEFINE) if (index_pair.second.action == UDQAction::DEFINE) {
ret.push_back(this->m_definitions.at(key)); const std::string& key = index_pair.first;
ret.push_back( this->m_definitions.at(key) );
}
} }
return ret; return ret;
} }
std::vector<UDQDefine> UDQConfig::definitions(UDQVarType var_type) const { std::vector<UDQDefine> UDQConfig::definitions(UDQVarType var_type) const {
std::vector<UDQDefine> filtered_defines; std::vector<UDQDefine> filtered_defines;
for (const auto& key : this->define_order) { for (const auto& index_pair : this->input_index) {
const auto& udq_define = this->m_definitions.at(key); if (index_pair.second.action == UDQAction::DEFINE) {
if (udq_define.var_type() == var_type && this->action_type(key) == UDQAction::DEFINE) const std::string& key = index_pair.first;
filtered_defines.push_back(udq_define); 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; return filtered_defines;
} }

View File

@ -1816,8 +1816,8 @@ BOOST_AUTO_TEST_CASE(UDQ_DEFINE_ORDER) {
SCHEDULE SCHEDULE
UDQ UDQ
ASSIGN FU_PAR1 1.0 / ASSIGN FU_PAR1 1.0 /
ASSIGN FU_PAR2 0.0 /
DEFINE FU_PAR3 FMWPR / DEFINE FU_PAR3 FMWPR /
ASSIGN FU_PAR2 0.0 /
DEFINE FU_PAR2 FU_PAR3 / DEFINE FU_PAR2 FU_PAR3 /
/ /
)"; )";