Add method WellContainer<T>::wells()

This commit is contained in:
Joakim Hove
2021-10-15 14:14:20 +02:00
parent d925e74b76
commit c8cbd32f85
3 changed files with 18 additions and 0 deletions

View File

@@ -157,6 +157,15 @@ public:
throw std::logic_error("No such well");
}
std::vector<std::string> wells() const {
std::vector<std::string> wlist;
for (const auto& [wname, _] : this->index_map) {
(void)_;
wlist.push_back(wname);
}
return wlist;
}
private:
void update_if(std::size_t index, const std::string& name, const WellContainer<T>& other) {

View File

@@ -73,6 +73,10 @@ public:
return this->wells_.size();
}
std::vector<std::string> wells() const {
return this->wells_.wells();
}
int numWells() const
{

View File

@@ -17,8 +17,10 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <config.h>
#include <functional>
#include <vector>
#define BOOST_TEST_MODULE WellStateFIBOTest
@@ -440,6 +442,9 @@ BOOST_AUTO_TEST_CASE(TESTWellContainer) {
BOOST_CHECK_EQUAL(wc.well_name(1), "W2");
BOOST_CHECK_THROW(wc.well_name(10), std::exception);
const auto& wells = wc.wells();
std::vector<std::string> expected = {"W1", "W2"};
BOOST_CHECK( std::is_permutation( wells.begin(), wells.end(), expected.begin(), expected.end()) );
Opm::WellContainer<int> wc2;
wc2.copy_welldata(wc);