mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add method WellContainer::well_index()
This commit is contained in:
@@ -53,6 +53,9 @@ public:
|
|||||||
this->add(name, value);
|
this->add(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return this->index_map.empty();
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t size() const {
|
std::size_t size() const {
|
||||||
return this->m_data.size();
|
return this->m_data.size();
|
||||||
@@ -155,6 +158,14 @@ public:
|
|||||||
return this->m_data;
|
return this->m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<int> well_index(const std::string& wname) const {
|
||||||
|
auto index_iter = this->index_map.find(wname);
|
||||||
|
if (index_iter != this->index_map.end())
|
||||||
|
return index_iter->second;
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_if(std::size_t index, const std::string& name, const WellContainer<T>& other) {
|
void update_if(std::size_t index, const std::string& name, const WellContainer<T>& other) {
|
||||||
|
|||||||
@@ -516,6 +516,13 @@ BOOST_AUTO_TEST_CASE(TESTWellContainer) {
|
|||||||
BOOST_CHECK(wci.has("W1"));
|
BOOST_CHECK(wci.has("W1"));
|
||||||
BOOST_CHECK_EQUAL(wci[1], 2);
|
BOOST_CHECK_EQUAL(wci[1], 2);
|
||||||
BOOST_CHECK_EQUAL(wci["W3"], 3);
|
BOOST_CHECK_EQUAL(wci["W3"], 3);
|
||||||
|
|
||||||
|
auto w3 = wci.well_index("W3");
|
||||||
|
BOOST_CHECK(w3.has_value());
|
||||||
|
BOOST_CHECK_EQUAL(w3.value(), 2);
|
||||||
|
|
||||||
|
auto wx = wci.well_index("WX");
|
||||||
|
BOOST_CHECK(!wx.has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user