diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 7484aa9b5..3b2870bc9 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->permanently_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()))}); @@ -694,6 +695,9 @@ void WellState::initWellStateMSWell(const std::vector& wells_ecl, // what we do here, is to set the segment rates and perforation rates for (int w = 0; w < nw; ++w) { const auto& well_ecl = wells_ecl[w]; + if (this->is_permanently_inactive_well(well_ecl.name())) + continue; + auto& ws = this->well(w); if (well_ecl.isMultiSegment()) { @@ -724,6 +728,10 @@ void WellState::initWellStateMSWell(const std::vector& wells_ecl, n_activeperf++; } } + + if (static_cast(ws.perf_data.size()) != n_activeperf) + throw std::logic_error("Distributed multi-segment wells cannot be initialized properly yet."); + std::vector> segment_inlets(well_nseg); for (int seg = 0; seg < well_nseg; ++seg) { @@ -1050,7 +1058,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->permanently_inactive_well_names_ == rhs.permanently_inactive_well_names_; } template diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 7eb9b7e33..d6d085234 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(permanently_inactive_well_names_); } private: + bool is_permanently_inactive_well(const std::string& wname) const { + return std::find(this->permanently_inactive_well_names_.begin(), this->permanently_inactive_well_names_.end(), wname) != this->permanently_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 permanently inactive well names + std::vector permanently_inactive_well_names_; + data::Segment reportSegmentResults(const int well_id, const int seg_ix,