From 042830e86016325d756286eff8913ad4ebf9383a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 15 Jun 2022 11:29:29 +0200 Subject: [PATCH] Don't Assume Increasing WLIST Position In Restart Files The well list positions for individual wells (i.e,, IWLS) need not, and typically are not, strictly increasing in the restart files. Therefore we must only 'resize()' the well name vectors if the 'well_order' is strictly larger than the current size. Otherwise, we lose information about which wells are in which well lists. --- src/opm/io/eclipse/rst/state.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/opm/io/eclipse/rst/state.cpp b/src/opm/io/eclipse/rst/state.cpp index 1b0bf4bdc..887bb2dbb 100644 --- a/src/opm/io/eclipse/rst/state.cpp +++ b/src/opm/io/eclipse/rst/state.cpp @@ -380,13 +380,17 @@ void RstState::add_wlist(const std::vector& zwls, const auto& well_name = this->wells[well_index].name; for (auto wlist_index = 0*this->header.max_wlist; wlist_index < this->header.max_wlist; wlist_index++) { - int well_order = iwls[iwls_offset + wlist_index]; - if (well_order != 0) { - const auto& wlist_name = zwls[zwls_offset + wlist_index]; - auto& wlist = this->wlists[wlist_name]; - wlist.resize( well_order ); - wlist[well_order - 1] = well_name; + const auto well_order = iwls[iwls_offset + wlist_index]; + if (well_order < 1) { + continue; } + + auto& wlist = this->wlists[zwls[zwls_offset + wlist_index]]; + if (wlist.size() < static_cast::size_type>(well_order)) { + wlist.resize(well_order); + } + + wlist[well_order - 1] = well_name; } } }