Change UDQExpression() constructor to take enum
This commit is contained in:
parent
e00a5d5fa9
commit
e27933270a
@ -33,7 +33,7 @@ namespace Opm {
|
||||
|
||||
class UDQExpression {
|
||||
public:
|
||||
UDQExpression(const std::string& action, const std::string& keyword, const std::vector<std::string>& data);
|
||||
UDQExpression(UDQAction action, const std::string& keyword, const std::vector<std::string>& data);
|
||||
explicit UDQExpression(const DeckRecord& expression);
|
||||
const std::vector<std::string>& tokens() const;
|
||||
UDQAction action() const;
|
||||
|
@ -34,11 +34,11 @@ namespace Opm {
|
||||
|
||||
|
||||
void UDQ::add_record(const DeckRecord& record) {
|
||||
const auto& action = record.getItem("ACTION").get<std::string>(0);
|
||||
auto action = UDQExpression::actionString2Enum(record.getItem("ACTION").get<std::string>(0));
|
||||
const auto& quantity = record.getItem("QUANTITY").get<std::string>(0);
|
||||
const auto& data = record.getItem("DATA").getData<std::string>();
|
||||
|
||||
if (UDQExpression::actionString2Enum(action) == UDQAction::UNITS)
|
||||
if (action == UDQAction::UNITS)
|
||||
this->assign_unit( quantity, data[0] );
|
||||
else
|
||||
this->m_expressions.emplace_back(action, quantity, data);
|
||||
|
@ -57,10 +57,10 @@ namespace Opm {
|
||||
2. For items like '2*(1+WBHP)' the parsing code will expand the 2*
|
||||
operator to the repeated tokens : (1+WBHP), (1+WBHP)
|
||||
*/
|
||||
UDQExpression::UDQExpression(const std::string& action_in, const std::string& keyword_in, const std::vector<std::string>& input_data) {
|
||||
UDQExpression::UDQExpression(UDQAction action, const std::string& keyword_in, const std::vector<std::string>& input_data) {
|
||||
assertKeyword(keyword_in);
|
||||
|
||||
this->m_action = actionString2Enum(action_in);
|
||||
this->m_action = action;
|
||||
this->m_keyword = keyword_in;
|
||||
|
||||
for (const std::string& item : input_data) {
|
||||
@ -96,7 +96,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
UDQExpression::UDQExpression(const DeckRecord& record) :
|
||||
UDQExpression(record.getItem("ACTION").get<std::string>(0),
|
||||
UDQExpression(UDQExpression::actionString2Enum(record.getItem("ACTION").get<std::string>(0)),
|
||||
record.getItem("QUANTITY").get<std::string>(0),
|
||||
record.getItem("DATA").getData<std::string>())
|
||||
|
||||
|
@ -98,7 +98,7 @@ UDQ
|
||||
|
||||
auto schedule = make_schedule(input);
|
||||
const auto& udq = schedule.getUDQConfig(0);
|
||||
BOOST_CHECK_EQUAL(2, udq.expressions().size());
|
||||
BOOST_CHECK_EQUAL(1, udq.expressions().size());
|
||||
|
||||
BOOST_CHECK_THROW( udq.unit("NO_SUCH_KEY"), std::invalid_argument );
|
||||
BOOST_CHECK_EQUAL( udq.unit("WUBHP"), "BARSA");
|
||||
@ -148,12 +148,12 @@ UDQ
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQ_KEYWORD) {
|
||||
// Invalid action
|
||||
BOOST_REQUIRE_THROW( UDQExpression("INVALID_ACTION", "WUBHP" , {"DATA1" ,"1"}), std::invalid_argument);
|
||||
BOOST_REQUIRE_THROW( UDQExpression::actionString2Enum("INVALID_ACTION"), std::invalid_argument);
|
||||
|
||||
// Invalid keyword
|
||||
BOOST_REQUIRE_THROW( UDQExpression("ASSIGN", "INVALID_KEYWORD", {}), std::invalid_argument);
|
||||
BOOST_REQUIRE_THROW( UDQExpression(UDQAction::ASSIGN, "INVALID_KEYWORD", {}), std::invalid_argument);
|
||||
|
||||
BOOST_CHECK_NO_THROW(UDQExpression("ASSIGN" ,"WUBHP", {"1"}));
|
||||
BOOST_CHECK_NO_THROW(UDQExpression(UDQAction::ASSIGN ,"WUBHP", {"1"}));
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ UDQPARAM
|
||||
SCHEDULE
|
||||
|
||||
UDQ
|
||||
ASSIGN CUMW1 P12 10 12 1 (4.0 + 6*(4 - 2)) /
|
||||
DEFINE CUMW1 P12 10 12 1 (4.0 + 6*(4 - 2)) /
|
||||
DEFINE WUMW1 WBHP 'P*1*' UMAX WBHP 'P*4*' /
|
||||
/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user