Merge pull request #3450 from joakim-hove/small

Small
This commit is contained in:
Joakim Hove 2021-08-03 18:08:33 +02:00 committed by GitHub
commit 1cbc096d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 1 deletions

View File

@ -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);

View File

@ -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<T>& other) {

View File

@ -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;
@ -339,6 +344,15 @@ public:
return this->perfdata[well_index];
}
const std::string& name(std::size_t well_index) const {
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

View File

@ -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<int> wc2;
wc2.copy_welldata(wc);