Add UDQVartype member to assignment and expression

This commit is contained in:
Joakim Hove 2019-02-21 12:32:14 +01:00
parent b5542c4e56
commit 19988494c0
4 changed files with 12 additions and 21 deletions

View File

@ -25,6 +25,7 @@
#include <vector>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
@ -37,6 +38,7 @@ public:
UDQWellSet eval_wells(const std::vector<std::string>& wells) const;
private:
std::string m_keyword;
UDQVarType m_var_type;
std::vector<std::string> m_selector;
double m_value;
};

View File

@ -24,6 +24,7 @@
#include <vector>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
@ -42,6 +43,7 @@ namespace Opm {
private:
UDQAction m_action;
std::string m_keyword;
UDQVarType m_var_type;
std::vector<std::string> data;
};
}

View File

@ -18,11 +18,13 @@
*/
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
UDQAssign::UDQAssign(const std::string& keyword, const std::vector<std::string>& selector, double value) :
m_keyword(keyword),
m_var_type(UDQ::varType(keyword)),
m_selector(selector),
m_value(value)
{}

View File

@ -24,6 +24,7 @@
#include <opm/parser/eclipse/RawDeck/RawConsts.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQExpression.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
@ -32,21 +33,6 @@
namespace Opm {
namespace {
void assertKeyword(const std::string& keyword) {
const std::string valid_start = "CFGRSWAB";
if (valid_start.find(keyword[0]) == std::string::npos)
throw std::invalid_argument("Leading character must be in set: " + valid_start);
if (!(keyword[1] == 'U'))
throw std::invalid_argument("Second character in UDQ keyword must be 'U'");
}
}
/*
The tokenizer algorithm has two problems with '*':
@ -57,12 +43,11 @@ 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(UDQAction action, const std::string& keyword_in, const std::vector<std::string>& input_data) {
assertKeyword(keyword_in);
this->m_action = action;
this->m_keyword = keyword_in;
UDQExpression::UDQExpression(UDQAction action, const std::string& keyword_in, const std::vector<std::string>& input_data) :
m_action(action),
m_keyword(keyword_in),
m_var_type(UDQ::varType(keyword_in))
{
for (const std::string& item : input_data) {
if (RawConsts::is_quote()(item[0])) {
this->data.push_back(item.substr(1, item.size() - 2));