Add unit to UDQInput class

This commit is contained in:
Joakim Hove
2019-07-29 10:17:20 +02:00
committed by Jostein Alvestad
parent 520df29bd8
commit 5e751bb26c
4 changed files with 21 additions and 17 deletions

View File

@@ -50,8 +50,8 @@ public:
class UDQInput{
public:
UDQInput(const UDQIndex& index, const UDQDefine& udq_define);
UDQInput(const UDQIndex& index, const UDQAssign& udq_assign);
UDQInput(const UDQIndex& index, const UDQDefine& udq_define, const std::string& unit);
UDQInput(const UDQIndex& index, const UDQAssign& udq_assign, const std::string& unit);
template<typename T>
const T& get() const;
@@ -61,12 +61,14 @@ public:
const std::string& keyword() const;
UDQVarType var_type() const;
const std::string& unit() const;
const UDQIndex index;
private:
UDQIndex index;
const UDQDefine * define;
const UDQAssign * assign;
const std::string m_keyword;
UDQVarType m_var_type;
const std::string m_unit;
};
}

View File

@@ -114,12 +114,16 @@ namespace Opm {
std::vector<UDQInput> res;
for (const auto& index_pair : this->input_index) {
const UDQIndex& index = index_pair.second;
std::string u;
if (this->has_unit(index_pair.first))
u = this->unit(index_pair.first);
if (index.action == UDQAction::DEFINE) {
const std::string& key = index_pair.first;
res.push_back(UDQInput(index, this->m_definitions.at(key)));
res.push_back(UDQInput(index, this->m_definitions.at(key), u));
} else if (index_pair.second.action == UDQAction::ASSIGN) {
const std::string& key = index_pair.first;
res.push_back(UDQInput(index, this->m_assignments.at(key)));
res.push_back(UDQInput(index, this->m_assignments.at(key), u));
}
}
return res;

View File

@@ -25,31 +25,28 @@
namespace Opm {
UDQInput::UDQInput(const UDQIndex& index_arg, const UDQDefine& udq_define) :
UDQInput::UDQInput(const UDQIndex& index_arg, const UDQDefine& udq_define, const std::string& unit_arg) :
index(index_arg),
define(std::addressof(udq_define)),
<<<<<<< HEAD
assign(nullptr)
=======
assign(nullptr),
m_keyword(udq_define.keyword()),
m_var_type(udq_define.var_type())
>>>>>>> 302d82969... Add UDQVarTYpe member to UDQInput class
m_var_type(udq_define.var_type()),
m_unit(unit_arg)
{}
UDQInput::UDQInput(const UDQIndex& index_arg, const UDQAssign& udq_assign):
UDQInput::UDQInput(const UDQIndex& index_arg, const UDQAssign& udq_assign, const std::string& unit_arg):
index(index_arg),
define(nullptr),
<<<<<<< HEAD
assign(std::addressof(udq_assign))
=======
assign(std::addressof(udq_assign)),
m_keyword(udq_assign.keyword()),
m_var_type(udq_assign.var_type())
>>>>>>> 302d82969... Add UDQVarTYpe member to UDQInput class
m_var_type(udq_assign.var_type()),
m_unit(unit_arg)
{}
const std::string& UDQInput::unit() const {
return this->m_unit;
}
template<>
bool UDQInput::is<UDQAssign>() const {

View File

@@ -1187,6 +1187,7 @@ UDQ
BOOST_CHECK( input[5].is<UDQAssign>() );
BOOST_CHECK( input[6].is<UDQDefine>() );
BOOST_CHECK_EQUAL( input[4].unit(), "SM3/DAY" );
BOOST_CHECK_EQUAL(def[0].keyword(), "WUWCT");
BOOST_CHECK_EQUAL(def[1].keyword(), "FUOPR");