diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index ad3cae207..9cc4d2ccd 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -407,10 +407,19 @@ namespace Opm void WellsManager::setupWellControls(std::vector& wells, size_t timeStep, - std::vector& well_names, const PhaseUsage& phaseUsage) { + std::vector& well_names, const PhaseUsage& phaseUsage, + const std::vector& wells_on_proc) { int well_index = 0; - for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { - WellConstPtr well = (*wellIter); + auto well_on_proc = wells_on_proc.begin(); + + for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter, ++well_on_proc) { + if( ! *well_on_proc ) + { + // Wells not stored on the process are not in the list + continue; + } + + WellConstPtr well = (*wellIter); if (well->getStatus(timeStep) == WellCommon::STOP) { // STOPed wells are kept in the well list but marked as stopped. diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index 0094f2114..58baaf7e7 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -155,7 +155,8 @@ namespace Opm WellsManager& operator=(const WellsManager& other); static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map& cartesian_to_compressed ); void setupWellControls(std::vector& wells, size_t timeStep, - std::vector& well_names, const PhaseUsage& phaseUsage); + std::vector& well_names, const PhaseUsage& phaseUsage, + const std::vector& wells_on_proc); template void createWellsFromSpecs( std::vector& wells, size_t timeStep, @@ -169,7 +170,8 @@ namespace Opm const PhaseUsage& phaseUsage, const std::map& cartesian_to_compressed, const double* permeability, - const NTG& ntg); + const NTG& ntg, + std::vector& wells_on_proc); void addChildGroups(GroupTreeNodeConstPtr parentNode, ScheduleConstPtr schedule, size_t timeStep, const PhaseUsage& phaseUsage); void setupGuideRates(std::vector& wells, const size_t timeStep, std::vector& well_data, std::map& well_names_to_index); diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 818e9195f..a8d18d83e 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -113,7 +113,8 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t const PhaseUsage& phaseUsage, const std::map& cartesian_to_compressed, const double* permeability, - const NTG& ntg) + const NTG& ntg, + std::vector& wells_on_proc) { if (dimensions != 3) { OPM_THROW(std::domain_error, @@ -122,9 +123,8 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t } std::vector > wellperf_data; - std::vector well_on_proc; wellperf_data.resize(wells.size()); - well_on_proc.resize(wells.size(), 1); + wells_on_proc.resize(wells.size(), 1); int well_index = 0; for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { @@ -206,7 +206,8 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t completion_on_proc.end(),0); if ( sum_completions_on_proc == 0 ) { - const_cast(*well).setStatus(timeStep, WellCommon::SHUT); + // Mark well as not existent on this process + wells_on_proc[wellIter-wells.begin()] = 0; continue; } // Check that the complete well is on this process @@ -233,7 +234,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t well_index++; } - + std::cout<<"well_index="<