From 4fc36e58fb78f841d63789d3ca6207264e462ac9 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 7 Sep 2015 16:55:08 +0200 Subject: [PATCH] [bugfix] Account for shut completions when checking well in a parallel run. Previously well with just some shut completions errorneously triggered an exception in parallel runs. This is fixed with this commit. Due to the logic shut completions will always be marked as existing on a process. (Initially all completions are marked as found. For each open completion we check whether the cartesian index belongs to the local grid. If that is not the case we mark it as not found). Therefore we now check whether the found number of completions is either the number of shut completions or the number of all completions. In the former case the well is not stored on this process, and in the latter case it is. In other cases we throw an exception. --- opm/core/wells/WellsManager_impl.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 2e7b1dfa0..e3c93e9c2 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -136,7 +136,9 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t { // COMPDAT handling CompletionSetConstPtr completionSet = well->getCompletions(timeStep); + // shut completions and open ones stored in this process will have 1 others 0. std::vector completion_on_proc(completionSet->size(), 1); + std::size_t shut_completions_number = 0; for (size_t c=0; csize(); c++) { CompletionConstPtr completion = completionSet->get(c); if (completion->getState() == WellCompletion::OPEN) { @@ -195,6 +197,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t wellperf_data[well_index].push_back(pd); } } else { + ++shut_completions_number; if (completion->getState() != WellCompletion::SHUT) { OPM_THROW(std::runtime_error, "Completion state: " << WellCompletion::StateEnum2String( completion->getState() ) << " not handled"); } @@ -205,7 +208,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t // Set wells that are on other processor to SHUT. std::size_t sum_completions_on_proc = std::accumulate(completion_on_proc.begin(), completion_on_proc.end(),0); - if ( sum_completions_on_proc == 0 ) + if ( sum_completions_on_proc == shut_completions_number ) { // Mark well as not existent on this process wells_on_proc[wellIter-wells.begin()] = 0; @@ -214,7 +217,10 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t // Check that the complete well is on this process if( sum_completions_on_proc < completionSet->size() ) { - OPM_THROW(std::runtime_error, "Wells must be completely on processor!"); + OPM_THROW(std::runtime_error, "Each well must be completely stored + <<"on processor! Not the case for "<< well->name()<<": " + <size()-shut_completions-sum_completions_on_proc + <<" completions missing."); } } }