From 057db0ec0ec5a14cc7654bb22d64bd312b7adedb Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 26 Jul 2021 12:06:45 +0200 Subject: [PATCH 1/3] Add method WellState::name() --- opm/simulators/wells/WellContainer.hpp | 8 ++++++++ opm/simulators/wells/WellState.hpp | 4 ++++ tests/test_wellstate.cpp | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/opm/simulators/wells/WellContainer.hpp b/opm/simulators/wells/WellContainer.hpp index 0fbde2dc4..e790b54f4 100644 --- a/opm/simulators/wells/WellContainer.hpp +++ b/opm/simulators/wells/WellContainer.hpp @@ -166,6 +166,14 @@ public: return std::nullopt; } + const std::string& well_name(std::size_t well_index) const { + for (const auto& [wname, windex] : this->index_map) { + if (windex == well_index) + return wname; + } + throw std::logic_error("No such well"); + } + private: void update_if(std::size_t index, const std::string& name, const WellContainer& other) { diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 613701798..024fda5ab 100644 --- a/opm/simulators/wells/WellState.hpp +++ b/opm/simulators/wells/WellState.hpp @@ -339,6 +339,10 @@ public: return this->perfdata[well_index]; } + const std::string& name(std::size_t well_index) const { + return this->status_.well_name(well_index); + } + private: WellMapType wellMap_; // Use of std::optional<> here is a technical crutch, the diff --git a/tests/test_wellstate.cpp b/tests/test_wellstate.cpp index eb8e921d1..7975cd65c 100644 --- a/tests/test_wellstate.cpp +++ b/tests/test_wellstate.cpp @@ -432,6 +432,10 @@ BOOST_AUTO_TEST_CASE(TESTWellContainer) { BOOST_CHECK_THROW(wc["INVALID_WELL"], std::exception); BOOST_CHECK_EQUAL(wc["W1"], 1); BOOST_CHECK_EQUAL(wc["W2"], 2); + BOOST_CHECK_EQUAL(wc.well_name(0), "W1"); + BOOST_CHECK_EQUAL(wc.well_name(1), "W2"); + BOOST_CHECK_THROW(wc.well_name(10), std::exception); + Opm::WellContainer wc2; wc2.copy_welldata(wc); From a39fcc9708486784e34d89d8a9d9305cb45d0e9e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 26 Jul 2021 13:06:24 +0200 Subject: [PATCH 2/3] Set WellState::thp when loading restart file --- opm/simulators/wells/BlackoilWellModelGeneric.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 710a5098a..32cc5666b 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -172,6 +172,7 @@ loadRestartData(const data::Wells& rst_wells, for( const auto& wm : well_state.wellMap() ) { const auto well_index = wm.second[ 0 ]; const auto& rst_well = rst_wells.at( wm.first ); + well_state.update_thp(well_index, rst_well.thp); well_state.update_bhp(well_index, rst_well.bhp); well_state.update_temperature(well_index, rst_well.temperature); From e01910adc233702a914bc84dac81a8581424e8b4 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 26 Jul 2021 14:09:06 +0200 Subject: [PATCH 3/3] Add methods WellState::size() and WellState::producer() --- opm/simulators/wells/WellState.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 024fda5ab..9aec91607 100644 --- a/opm/simulators/wells/WellState.hpp +++ b/opm/simulators/wells/WellState.hpp @@ -71,9 +71,14 @@ public: const WellMapType& wellMap() const { return wellMap_; } WellMapType& wellMap() { return wellMap_; } + std::size_t size() const { + return this->wellMap_.size(); + } + + int numWells() const { - return wellMap_.size(); + return this->size(); } int wellIndex(const std::string& wellName) const; @@ -343,6 +348,11 @@ public: return this->status_.well_name(well_index); } + bool producer(std::size_t well_index) const { + return this->is_producer_[well_index]; + } + + private: WellMapType wellMap_; // Use of std::optional<> here is a technical crutch, the