Add wells() method to SummaryState
This commit is contained in:
parent
15a7d7597d
commit
c244625865
@ -23,6 +23,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <ert/ecl/smspec_node.hpp>
|
||||
|
||||
@ -74,6 +75,7 @@ public:
|
||||
bool has_well_var(const std::string& well, const std::string& var) const;
|
||||
double get_well_var(const std::string& well, const std::string& var) const;
|
||||
|
||||
std::vector<std::string> wells() const;
|
||||
std::vector<std::string> wells(const std::string& var) const;
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
@ -82,6 +84,7 @@ private:
|
||||
|
||||
// The first key is the variable and the second key is the well.
|
||||
std::unordered_map<std::string, std::unordered_map<std::string, double>> well_values;
|
||||
std::unordered_set<std::string> m_wells;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ namespace Opm{
|
||||
void SummaryState::add_well_var(const std::string& well, const std::string& var, double value) {
|
||||
this->add(var + ":" + well, value);
|
||||
this->well_values[var][well] = value;
|
||||
this->m_wells.insert(well);
|
||||
}
|
||||
|
||||
bool SummaryState::has_well_var(const std::string& well, const std::string& var) const {
|
||||
@ -91,4 +92,12 @@ namespace Opm{
|
||||
return wells;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> SummaryState::wells() const {
|
||||
return std::vector<std::string>(this->m_wells.begin(), this->m_wells.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1397,6 +1397,7 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) {
|
||||
|
||||
st.add_well_var("OP1", "WWCT", 0.75);
|
||||
st.add_well_var("OP2", "WWCT", 0.75);
|
||||
st.add_well_var("OP3", "WOPT", 0.75);
|
||||
BOOST_CHECK( st.has_well_var("OP1", "WWCT"));
|
||||
BOOST_CHECK_EQUAL( st.get_well_var("OP1", "WWCT"), 0.75);
|
||||
BOOST_CHECK_EQUAL( st.get_well_var("OP1", "WWCT"), st.get("WWCT:OP1"));
|
||||
@ -1406,8 +1407,15 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) {
|
||||
BOOST_CHECK_EQUAL( wopr_wells.size() , 0);
|
||||
|
||||
const auto& wwct_wells = st.wells("WWCT");
|
||||
BOOST_CHECK_EQUAL( wwct_wells.size(), 2);
|
||||
BOOST_CHECK_EQUAL(std::count(wwct_wells.begin(), wwct_wells.end(), "OP1"), 1);
|
||||
BOOST_CHECK_EQUAL(std::count(wwct_wells.begin(), wwct_wells.end(), "OP2"), 1);
|
||||
|
||||
const auto& all_wells = st.wells();
|
||||
BOOST_CHECK_EQUAL( all_wells.size(), 3);
|
||||
BOOST_CHECK_EQUAL(std::count(all_wells.begin(), all_wells.end(), "OP1"), 1);
|
||||
BOOST_CHECK_EQUAL(std::count(all_wells.begin(), all_wells.end(), "OP2"), 1);
|
||||
BOOST_CHECK_EQUAL(std::count(all_wells.begin(), all_wells.end(), "OP3"), 1);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user