From 2a8f944b6f784a7f87f99204668dbc25aead6775 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 12 Dec 2019 11:12:46 +0100 Subject: [PATCH] make UDQActive constructible from variables also make it default constructible, add accessors and equality operator --- .../EclipseState/Schedule/UDQ/UDQActive.hpp | 32 +++++++++++++++++ .../EclipseState/Schedule/UDQ/UDQActive.cpp | 34 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp b/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp index 296a5a012..9cafadaca 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp @@ -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& inputRecs, + const std::vector& outputRecs, + const std::unordered_map& udqkeys, + const std::unordered_map& 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& get_iuad() const; std::vector get_iuap() const; + + const std::vector& getInputRecords() const; + const std::vector& getOutputRecords() const; + const std::unordered_map& getUdqKeys() const; + const std::unordered_map& 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); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp index eac8e34be..b838278a2 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp @@ -25,6 +25,16 @@ namespace Opm { +UDQActive::UDQActive(const std::vector& inputRecs, + const std::vector& outputRecs, + const std::unordered_map& udqkeys, + const std::unordered_map& 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::getInputRecords() const { + return input_data; +} + +const std::vector& UDQActive::getOutputRecords() const { + return output_data; +} + +const std::unordered_map& UDQActive::getUdqKeys() const { + return udq_keys; +} + +const std::unordered_map& 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(); +} + }