Merge pull request #1382 from akva2/noecl_flush
More serialization preparation
This commit is contained in:
commit
9363905e03
@ -651,6 +651,7 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/checkDeck.hpp
|
||||
opm/parser/eclipse/EclipseState/Runspec.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp
|
||||
|
@ -35,13 +35,19 @@ namespace Opm {
|
||||
|
||||
class UDQASTNode {
|
||||
public:
|
||||
UDQASTNode();
|
||||
explicit UDQASTNode(UDQTokenType type_arg);
|
||||
explicit UDQASTNode(double scalar_value);
|
||||
UDQASTNode(UDQTokenType type_arg, const std::string& func_name, const UDQASTNode& arg);
|
||||
UDQASTNode(UDQTokenType type_arg, const std::string& func_name, const UDQASTNode& left, const UDQASTNode& right);
|
||||
UDQASTNode(UDQTokenType type_arg, const std::string& func_name);
|
||||
UDQASTNode(UDQTokenType type_arg, const std::string& string_value, const std::vector<std::string>& selector);
|
||||
|
||||
UDQASTNode(UDQVarType varType, UDQTokenType typ,
|
||||
const std::string& stringVal,
|
||||
double scalarVal,
|
||||
const std::vector<std::string>& selectors,
|
||||
const std::shared_ptr<UDQASTNode>& left_arg,
|
||||
const std::shared_ptr<UDQASTNode>& right_arg);
|
||||
|
||||
UDQSet eval(UDQVarType eval_target, const UDQContext& context) const;
|
||||
|
||||
@ -53,6 +59,16 @@ public:
|
||||
void set_right(const UDQASTNode& arg);
|
||||
UDQASTNode* get_left() const;
|
||||
UDQASTNode* get_right() const;
|
||||
|
||||
bool operator==(const UDQASTNode& data) const;
|
||||
|
||||
const std::string& stringValue() const;
|
||||
UDQTokenType getType() const;
|
||||
double scalarValue() const;
|
||||
const std::vector<std::string>& getSelectors() const;
|
||||
const std::shared_ptr<UDQASTNode>& getLeft() const;
|
||||
const std::shared_ptr<UDQASTNode>& getRight() const;
|
||||
|
||||
private:
|
||||
UDQTokenType type;
|
||||
void func_tokens(std::set<UDQTokenType>& tokens) const;
|
@ -37,6 +37,13 @@ public:
|
||||
|
||||
class Record{
|
||||
public:
|
||||
Record() :
|
||||
input_index(0),
|
||||
control(UDAControl::WCONPROD_ORAT),
|
||||
uad_code(0),
|
||||
use_count(1)
|
||||
{}
|
||||
|
||||
Record(const std::string& udq_arg, std::size_t input_index_arg, std::size_t use_index_arg, const std::string& wgname_arg, UDAControl control_arg) :
|
||||
udq(udq_arg),
|
||||
input_index(input_index_arg),
|
||||
@ -74,6 +81,11 @@ public:
|
||||
|
||||
class InputRecord {
|
||||
public:
|
||||
InputRecord() :
|
||||
input_index(0),
|
||||
control(UDAControl::WCONPROD_ORAT)
|
||||
{}
|
||||
|
||||
InputRecord(std::size_t input_index_arg, const std::string& udq_arg, const std::string& wgname_arg, UDAControl control_arg) :
|
||||
input_index(input_index_arg),
|
||||
udq(udq_arg),
|
||||
@ -81,12 +93,24 @@ public:
|
||||
control(control_arg)
|
||||
{}
|
||||
|
||||
bool operator==(const InputRecord& other) const {
|
||||
return this->input_index == other.input_index &&
|
||||
this->udq == other.udq &&
|
||||
this->wgname == other.wgname &&
|
||||
this->control == other.control;
|
||||
}
|
||||
|
||||
std::size_t input_index;
|
||||
std::string udq;
|
||||
std::string wgname;
|
||||
UDAControl control;
|
||||
};
|
||||
|
||||
UDQActive() = default;
|
||||
UDQActive(const std::vector<InputRecord>& inputRecs,
|
||||
const std::vector<Record>& outputRecs,
|
||||
const std::unordered_map<std::string,std::size_t>& udqkeys,
|
||||
const std::unordered_map<std::string,std::size_t>& wgkeys);
|
||||
int update(const UDQConfig& udq_config, const UDAValue& uda, const std::string& wgname, UDAControl control);
|
||||
std::size_t IUAD_size() const;
|
||||
std::size_t IUAP_size() const;
|
||||
@ -94,6 +118,14 @@ public:
|
||||
Record operator[](std::size_t index) const;
|
||||
const std::vector<Record>& get_iuad() const;
|
||||
std::vector<InputRecord> get_iuap() const;
|
||||
|
||||
const std::vector<InputRecord>& getInputRecords() const;
|
||||
const std::vector<Record>& getOutputRecords() const;
|
||||
const std::unordered_map<std::string, std::size_t>& getUdqKeys() const;
|
||||
const std::unordered_map<std::string, std::size_t>& getWgKeys() const;
|
||||
|
||||
bool operator==(const UDQActive& data) const;
|
||||
|
||||
private:
|
||||
std::string udq_hash(const std::string& udq, UDAControl control);
|
||||
std::string wg_hash(const std::string& wgname, UDAControl control);
|
||||
|
@ -42,13 +42,28 @@ public:
|
||||
struct AssignRecord {
|
||||
std::vector<std::string> selector;
|
||||
double value;
|
||||
|
||||
bool operator==(const AssignRecord& data) const {
|
||||
return selector == data.selector &&
|
||||
value == data.value;
|
||||
}
|
||||
};
|
||||
|
||||
UDQAssign();
|
||||
UDQAssign(const std::string& keyword, const std::vector<std::string>& selector, double value);
|
||||
UDQAssign(const std::string& keyword,
|
||||
UDQVarType varType,
|
||||
const std::vector<AssignRecord>& records);
|
||||
|
||||
const std::string& keyword() const;
|
||||
UDQVarType var_type() const;
|
||||
void add_record(const std::vector<std::string>& selector, double value);
|
||||
UDQSet eval(const std::vector<std::string>& wells) const;
|
||||
|
||||
const std::vector<AssignRecord>& getRecords() const;
|
||||
|
||||
bool operator==(const UDQAssign& data) const;
|
||||
|
||||
private:
|
||||
std::string m_keyword;
|
||||
UDQVarType m_var_type;
|
||||
|
@ -40,8 +40,18 @@ namespace Opm {
|
||||
class Deck;
|
||||
class UDQConfig {
|
||||
public:
|
||||
UDQConfig() = default;
|
||||
explicit UDQConfig(const Deck& deck);
|
||||
explicit UDQConfig(const UDQParams& params);
|
||||
UDQConfig(const UDQParams& params,
|
||||
const UDQFunctionTable& funcTable,
|
||||
const std::unordered_map<std::string, UDQDefine>& definition,
|
||||
const std::unordered_map<std::string, UDQAssign>& assignment,
|
||||
const std::unordered_map<std::string, std::string>& unit,
|
||||
const OrderedMap<std::string, UDQIndex>& inputIdx,
|
||||
const std::map<UDQVarType, std::size_t>& tCount);
|
||||
|
||||
|
||||
const std::string& unit(const std::string& key) const;
|
||||
bool has_unit(const std::string& keyword) const;
|
||||
bool has_keyword(const std::string& keyword) const;
|
||||
@ -52,6 +62,11 @@ namespace Opm {
|
||||
void add_define(const std::string& quantity, const std::vector<std::string>& expression);
|
||||
|
||||
std::vector<UDQDefine> definitions() const;
|
||||
const std::unordered_map<std::string, UDQDefine>& definitionMap() const;
|
||||
const std::unordered_map<std::string, UDQAssign>& assignmentMap() const;
|
||||
const std::unordered_map<std::string, std::string>& unitsMap() const;
|
||||
const OrderedMap<std::string, UDQIndex>& inputIndex() const;
|
||||
const std::map<UDQVarType, std::size_t>& typeCount() const;
|
||||
std::vector<UDQDefine> definitions(UDQVarType var_type) const;
|
||||
std::vector<UDQInput> input() const;
|
||||
|
||||
@ -66,6 +81,9 @@ namespace Opm {
|
||||
std::vector<UDQAssign> assignments(UDQVarType var_type) const;
|
||||
const UDQParams& params() const;
|
||||
const UDQFunctionTable& function_table() const;
|
||||
|
||||
bool operator==(const UDQConfig& config) const;
|
||||
|
||||
private:
|
||||
void add_node(const std::string& quantity, UDQAction action);
|
||||
|
||||
|
@ -38,6 +38,8 @@ class ErrorGuard;
|
||||
|
||||
class UDQDefine{
|
||||
public:
|
||||
UDQDefine();
|
||||
|
||||
UDQDefine(const UDQParams& udq_params,
|
||||
const std::string& keyword,
|
||||
const std::vector<std::string>& deck_data);
|
||||
@ -55,14 +57,21 @@ public:
|
||||
const ParseContext& parseContext,
|
||||
T&& errors);
|
||||
|
||||
UDQDefine(const std::string& keyword,
|
||||
std::shared_ptr<UDQASTNode> astPtr,
|
||||
UDQVarType type,
|
||||
const std::string& string_data);
|
||||
|
||||
UDQSet eval(const UDQContext& context) const;
|
||||
const std::string& keyword() const;
|
||||
const std::string& input_string() const;
|
||||
UDQVarType var_type() const;
|
||||
std::set<UDQTokenType> func_tokens() const;
|
||||
std::shared_ptr<UDQASTNode> getAst() const;
|
||||
|
||||
bool operator==(const UDQDefine& data) const;
|
||||
|
||||
private:
|
||||
const UDQParams& udq_params; // Beacuse of the shared RNG stream this must be a reference.
|
||||
std::string m_keyword;
|
||||
std::shared_ptr<UDQASTNode> ast;
|
||||
UDQVarType m_var_type;
|
||||
|
@ -33,10 +33,14 @@ namespace Opm {
|
||||
|
||||
class UDQFunction {
|
||||
public:
|
||||
UDQFunction() : func_type(UDQTokenType::error) {}
|
||||
UDQFunction(const std::string& name);
|
||||
UDQFunction(const std::string& name, UDQTokenType funcType);
|
||||
virtual ~UDQFunction() = default;
|
||||
const std::string& name() const;
|
||||
UDQTokenType type() const;
|
||||
bool operator==(const UDQFunction& data) const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
UDQTokenType func_type;
|
||||
|
@ -30,14 +30,24 @@ namespace Opm {
|
||||
|
||||
class UDQFunctionTable {
|
||||
public:
|
||||
using FunctionMap = std::unordered_map<std::string,
|
||||
std::shared_ptr<UDQFunction>>;
|
||||
explicit UDQFunctionTable(const UDQParams& params);
|
||||
UDQFunctionTable();
|
||||
UDQFunctionTable(const UDQParams& param,
|
||||
const FunctionMap& map);
|
||||
bool has_function(const std::string& name) const;
|
||||
const UDQFunction& get(const std::string& name) const;
|
||||
|
||||
const UDQParams& getParams() const;
|
||||
const FunctionMap& functionMap() const;
|
||||
|
||||
bool operator==(const UDQFunctionTable& data) const;
|
||||
|
||||
private:
|
||||
void insert_function(std::shared_ptr<const UDQFunction> func);
|
||||
void insert_function(std::shared_ptr<UDQFunction> func);
|
||||
UDQParams params;
|
||||
std::unordered_map<std::string, std::shared_ptr<const UDQFunction>> function_table;
|
||||
FunctionMap function_table;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -42,6 +42,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const UDQIndex& data) const {
|
||||
return insert_index == data.insert_index &&
|
||||
typed_insert_index == data.typed_insert_index &&
|
||||
action == data.action &&
|
||||
var_type == data.var_type;
|
||||
}
|
||||
|
||||
|
||||
std::size_t insert_index;
|
||||
std::size_t typed_insert_index;
|
||||
|
@ -26,14 +26,20 @@ namespace Opm {
|
||||
class WList {
|
||||
public:
|
||||
using storage = std::unordered_set<std::string>;
|
||||
|
||||
WList() = default;
|
||||
WList(const storage& wlist);
|
||||
std::size_t size() const;
|
||||
void add(const std::string& well);
|
||||
void del(const std::string& well);
|
||||
bool has(const std::string& well) const;
|
||||
|
||||
std::vector<std::string> wells() const;
|
||||
const storage& wellList() const;
|
||||
storage::const_iterator begin() const;
|
||||
storage::const_iterator end() const;
|
||||
|
||||
bool operator==(const WList& data) const;
|
||||
private:
|
||||
storage well_list;
|
||||
};
|
||||
|
@ -27,11 +27,17 @@ class WList;
|
||||
|
||||
class WListManager {
|
||||
public:
|
||||
WListManager() = default;
|
||||
WListManager(const std::map<std::string,WList>& list);
|
||||
bool hasList(const std::string&) const;
|
||||
WList& getList(const std::string& name);
|
||||
const WList& getList(const std::string& name) const;
|
||||
WList& newList(const std::string& name);
|
||||
void delWell(const std::string& well);
|
||||
|
||||
const std::map<std::string,WList>& lists() const;
|
||||
bool operator==(const WListManager& data) const;
|
||||
|
||||
private:
|
||||
std::map<std::string, WList> wlists;
|
||||
};
|
||||
|
@ -18,14 +18,16 @@
|
||||
*/
|
||||
#include <fnmatch.h>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
|
||||
#include "UDQASTNode.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
UDQASTNode::UDQASTNode() :
|
||||
UDQASTNode(UDQTokenType::error)
|
||||
{}
|
||||
|
||||
|
||||
UDQASTNode::UDQASTNode(UDQTokenType type_arg) :
|
||||
@ -102,6 +104,22 @@ UDQASTNode::UDQASTNode(UDQTokenType type_arg,
|
||||
}
|
||||
|
||||
|
||||
UDQASTNode::UDQASTNode(UDQVarType varType, UDQTokenType typ,
|
||||
const std::string& stringVal,
|
||||
double scalarVal,
|
||||
const std::vector<std::string>& selectors,
|
||||
const std::shared_ptr<UDQASTNode>& left_arg,
|
||||
const std::shared_ptr<UDQASTNode>& right_arg) :
|
||||
var_type(varType),
|
||||
type(typ),
|
||||
string_value(stringVal),
|
||||
selector(selectors),
|
||||
scalar_value(scalarVal),
|
||||
left(left_arg),
|
||||
right(right_arg)
|
||||
{}
|
||||
|
||||
|
||||
UDQASTNode::UDQASTNode(UDQTokenType type_arg,
|
||||
const std::string& string_value_arg,
|
||||
const std::vector<std::string>& selector_arg) :
|
||||
@ -275,4 +293,50 @@ void UDQASTNode::set_right(const UDQASTNode& arg) {
|
||||
this->update_type(arg);
|
||||
}
|
||||
|
||||
bool UDQASTNode::operator==(const UDQASTNode& data) const {
|
||||
if ((this->getLeft() && !data.getLeft()) ||
|
||||
(!this->getLeft() && data.getLeft()))
|
||||
return false;
|
||||
|
||||
if (this->getLeft() && !(*this->getLeft() == *data.getLeft()))
|
||||
return false;
|
||||
|
||||
if ((this->getRight() && !data.getRight()) ||
|
||||
(!this->getRight() && data.getRight()))
|
||||
return false;
|
||||
|
||||
if (this->getRight() && !(*this->getRight() == *data.getRight()))
|
||||
return false;
|
||||
|
||||
return type == data.type &&
|
||||
var_type == data.var_type &&
|
||||
string_value == data.string_value &&
|
||||
scalar_value == data.scalar_value &&
|
||||
selector == data.selector;
|
||||
}
|
||||
|
||||
const std::string& UDQASTNode::stringValue() const {
|
||||
return string_value;
|
||||
}
|
||||
|
||||
double UDQASTNode::scalarValue() const {
|
||||
return scalar_value;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& UDQASTNode::getSelectors() const {
|
||||
return selector;
|
||||
}
|
||||
|
||||
const std::shared_ptr<UDQASTNode>& UDQASTNode::getLeft() const {
|
||||
return left;
|
||||
}
|
||||
|
||||
const std::shared_ptr<UDQASTNode>& UDQASTNode::getRight() const {
|
||||
return right;
|
||||
}
|
||||
|
||||
UDQTokenType UDQASTNode::getType() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,16 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
UDQActive::UDQActive(const std::vector<InputRecord>& inputRecs,
|
||||
const std::vector<Record>& outputRecs,
|
||||
const std::unordered_map<std::string,std::size_t>& udqkeys,
|
||||
const std::unordered_map<std::string,std::size_t>& wgkeys)
|
||||
: input_data(inputRecs)
|
||||
, output_data(outputRecs)
|
||||
, udq_keys(udqkeys)
|
||||
, wg_keys(wgkeys)
|
||||
{}
|
||||
|
||||
std::size_t UDQActive::IUAD_size() const {
|
||||
const auto& output = this->get_iuad();
|
||||
return output.size();
|
||||
@ -173,6 +183,30 @@ UDQActive::Record UDQActive::operator[](std::size_t index) const {
|
||||
return output_record;
|
||||
}
|
||||
|
||||
const std::vector<UDQActive::InputRecord>& UDQActive::getInputRecords() const {
|
||||
return input_data;
|
||||
}
|
||||
|
||||
const std::vector<UDQActive::Record>& UDQActive::getOutputRecords() const {
|
||||
return output_data;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::size_t>& UDQActive::getUdqKeys() const {
|
||||
return udq_keys;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, std::size_t>& UDQActive::getWgKeys() const {
|
||||
return wg_keys;
|
||||
}
|
||||
|
||||
|
||||
bool UDQActive::operator==(const UDQActive& data) const {
|
||||
return this->getInputRecords() == data.getInputRecords() &&
|
||||
this->getOutputRecords() == data.getOutputRecords() &&
|
||||
this->getUdqKeys() == data.getUdqKeys() &&
|
||||
this->getWgKeys() == data.getWgKeys();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,11 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
UDQAssign::UDQAssign() :
|
||||
m_var_type(UDQVarType::NONE)
|
||||
{
|
||||
}
|
||||
|
||||
UDQAssign::UDQAssign(const std::string& keyword, const std::vector<std::string>& selector, double value) :
|
||||
m_keyword(keyword),
|
||||
m_var_type(UDQ::varType(keyword))
|
||||
@ -29,6 +34,15 @@ UDQAssign::UDQAssign(const std::string& keyword, const std::vector<std::string>&
|
||||
this->add_record(selector, value);
|
||||
}
|
||||
|
||||
UDQAssign::UDQAssign(const std::string& keyword,
|
||||
UDQVarType varType,
|
||||
const std::vector<AssignRecord>& record) :
|
||||
m_keyword(keyword),
|
||||
m_var_type(varType),
|
||||
records(record)
|
||||
{
|
||||
}
|
||||
|
||||
void UDQAssign::add_record(const std::vector<std::string>& selector, double value) {
|
||||
this->records.push_back({selector, value});
|
||||
}
|
||||
@ -58,4 +72,15 @@ UDQSet UDQAssign::eval(const std::vector<std::string>& wells) const {
|
||||
}
|
||||
throw std::invalid_argument("Not yet implemented");
|
||||
}
|
||||
|
||||
const std::vector<UDQAssign::AssignRecord>& UDQAssign::getRecords() const {
|
||||
return records;
|
||||
}
|
||||
|
||||
bool UDQAssign::operator==(const UDQAssign& data) const {
|
||||
return this->keyword() == data.keyword() &&
|
||||
this->var_type() == data.var_type() &&
|
||||
this->getRecords() == data.getRecords();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,6 +46,22 @@ namespace Opm {
|
||||
{}
|
||||
|
||||
|
||||
UDQConfig::UDQConfig(const UDQParams& params,
|
||||
const UDQFunctionTable& funcTable,
|
||||
const std::unordered_map<std::string, UDQDefine>& definition,
|
||||
const std::unordered_map<std::string, UDQAssign>& assignment,
|
||||
const std::unordered_map<std::string, std::string>& unit,
|
||||
const OrderedMap<std::string, UDQIndex>& inputIdx,
|
||||
const std::map<UDQVarType, std::size_t>& tCount) :
|
||||
udq_params(params),
|
||||
udqft(funcTable),
|
||||
m_definitions(definition),
|
||||
m_assignments(assignment),
|
||||
units(unit),
|
||||
input_index(inputIdx),
|
||||
type_count(tCount)
|
||||
{}
|
||||
|
||||
|
||||
const UDQParams& UDQConfig::params() const {
|
||||
return this->udq_params;
|
||||
@ -256,6 +272,42 @@ namespace Opm {
|
||||
return this->udqft;
|
||||
}
|
||||
|
||||
|
||||
const std::unordered_map<std::string, UDQDefine>& UDQConfig::definitionMap() const {
|
||||
return this->m_definitions;
|
||||
}
|
||||
|
||||
|
||||
const std::unordered_map<std::string, UDQAssign>& UDQConfig::assignmentMap() const {
|
||||
return this->m_assignments;
|
||||
}
|
||||
|
||||
|
||||
const std::unordered_map<std::string, std::string>& UDQConfig::unitsMap() const {
|
||||
return this->units;
|
||||
}
|
||||
|
||||
|
||||
const OrderedMap<std::string, UDQIndex>& UDQConfig::inputIndex() const {
|
||||
return this->input_index;
|
||||
}
|
||||
|
||||
|
||||
const std::map<UDQVarType, std::size_t>& UDQConfig::typeCount() const {
|
||||
return this->type_count;
|
||||
}
|
||||
|
||||
|
||||
bool UDQConfig::operator==(const UDQConfig& data) const {
|
||||
return this->params() == data.params() &&
|
||||
this->function_table() == data.function_table() &&
|
||||
this->definitionMap() == data.definitionMap() &&
|
||||
this->assignmentMap() == data.assignmentMap() &&
|
||||
this->unitsMap() == data.unitsMap() &&
|
||||
this->inputIndex() == data.inputIndex() &&
|
||||
this->typeCount() == data.typeCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,12 +23,12 @@
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
|
||||
#include "../../../Parser/raw/RawConsts.hpp"
|
||||
#include "UDQParser.hpp"
|
||||
#include "UDQASTNode.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -61,6 +61,10 @@ std::vector<std::string> quote_split(const std::string& item) {
|
||||
|
||||
}
|
||||
|
||||
UDQDefine::UDQDefine()
|
||||
: m_var_type(UDQVarType::NONE)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
UDQDefine::UDQDefine(const UDQParams& udq_params_arg,
|
||||
const std::string& keyword,
|
||||
@ -78,12 +82,11 @@ UDQDefine::UDQDefine(const UDQParams& udq_params_arg,
|
||||
{}
|
||||
|
||||
|
||||
UDQDefine::UDQDefine(const UDQParams& udq_params_arg,
|
||||
UDQDefine::UDQDefine(const UDQParams& udq_params,
|
||||
const std::string& keyword,
|
||||
const std::vector<std::string>& deck_data,
|
||||
const ParseContext& parseContext,
|
||||
ErrorGuard& errors) :
|
||||
udq_params(udq_params_arg),
|
||||
m_keyword(keyword),
|
||||
m_var_type(UDQ::varType(keyword))
|
||||
{
|
||||
@ -121,7 +124,7 @@ UDQDefine::UDQDefine(const UDQParams& udq_params_arg,
|
||||
|
||||
}
|
||||
}
|
||||
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(this->udq_params, this->m_var_type, this->m_keyword, tokens, parseContext, errors) );
|
||||
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(udq_params, this->m_var_type, this->m_keyword, tokens, parseContext, errors) );
|
||||
|
||||
this->string_data = "";
|
||||
for (std::size_t index = 0; index < deck_data.size(); index++) {
|
||||
@ -131,6 +134,18 @@ UDQDefine::UDQDefine(const UDQParams& udq_params_arg,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UDQDefine::UDQDefine(const std::string& keyword,
|
||||
std::shared_ptr<UDQASTNode> astPtr,
|
||||
UDQVarType type,
|
||||
const std::string& stringData)
|
||||
: m_keyword(keyword)
|
||||
, ast(astPtr)
|
||||
, m_var_type(type)
|
||||
, string_data(stringData)
|
||||
{}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
@ -218,4 +233,19 @@ std::set<UDQTokenType> UDQDefine::func_tokens() const {
|
||||
return this->ast->func_tokens();
|
||||
}
|
||||
|
||||
std::shared_ptr<UDQASTNode> UDQDefine::getAst() const {
|
||||
return this->ast;
|
||||
}
|
||||
|
||||
bool UDQDefine::operator==(const UDQDefine& data) const {
|
||||
if ((ast && !data.ast) || (!ast && data.ast))
|
||||
return false;
|
||||
if (ast && !(*ast == *data.ast))
|
||||
return false;
|
||||
|
||||
return this->keyword() == data.keyword() &&
|
||||
this->var_type() == data.var_type() &&
|
||||
this->input_string() == data.input_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,12 @@ UDQFunction::UDQFunction(const std::string& name) :
|
||||
{
|
||||
}
|
||||
|
||||
UDQFunction::UDQFunction(const std::string& name, UDQTokenType funcType) :
|
||||
m_name(name),
|
||||
func_type(funcType)
|
||||
{
|
||||
}
|
||||
|
||||
UDQTokenType UDQFunction::type() const {
|
||||
return this->func_type;
|
||||
}
|
||||
@ -41,6 +47,11 @@ const std::string& UDQFunction::name() const {
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
bool UDQFunction::operator==(const UDQFunction& data) const {
|
||||
return this->name() == data.name() &&
|
||||
this->type() == data.type();
|
||||
}
|
||||
|
||||
UDQScalarFunction::UDQScalarFunction(const std::string&name, std::function<UDQSet(const UDQSet& arg)> f) :
|
||||
UDQFunction(name),
|
||||
func(std::move(f))
|
||||
|
@ -91,8 +91,13 @@ UDQFunctionTable::UDQFunctionTable(const UDQParams& params_arg) :
|
||||
this->insert_function( std::make_shared<UDQBinaryFunction>("UMAX", UDQBinaryFunction::UMAX ));
|
||||
}
|
||||
|
||||
UDQFunctionTable::UDQFunctionTable(const UDQParams& param,
|
||||
const FunctionMap& map) :
|
||||
params(param),
|
||||
function_table(map)
|
||||
{}
|
||||
|
||||
void UDQFunctionTable::insert_function(std::shared_ptr<const UDQFunction> func) {
|
||||
void UDQFunctionTable::insert_function(std::shared_ptr<UDQFunction> func) {
|
||||
auto name = func->name();
|
||||
this->function_table.emplace( std::move(name), std::move(func) );
|
||||
}
|
||||
@ -111,4 +116,37 @@ const UDQFunction& UDQFunctionTable::get(const std::string& name) const {
|
||||
const auto& pair_ptr = this->function_table.find(name);
|
||||
return *pair_ptr->second;
|
||||
}
|
||||
|
||||
const UDQParams& UDQFunctionTable::getParams() const {
|
||||
return this->params;
|
||||
}
|
||||
|
||||
const UDQFunctionTable::FunctionMap& UDQFunctionTable::functionMap() const {
|
||||
return this->function_table;
|
||||
}
|
||||
|
||||
bool UDQFunctionTable::operator==(const UDQFunctionTable& data) const {
|
||||
if (!(this->getParams() == data.getParams()))
|
||||
return false;
|
||||
|
||||
if (this->functionMap().size() != data.functionMap().size())
|
||||
return false;
|
||||
|
||||
auto tIt = this->functionMap().begin();
|
||||
auto dIt = data.functionMap().begin();
|
||||
for (; tIt != this->functionMap().end(); ++tIt, ++dIt) {
|
||||
if (tIt->first != dIt->first)
|
||||
return false;
|
||||
|
||||
if ((tIt->second && !dIt->second) || (!tIt->second && dIt->second))
|
||||
return false;
|
||||
|
||||
if (tIt->second && !(*tIt->second == *dIt->second))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
|
||||
#include "UDQASTNode.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class ParseContext;
|
||||
|
@ -21,6 +21,11 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
WList::WList(const storage& wlist) :
|
||||
well_list(wlist)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::size_t WList::size() const {
|
||||
return this->well_list.size();
|
||||
@ -51,4 +56,12 @@ WList::storage::const_iterator WList::end() const {
|
||||
return this->well_list.end();
|
||||
}
|
||||
|
||||
const WList::storage& WList::wellList() const {
|
||||
return this->well_list;
|
||||
}
|
||||
|
||||
bool WList::operator==(const WList& data) const {
|
||||
return this->wellList() == data.wellList();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,11 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
WListManager::WListManager(const std::map<std::string,WList>& list)
|
||||
: wlists(list)
|
||||
{
|
||||
}
|
||||
|
||||
bool WListManager::hasList(const std::string& name) const {
|
||||
return (this->wlists.find(name) != this->wlists.end());
|
||||
}
|
||||
@ -49,4 +54,12 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<std::string,WList>& WListManager::lists() const {
|
||||
return this->wlists;
|
||||
}
|
||||
|
||||
bool WListManager::operator==(const WListManager& data) const {
|
||||
return this->lists() == data.lists();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user