From e189d56167208438c866f653e0a8572df87e8222 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Wed, 20 Nov 2024 15:40:18 +0100 Subject: [PATCH] Explicit check for inactive wells and throw if trying to initialize a distributed multi-segment well --- opm/simulators/wells/WellState.cpp | 9 +++++++-- opm/simulators/wells/WellState.hpp | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 3377423c5..3aca9016f 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -273,6 +273,7 @@ void WellState::init(const std::vector& cellPressures, report_step, wells_ecl); well_rates.clear(); + this->inactive_well_names_ = schedule.getInactiveWellNamesAtEnd(); for (const auto& wname : schedule.wellNames(report_step)) { well_rates.insert({wname, std::make_pair(false, std::vector(this->numPhases()))}); @@ -728,7 +729,10 @@ void WellState::initWellStateMSWell(const std::vector& wells_ecl, // For inactive wells there is no need for calculating an initial solution // \todo{ Update the procedure below to work for actually distributed wells. } if (static_cast(ws.perf_data.size()) != n_activeperf) - continue; + if (this->is_inactive_well(well_ecl.name())) + continue; + else + throw std::logic_error("Distributed multi-segment wells cannot be initialized properly yet."); std::vector> segment_inlets(well_nseg); @@ -1056,7 +1060,8 @@ bool WellState::operator==(const WellState& rhs) const { return this->alq_state == rhs.alq_state && this->well_rates == rhs.well_rates && - this->wells_ == rhs.wells_; + this->wells_ == rhs.wells_ && + this->inactive_well_names_ == rhs.inactive_well_names_; } template diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 7eb9b7e33..56c1ba550 100644 --- a/opm/simulators/wells/WellState.hpp +++ b/opm/simulators/wells/WellState.hpp @@ -348,9 +348,14 @@ public: for (auto& w : wells_) { serializer(w); } + serializer(inactive_well_names_); } private: + bool is_inactive_well(const std::string& wname) const { + return std::find(this->inactive_well_names_.begin(), this->inactive_well_names_.end(), wname) != this->inactive_well_names_.end(); + } + PhaseUsage phase_usage_; // The wells_ variable is essentially a map of all the wells on the current @@ -372,6 +377,9 @@ private: // not. std::map>> well_rates; + // Keep track of inactive well names + std::vector inactive_well_names_; + data::Segment reportSegmentResults(const int well_id, const int seg_ix,