make UDQConfig constructible from variables

also make it default constructible, add accessors
and equality operator
This commit is contained in:
Arne Morten Kvarving
2019-12-12 11:12:46 +01:00
parent 763bc69211
commit 5c203e29b5
2 changed files with 70 additions and 0 deletions

View File

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

View File

@@ -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();
}
}