Make sure UDQ define statements are evaluated in definition order

This commit is contained in:
Joakim Hove 2020-10-21 13:49:07 +02:00
parent 6e82f3cb7a
commit 413a16157c
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> 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<UDQDefine> UDQConfig::definitions(UDQVarType var_type) const {
std::vector<UDQDefine> 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;
}

View File

@ -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 /
/
)";