diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index f2676c8ec2..8bfe2368b4 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -20,6 +20,7 @@ */ #include + #include #include @@ -33,7 +34,9 @@ #include #include #include + #include + #include #include #include @@ -45,10 +48,13 @@ #include +#include #include #include #include #include +#include +#include namespace Opm { @@ -677,33 +683,32 @@ void WellInterfaceGeneric::resetWellOperability() } template -void WellInterfaceGeneric::addPerforations(const std::vector>& perfs){ - int newperf = perfs.size(); - - for(auto& perf : perfs){ - const auto [cell, WI, depth] = perf; - auto it = std::find(well_cells_.begin(), well_cells_.end(), cell); - if(it != well_cells_.end()){ - // if perforation to cell already exist just add - size_t ind = it- well_cells_.begin(); - well_index_[ind] += WI; - }else{ - well_cells_.push_back(cell); - well_index_.push_back(WI); - perf_depth_.push_back(depth); - // not needed - double nan = std::nan("1"); - perf_rep_radius_.push_back(nan); - perf_length_.push_back(nan); - bore_diameters_.push_back(nan); - saturation_table_number_.push_back(saturation_table_number_[0]);// for now used the saturation table for the first cell - number_of_perforations_ += 1; - } - // completions_; - // inj_multiplier_; - // prev_inj_multiplier_; - // inj_fc_multiplier_; +void WellInterfaceGeneric::addPerforations(const std::vector>& perfs) +{ + for (const auto& [cell, WI, depth] : perfs) { + auto it = std::find(well_cells_.begin(), well_cells_.end(), cell); + if (it != well_cells_.end()) { + // If perforation to cell already exists, just add contribution. + const auto ind = std::distance(well_cells_.begin(), it); + well_index_[ind] += WI; } + else { + well_cells_.push_back(cell); + well_index_.push_back(WI); + perf_depth_.push_back(depth); + + // Not strictly needed. + const double nan = std::nan("1"); + perf_rep_radius_.push_back(nan); + perf_length_.push_back(nan); + bore_diameters_.push_back(nan); + + // For now use the saturation table for the first cell. + saturation_table_number_.push_back(saturation_table_number_[0]); + + number_of_perforations_ += 1; + } + } } template diff --git a/opm/simulators/wells/WellInterfaceGeneric.hpp b/opm/simulators/wells/WellInterfaceGeneric.hpp index c4a530c201..51a16c266e 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.hpp +++ b/opm/simulators/wells/WellInterfaceGeneric.hpp @@ -203,6 +203,7 @@ class WellInterfaceGeneric { const int openConnIdx) const = 0; void addPerforations(const std::vector>& perfs); + protected: bool getAllowCrossFlow() const;