From f7dec58ee24e7fc31f27375cbc0cb219b279264f Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 15 Jul 2022 16:50:38 +0200 Subject: [PATCH 1/3] Fix deadlock for distributed wells when calculating densities/pressures There was a check that is supposed that all rates are zero but for distributed wells it only checked local perforations. Of course that can lead to different outcome on processes for distributed wells. --- opm/simulators/wells/StandardWell_impl.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 9cfb7287e..f8a454641 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -1596,6 +1596,12 @@ namespace Opm // approximate the perforation mixture using the mobility ratio // and weight the perforations using the well transmissibility. bool all_zero = std::all_of(perfRates.begin(), perfRates.end(), [](double val) { return val == 0.0; }); + const auto& comm = this->parallel_well_info_.communication(); + if (comm.size() > 1) + { + all_zero = (comm.min(all_zero ? 1 : 0) == 1); + } + if ( all_zero && this->isProducer() ) { double total_tw = 0; for (int perf = 0; perf < nperf; ++perf) { From c22114af41d3f635d76d4c716987dd157f3a0ec8 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 28 Jul 2022 17:14:23 +0200 Subject: [PATCH 2/3] Handle injection/producer targets correctly for distributed wells. We should never return in a function if there are no local perforations for a distributed well, but that is what we did before this fix. --- opm/simulators/wells/WellState.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 919cd5e8e..802251aca 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -63,9 +63,10 @@ void WellState::initSingleProducer(const Well& well, const double temp = 273.15 + 15.56; auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, true, pressure_first_connection, well_perf_data, pu, temp}); - if ( ws.perf_data.empty()) - return; + // the rest of the code needs to executed even if ws.perf_data is empty + // as this does not say anything for the whole well if it is distributed. + // Hence never ever return here! if (well.getStatus() == Well::Status::OPEN) { ws.status = Well::Status::OPEN; } @@ -85,9 +86,10 @@ void WellState::initSingleInjector(const Well& well, const double temp = inj_controls.temperature; auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, false, pressure_first_connection, well_perf_data, pu, temp}); - if ( ws.perf_data.empty()) - return; + // the rest of the code needs to executed even if ws.perf_data is empty + // as this does not say anything for the whole well if it is distributed. + // Hence never ever return here! if (well.getStatus() == Well::Status::OPEN) { ws.status = Well::Status::OPEN; } From 941957c13e69fdae3e2bb30c46a0fa2010c315f6 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 28 Jul 2022 19:50:24 +0200 Subject: [PATCH 3/3] Fix shadowed variable warning. --- opm/simulators/wells/StandardWell_impl.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index f8a454641..8d4a3110c 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -1607,7 +1607,6 @@ namespace Opm for (int perf = 0; perf < nperf; ++perf) { total_tw += this->well_index_[perf]; } - const auto& comm = this->parallel_well_info_.communication(); if (comm.size() > 1) { total_tw = comm.sum(total_tw);