diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 1e6a25fe2..42b537ff4 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -274,11 +274,11 @@ getLocalWells(const int timeStepIdx) const } template -std::vector> +std::vector>> BlackoilWellModelGeneric:: createLocalParallelWellInfo(const std::vector& wells) { - std::vector> local_parallel_well_info; + std::vector>> local_parallel_well_info; local_parallel_well_info.reserve(wells.size()); for (const auto& well : wells) { @@ -318,7 +318,7 @@ initializeWellPerfData() int connection_index = 0; // INVALID_ECL_INDEX marks no above perf available - int connection_index_above = ParallelWellInfo::INVALID_ECL_INDEX; + int connection_index_above = ParallelWellInfo::INVALID_ECL_INDEX; well_perf_data_[well_index].clear(); well_perf_data_[well_index].reserve(well.getConnections().size()); diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index bb0848528..fbf5aa5ca 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -58,7 +58,7 @@ namespace Opm { template class GasLiftWellState; class Group; class GuideRateConfig; - class ParallelWellInfo; + template class ParallelWellInfo; class RestartValue; class Schedule; struct SimulatorUpdate; @@ -323,7 +323,7 @@ protected: /// \brief Create the parallel well information /// \param localWells The local wells from ECL schedule - std::vector> + std::vector>> createLocalParallelWellInfo(const std::vector& wells); void initializeWellProdIndCalculators(); @@ -546,8 +546,8 @@ protected: std::vector local_shut_wells_{}; - std::vector parallel_well_info_; - std::vector> local_parallel_well_info_; + std::vector> parallel_well_info_; + std::vector>> local_parallel_well_info_; std::vector prod_index_calc_; mutable ParallelWBPCalculation wbpCalculationService_; diff --git a/opm/simulators/wells/MultisegmentWell.hpp b/opm/simulators/wells/MultisegmentWell.hpp index 084636ef3..a0e953bef 100644 --- a/opm/simulators/wells/MultisegmentWell.hpp +++ b/opm/simulators/wells/MultisegmentWell.hpp @@ -68,7 +68,7 @@ namespace Opm using typename Base::PressureMatrix; MultisegmentWell(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 62172dacd..0a014fe6b 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -57,7 +57,7 @@ namespace Opm template MultisegmentWell:: MultisegmentWell(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/ParallelWBPCalculation.cpp b/opm/simulators/wells/ParallelWBPCalculation.cpp index 3ffc107fa..fbbf8b1f2 100644 --- a/opm/simulators/wells/ParallelWBPCalculation.cpp +++ b/opm/simulators/wells/ParallelWBPCalculation.cpp @@ -173,7 +173,7 @@ Opm::ParallelWBPCalculation::evalCellSource(Evaluator evalCellSrc) std::size_t Opm::ParallelWBPCalculation:: createCalculator(const Well& well, - const ParallelWellInfo& parallelWellInfo, + const ParallelWellInfo& parallelWellInfo, const std::vector& localConnIdx, EvaluatorFactory makeWellSourceEvaluator) { diff --git a/opm/simulators/wells/ParallelWBPCalculation.hpp b/opm/simulators/wells/ParallelWBPCalculation.hpp index dd500e664..a0492ad64 100644 --- a/opm/simulators/wells/ParallelWBPCalculation.hpp +++ b/opm/simulators/wells/ParallelWBPCalculation.hpp @@ -36,7 +36,7 @@ namespace Opm { class GridDims; - class ParallelWellInfo; + template class ParallelWellInfo; class PAvg; class Well; } @@ -112,7 +112,7 @@ public: /// well. std::size_t createCalculator(const Well& well, - const ParallelWellInfo& parallelWellInfo, + const ParallelWellInfo& parallelWellInfo, const std::vector& localConnIdx, EvaluatorFactory makeWellSourceEvaluator); diff --git a/opm/simulators/wells/ParallelWellInfo.cpp b/opm/simulators/wells/ParallelWellInfo.cpp index 330999ac4..89237d3d3 100644 --- a/opm/simulators/wells/ParallelWellInfo.cpp +++ b/opm/simulators/wells/ParallelWellInfo.cpp @@ -45,15 +45,33 @@ struct CommPolicy return 1; } }; + +template<> +struct CommPolicy +{ + using Type = float*; + using IndexedType = float; + using IndexedTypeFlag = Dune::SizeOne; + static const void* getAddress(const float*& v, int index) + { + return v + index; + } + static int getSize(const float*&, int) + { + return 1; + } +}; #endif } namespace Opm { -GlobalPerfContainerFactory::GlobalPerfContainerFactory(const IndexSet& local_indices, - const Parallel::Communication comm, - const int num_local_perfs) +template +GlobalPerfContainerFactory:: +GlobalPerfContainerFactory(const IndexSet& local_indices, + const Parallel::Communication comm, + const int num_local_perfs) : local_indices_(local_indices), comm_(comm) { if ( comm_.size() > 1 ) @@ -101,13 +119,13 @@ GlobalPerfContainerFactory::GlobalPerfContainerFactory(const IndexSet& local_ind } } - - -std::vector GlobalPerfContainerFactory::createGlobal(const std::vector& local_perf_container, - std::size_t num_components) const +template +std::vector GlobalPerfContainerFactory:: +createGlobal(const std::vector& local_perf_container, + std::size_t num_components) const { // Could be become templated later. - using Value = double; + using Value = Scalar; if (comm_.size() > 1) { @@ -152,8 +170,11 @@ std::vector GlobalPerfContainerFactory::createGlobal(const std::vector& global, std::vector& local, - std::size_t num_components) const +template +void GlobalPerfContainerFactory:: +copyGlobalToLocal(const std::vector& global, + std::vector& local, + std::size_t num_components) const { if (global.empty()) { @@ -182,19 +203,22 @@ void GlobalPerfContainerFactory::copyGlobalToLocal(const std::vector& gl } } -int GlobalPerfContainerFactory::numGlobalPerfs() const +template +int GlobalPerfContainerFactory::numGlobalPerfs() const { return num_global_perfs_; } - -CommunicateAboveBelow::CommunicateAboveBelow([[maybe_unused]] const Parallel::Communication& comm) +template +CommunicateAboveBelow:: +CommunicateAboveBelow([[maybe_unused]] const Parallel::Communication& comm) #if HAVE_MPI : comm_(comm), interface_(comm_) #endif {} -void CommunicateAboveBelow::clear() +template +void CommunicateAboveBelow::clear() { #if HAVE_MPI above_indices_ = {}; @@ -205,7 +229,8 @@ void CommunicateAboveBelow::clear() num_local_perfs_ = 0; } -void CommunicateAboveBelow::beginReset() +template +void CommunicateAboveBelow::beginReset() { clear(); #if HAVE_MPI @@ -217,7 +242,8 @@ void CommunicateAboveBelow::beginReset() #endif } -int CommunicateAboveBelow::endReset() +template +int CommunicateAboveBelow::endReset() { #if HAVE_MPI if (comm_.size() > 1) @@ -226,7 +252,7 @@ int CommunicateAboveBelow::endReset() current_indices_.endResize(); remote_indices_.setIndexSets(current_indices_, above_indices_, comm_); // It is mandatory to not set includeSelf to true, as this will skip some entries. - remote_indices_.rebuild(); + remote_indices_.template rebuild(); using FromSet = Dune::EnumItem; using ToSet = Dune::AllSet; interface_.build(remote_indices_, FromSet(), ToSet()); @@ -236,8 +262,9 @@ int CommunicateAboveBelow::endReset() return num_local_perfs_; } +template template -void CommunicateAboveBelow::partialSumPerfValues(RAIterator begin, RAIterator end) const +void CommunicateAboveBelow::partialSumPerfValues(RAIterator begin, RAIterator end) const { if (this->comm_.size() < 2) { @@ -295,28 +322,27 @@ void CommunicateAboveBelow::partialSumPerfValues(RAIterator begin, RAIterator en } } -using dIter = typename std::vector::iterator; -template void CommunicateAboveBelow::partialSumPerfValues(dIter begin, dIter end) const; - +template struct CopyGatherScatter { - static const double& gather(const double* a, std::size_t i) + static const Scalar& gather(const Scalar* a, std::size_t i) { return a[i]; } - static void scatter(double* a, const double& v, std::size_t i) + static void scatter(Scalar* a, const Scalar& v, std::size_t i) { a[i] = v; } }; - -std::vector CommunicateAboveBelow::communicateAbove(double first_above, - const double* current, - std::size_t size) +template +std::vector CommunicateAboveBelow:: +communicateAbove(Scalar first_above, + const Scalar* current, + std::size_t size) { - std::vector above(size, first_above); + std::vector above(size, first_above); #if HAVE_MPI if (comm_.size() > 1) @@ -326,7 +352,7 @@ std::vector CommunicateAboveBelow::communicateAbove(double first_above, // passing const double*& and double* as parameter is // incompatible with function decl template forward(const Data&, Data&)) // That would need the first argument to be double* const& - communicator_.forward(const_cast(current), aboveData); + communicator_.forward>(const_cast(current), aboveData); } else #endif @@ -339,11 +365,14 @@ std::vector CommunicateAboveBelow::communicateAbove(double first_above, } return above; } -std::vector CommunicateAboveBelow::communicateBelow(double last_below, - const double* current, - std::size_t size) + +template +std::vector CommunicateAboveBelow:: +communicateBelow(Scalar last_below, + const Scalar* current, + std::size_t size) { - std::vector below(size, last_below); + std::vector below(size, last_below); #if HAVE_MPI if (comm_.size() > 1) @@ -353,7 +382,7 @@ std::vector CommunicateAboveBelow::communicateBelow(double last_below, // passing const double*& and double* as parameter is // incompatible with function decl template backward(Data&, const Data&) // That would need the first argument to be double* const& - communicator_.backward(belowData, const_cast(current)); + communicator_.backward>(belowData, const_cast(current)); } else #endif @@ -367,9 +396,11 @@ std::vector CommunicateAboveBelow::communicateBelow(double last_below, return below; } -void CommunicateAboveBelow::pushBackEclIndex([[maybe_unused]] int above, - [[maybe_unused]] int current, - [[maybe_unused]] bool isOwner) +template +void CommunicateAboveBelow:: +pushBackEclIndex([[maybe_unused]] int above, + [[maybe_unused]] int current, + [[maybe_unused]] bool isOwner) { #if HAVE_MPI if (comm_.size() > 1) @@ -386,8 +417,8 @@ void CommunicateAboveBelow::pushBackEclIndex([[maybe_unused]] int above, ++num_local_perfs_; } - -void ParallelWellInfo::DestroyComm::operator()(Parallel::Communication* comm) +template +void ParallelWellInfo::DestroyComm::operator()(Parallel::Communication* comm) { #if HAVE_MPI // Only delete custom communicators. @@ -406,28 +437,31 @@ void ParallelWellInfo::DestroyComm::operator()(Parallel::Communication* comm) delete comm; } - -const CommunicateAboveBelow::IndexSet& CommunicateAboveBelow::getIndexSet() const +template +const typename CommunicateAboveBelow::IndexSet& +CommunicateAboveBelow::getIndexSet() const { return current_indices_; } -int CommunicateAboveBelow::numLocalPerfs() const +template +int CommunicateAboveBelow::numLocalPerfs() const { return num_local_perfs_; } -ParallelWellInfo::ParallelWellInfo(const std::string& name, - bool hasLocalCells) +template +ParallelWellInfo::ParallelWellInfo(const std::string& name, + bool hasLocalCells) : name_(name), hasLocalCells_ (hasLocalCells), isOwner_(true), rankWithFirstPerf_(-1), comm_(new Parallel::Communication(Dune::MPIHelper::getLocalCommunicator())), - commAboveBelow_(new CommunicateAboveBelow(*comm_)) + commAboveBelow_(new CommunicateAboveBelow(*comm_)) {} - -ParallelWellInfo::ParallelWellInfo(const std::pair& well_info, - [[maybe_unused]] Parallel::Communication allComm) +template +ParallelWellInfo::ParallelWellInfo(const std::pair& well_info, + [[maybe_unused]] Parallel::Communication allComm) : name_(well_info.first), hasLocalCells_(well_info.second), rankWithFirstPerf_(-1) { @@ -439,12 +473,12 @@ ParallelWellInfo::ParallelWellInfo(const std::pair& well_info #else comm_.reset(new Parallel::Communication(Dune::MPIHelper::getLocalCommunicator())); #endif - commAboveBelow_.reset(new CommunicateAboveBelow(*comm_)); + commAboveBelow_.reset(new CommunicateAboveBelow(*comm_)); isOwner_ = (comm_->rank() == 0); } - -void ParallelWellInfo::communicateFirstPerforation(bool hasFirst) +template +void ParallelWellInfo::communicateFirstPerforation(bool hasFirst) { int first = hasFirst; std::vector firstVec(comm_->size()); @@ -455,29 +489,32 @@ void ParallelWellInfo::communicateFirstPerforation(bool hasFirst) rankWithFirstPerf_ = found - firstVec.begin(); } -void ParallelWellInfo::pushBackEclIndex(int above, int current) +template +void ParallelWellInfo::pushBackEclIndex(int above, int current) { commAboveBelow_->pushBackEclIndex(above, current); } -void ParallelWellInfo::beginReset() +template +void ParallelWellInfo::beginReset() { commAboveBelow_->beginReset(); } - -void ParallelWellInfo::endReset() +template +void ParallelWellInfo::endReset() { int local_num_perfs = commAboveBelow_->endReset(); globalPerfCont_ - .reset(new GlobalPerfContainerFactory(commAboveBelow_->getIndexSet(), - *comm_, - local_num_perfs)); + .reset(new GlobalPerfContainerFactory(commAboveBelow_->getIndexSet(), + *comm_, + local_num_perfs)); } +template template typename It::value_type -ParallelWellInfo::sumPerfValues(It begin, It end) const +ParallelWellInfo::sumPerfValues(It begin, It end) const { using V = typename It::value_type; /// \todo cater for overlap later. Currently only owner @@ -485,19 +522,16 @@ ParallelWellInfo::sumPerfValues(It begin, It end) const return communication().sum(local); } -using cdIter = typename std::vector::const_iterator; -template typename cdIter::value_type ParallelWellInfo::sumPerfValues(cdIter,cdIter) const; -template typename dIter::value_type ParallelWellInfo::sumPerfValues(dIter,dIter) const; - -void ParallelWellInfo::clear() +template +void ParallelWellInfo::clear() { commAboveBelow_->clear(); globalPerfCont_.reset(); } - +template template -T ParallelWellInfo::broadcastFirstPerforationValue(const T& t) const +T ParallelWellInfo::broadcastFirstPerforationValue(const T& t) const { T res = t; if (rankWithFirstPerf_ >= 0) { @@ -515,41 +549,50 @@ T ParallelWellInfo::broadcastFirstPerforationValue(const T& t) const return res; } -template int ParallelWellInfo::broadcastFirstPerforationValue(const int&) const; -template double ParallelWellInfo::broadcastFirstPerforationValue(const double&) const; +template int ParallelWellInfo::broadcastFirstPerforationValue(const int&) const; +template double ParallelWellInfo::broadcastFirstPerforationValue(const double&) const; -std::vector ParallelWellInfo::communicateAboveValues(double zero_value, - const double* current_values, - std::size_t size) const +template +std::vector ParallelWellInfo:: +communicateAboveValues(Scalar zero_value, + const Scalar* current_values, + std::size_t size) const { return commAboveBelow_->communicateAbove(zero_value, current_values, size); } -std::vector ParallelWellInfo::communicateAboveValues(double zero_value, - const std::vector& current_values) const +template +std::vector ParallelWellInfo:: +communicateAboveValues(Scalar zero_value, + const std::vector& current_values) const { return commAboveBelow_->communicateAbove(zero_value, current_values.data(), current_values.size()); } -std::vector ParallelWellInfo::communicateBelowValues(double last_value, - const double* current_values, - std::size_t size) const +template +std::vector ParallelWellInfo:: +communicateBelowValues(Scalar last_value, + const Scalar* current_values, + std::size_t size) const { return commAboveBelow_->communicateBelow(last_value, current_values, size); } -std::vector ParallelWellInfo::communicateBelowValues(double last_value, - const std::vector& current_values) const +template +std::vector ParallelWellInfo:: +communicateBelowValues(Scalar last_value, + const std::vector& current_values) const { return commAboveBelow_->communicateBelow(last_value, current_values.data(), current_values.size()); } -const GlobalPerfContainerFactory& -ParallelWellInfo::getGlobalPerfContainerFactory() const +template +const GlobalPerfContainerFactory& +ParallelWellInfo::getGlobalPerfContainerFactory() const { if(globalPerfCont_) return *globalPerfCont_; @@ -558,12 +601,15 @@ ParallelWellInfo::getGlobalPerfContainerFactory() const "No ecl indices have been added via beginReset, pushBackEclIndex, endReset"); } -bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2) +template +bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2) { - return well1.name() < well2.name() || (! (well2.name() < well1.name()) && well1.hasLocalCells() < well2.hasLocalCells()); + return well1.name() < well2.name() || (! (well2.name() < well1.name()) && + well1.hasLocalCells() < well2.hasLocalCells()); } -bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2) +template +bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2) { bool ret = well1.name() == well2.name() && well1.hasLocalCells() == well2.hasLocalCells() && well1.isOwner() == well2.isOwner(); @@ -575,56 +621,67 @@ bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2) return ret; } -bool operator!=(const ParallelWellInfo& well1, const ParallelWellInfo& well2) +template +bool operator!=(const ParallelWellInfo& well1, const ParallelWellInfo& well2) { return ! (well1 == well2); } -bool operator<(const std::pair& pair, const ParallelWellInfo& well) +template +bool operator<(const std::pair& pair, const ParallelWellInfo& well) { return pair.first < well.name() || ( !( well.name() < pair.first ) && pair.second < well.hasLocalCells() ); } -bool operator<( const ParallelWellInfo& well, const std::pair& pair) +template +bool operator<( const ParallelWellInfo& well, const std::pair& pair) { return well.name() < pair.first || ( !( pair.first < well.name() ) && well.hasLocalCells() < pair.second ); } -bool operator==(const std::pair& pair, const ParallelWellInfo& well) +template +bool operator==(const std::pair& pair, const ParallelWellInfo& well) { return pair.first == well.name() && pair.second == well.hasLocalCells(); } -bool operator==(const ParallelWellInfo& well, const std::pair& pair) +template +bool operator==(const ParallelWellInfo& well, const std::pair& pair) { return pair == well; } -bool operator!=(const std::pair& pair, const ParallelWellInfo& well) +template +bool operator!=(const std::pair& pair, const ParallelWellInfo& well) { return pair.first != well.name() || pair.second != well.hasLocalCells(); } -bool operator!=(const ParallelWellInfo& well, const std::pair& pair) +template +bool operator!=(const ParallelWellInfo& well, const std::pair& pair) { return pair != well; } -CheckDistributedWellConnections::CheckDistributedWellConnections(const Well& well, - const ParallelWellInfo& info) +template +CheckDistributedWellConnections:: +CheckDistributedWellConnections(const Well& well, + const ParallelWellInfo& info) : well_(well), pwinfo_(info) { foundConnections_.resize(well.getConnections().size(), 0); } -void -CheckDistributedWellConnections::connectionFound(std::size_t i) +template +void CheckDistributedWellConnections:: +connectionFound(std::size_t i) { foundConnections_[i] = 1; } -bool -CheckDistributedWellConnections::checkAllConnectionsFound() +template +bool CheckDistributedWellConnections:: +checkAllConnectionsFound() { // Ecl does not hold any information of remote connections. assert(pwinfo_.communication().max(foundConnections_.size()) == foundConnections_.size()); @@ -652,4 +709,30 @@ CheckDistributedWellConnections::checkAllConnectionsFound() } return !missingCells; } + +template using dIter = typename std::vector::iterator; +template using cdIter = typename std::vector::const_iterator; + +#define INSTANCE(T) \ + template class CheckDistributedWellConnections; \ + template class CommunicateAboveBelow; \ + template class GlobalPerfContainerFactory; \ + template class ParallelWellInfo; \ + template typename cdIter::value_type \ + ParallelWellInfo::sumPerfValues>(cdIter,cdIter) const; \ + template typename dIter::value_type \ + ParallelWellInfo::sumPerfValues>(dIter,dIter) const; \ + template void CommunicateAboveBelow::partialSumPerfValues>(dIter, dIter) const; \ + template bool operator<(const ParallelWellInfo&, const ParallelWellInfo&); \ + template bool operator<(const ParallelWellInfo&, const std::pair&); \ + template bool operator<(const std::pair&, const ParallelWellInfo&); \ + template bool operator==(const ParallelWellInfo&, const ParallelWellInfo&); \ + template bool operator==(const ParallelWellInfo& well, const std::pair&); \ + template bool operator==(const std::pair&, const ParallelWellInfo&); \ + template bool operator!=(const ParallelWellInfo&, const ParallelWellInfo&); \ + template bool operator!=(const std::pair&, const ParallelWellInfo&); \ + template bool operator!=(const ParallelWellInfo&, const std::pair&); + +INSTANCE(double) + } // end namespace Opm diff --git a/opm/simulators/wells/ParallelWellInfo.hpp b/opm/simulators/wells/ParallelWellInfo.hpp index 48ceff6b2..4439ff9bb 100644 --- a/opm/simulators/wells/ParallelWellInfo.hpp +++ b/opm/simulators/wells/ParallelWellInfo.hpp @@ -29,13 +29,13 @@ #include -namespace Opm -{ +namespace Opm { class Well; /// \brief Class to facilitate getting values associated with the above/below perforation /// +template class CommunicateAboveBelow { public: @@ -83,8 +83,8 @@ public: /// \param current C-array of the values at the perforations /// \param size The size of the C-array and the returned vector /// \return a vector containing the values for the perforation above. - std::vector communicateAbove(double first_value, - const double* current, + std::vector communicateAbove(Scalar first_value, + const Scalar* current, std::size_t size); /// \brief Creates an array of values for the perforation below. @@ -92,8 +92,8 @@ public: /// \param current C-array of the values at the perforations /// \param size The size of the C-array and the returned vector /// \return a vector containing the values for the perforation above. - std::vector communicateBelow(double first_value, - const double* current, + std::vector communicateBelow(Scalar first_value, + const Scalar* current, std::size_t size); /// \brief Do a (in place) partial sum on values attached to all perforations. @@ -131,11 +131,12 @@ private: /// even if the data is distributed. This class is supposed to help with that by /// computing the global data arrays for the well and copy computed values back to /// the distributed representation. +template class GlobalPerfContainerFactory { public: - using IndexSet = CommunicateAboveBelow::IndexSet; - using Attribute = CommunicateAboveBelow::Attribute; + using IndexSet = typename CommunicateAboveBelow::IndexSet; + using Attribute = typename CommunicateAboveBelow::Attribute; using GlobalIndex = typename IndexSet::IndexPair::GlobalIndex; /// \brief Constructor @@ -149,14 +150,14 @@ public: /// \param num_components the number of components per perforation. /// \return A container with values attached to all perforations of a well. /// Values are ordered by the index of the perforation in the ECL schedule. - std::vector createGlobal(const std::vector& local_perf_container, + std::vector createGlobal(const std::vector& local_perf_container, std::size_t num_components) const; /// \brief Copies the values of the global perforation to the local representation /// \param global values attached to all peforations of a well (as if the well would live on one process) /// \param num_components the number of components per perforation. /// \param[out] local The values attached to the local perforations only. - void copyGlobalToLocal(const std::vector& global, std::vector& local, + void copyGlobalToLocal(const std::vector& global, std::vector& local, std::size_t num_components) const; int numGlobalPerfs() const; @@ -180,6 +181,7 @@ private: /// \brief Class encapsulating some information about parallel wells /// /// e.g. It provides a communicator for well information +template class ParallelWellInfo { public: @@ -218,30 +220,30 @@ public: /// \param current C-array of the values at the perforations /// \param size The size of the C-array and the returned vector /// \return a vector containing the values for the perforation above. - std::vector communicateAboveValues(double first_value, - const double* current, + std::vector communicateAboveValues(Scalar first_value, + const Scalar* current, std::size_t size) const; /// \brief Creates an array of values for the perforation above. /// \param first_value Value to use for above of the first perforation /// \param current vector of current values - std::vector communicateAboveValues(double first_value, - const std::vector& current) const; + std::vector communicateAboveValues(Scalar first_value, + const std::vector& current) const; /// \brief Creates an array of values for the perforation below. /// \param last_value Value to use for below of the last perforation /// \param current C-array of the values at the perforations /// \param size The size of the C-array and the returned vector /// \return a vector containing the values for the perforation above. - std::vector communicateBelowValues(double last_value, - const double* current, + std::vector communicateBelowValues(Scalar last_value, + const Scalar* current, std::size_t size) const; /// \brief Creates an array of values for the perforation above. /// \param last_value Value to use for below of the last perforation /// \param current vector of current values - std::vector communicateBelowValues(double last_value, - const std::vector& current) const; + std::vector communicateBelowValues(Scalar last_value, + const std::vector& current) const; /// \brief Adds information about the ecl indices of the perforations. /// @@ -301,7 +303,7 @@ public: /// That is a container that holds data for every perforation no matter where /// it is stored. Container is ordered via ascendings index of the perforations /// in the ECL schedule. - const GlobalPerfContainerFactory& getGlobalPerfContainerFactory() const; + const GlobalPerfContainerFactory& getGlobalPerfContainerFactory() const; private: @@ -326,19 +328,20 @@ private: std::unique_ptr comm_; /// \brief used to communicate the values for the perforation above. - std::unique_ptr commAboveBelow_; + std::unique_ptr> commAboveBelow_; - std::unique_ptr globalPerfCont_; + std::unique_ptr> globalPerfCont_; }; /// \brief Class checking that all connections are on active cells /// /// Works for distributed wells, too +template class CheckDistributedWellConnections { public: CheckDistributedWellConnections(const Well& well, - const ParallelWellInfo& info); + const ParallelWellInfo& info); /// \brief Inidicate that the i-th completion was found /// @@ -351,26 +354,36 @@ public: private: std::vector foundConnections_; const Well& well_; - const ParallelWellInfo& pwinfo_; + const ParallelWellInfo& pwinfo_; }; -bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2); +template +bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2); -bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2); +template +bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2); -bool operator!=(const ParallelWellInfo& well1, const ParallelWellInfo& well2); +template +bool operator!=(const ParallelWellInfo& well1, const ParallelWellInfo& well2); -bool operator<(const std::pair& pair, const ParallelWellInfo& well); +template +bool operator<(const std::pair& pair, const ParallelWellInfo& well); -bool operator<( const ParallelWellInfo& well, const std::pair& pair); +template +bool operator<( const ParallelWellInfo& well, const std::pair& pair); -bool operator==(const std::pair& pair, const ParallelWellInfo& well); +template +bool operator==(const std::pair& pair, const ParallelWellInfo& well); -bool operator==(const ParallelWellInfo& well, const std::pair& pair); +template +bool operator==(const ParallelWellInfo& well, const std::pair& pair); -bool operator!=(const std::pair& pair, const ParallelWellInfo& well); +template +bool operator!=(const std::pair& pair, const ParallelWellInfo& well); -bool operator!=(const ParallelWellInfo& well, const std::pair& pair); +template +bool operator!=(const ParallelWellInfo& well, const std::pair& pair); } // end namespace Opm + #endif // OPM_PARALLELWELLINFO_HEADER_INCLUDED diff --git a/opm/simulators/wells/SingleWellState.cpp b/opm/simulators/wells/SingleWellState.cpp index 68c62fb2a..a297f69ad 100644 --- a/opm/simulators/wells/SingleWellState.cpp +++ b/opm/simulators/wells/SingleWellState.cpp @@ -31,7 +31,7 @@ namespace Opm { template SingleWellState:: SingleWellState(const std::string& name_, - const ParallelWellInfo& pinfo, + const ParallelWellInfo& pinfo, bool is_producer, Scalar pressure_first_connection, const std::vector>& perf_input, @@ -63,7 +63,7 @@ SingleWellState(const std::string& name_, template SingleWellState SingleWellState:: -serializationTestObject(const ParallelWellInfo& pinfo) +serializationTestObject(const ParallelWellInfo& pinfo) { SingleWellState result("testing", pinfo, true, 1.0, {}, PhaseUsage{}, 2.0); result.perf_data = PerfData::serializationTestObject(); diff --git a/opm/simulators/wells/SingleWellState.hpp b/opm/simulators/wells/SingleWellState.hpp index e78cd4c20..c2948bb61 100644 --- a/opm/simulators/wells/SingleWellState.hpp +++ b/opm/simulators/wells/SingleWellState.hpp @@ -41,14 +41,14 @@ template class SingleWellState { public: SingleWellState(const std::string& name, - const ParallelWellInfo& pinfo, + const ParallelWellInfo& pinfo, bool is_producer, Scalar presssure_first_connection, const std::vector>& perf_input, const PhaseUsage& pu, Scalar temp); - static SingleWellState serializationTestObject(const ParallelWellInfo& pinfo); + static SingleWellState serializationTestObject(const ParallelWellInfo& pinfo); template void serializeOp(Serializer& serializer) @@ -79,7 +79,7 @@ public: bool operator==(const SingleWellState&) const; std::string name; - std::reference_wrapper parallel_info; + std::reference_wrapper> parallel_info; WellStatus status{WellStatus::OPEN}; bool producer; diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 923f3126f..d02c04e7e 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -120,7 +120,7 @@ namespace Opm using BVectorWell = typename StdWellEval::BVectorWell; StandardWell(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/StandardWellEquations.cpp b/opm/simulators/wells/StandardWellEquations.cpp index 31f3986d6..bcce8c414 100644 --- a/opm/simulators/wells/StandardWellEquations.cpp +++ b/opm/simulators/wells/StandardWellEquations.cpp @@ -42,7 +42,7 @@ namespace Opm template StandardWellEquations:: -StandardWellEquations(const ParallelWellInfo& parallel_well_info) +StandardWellEquations(const ParallelWellInfo& parallel_well_info) : parallelB_(duneB_, parallel_well_info) { duneB_.setBuildMode(OffDiagMatWell::row_wise); diff --git a/opm/simulators/wells/StandardWellEquations.hpp b/opm/simulators/wells/StandardWellEquations.hpp index 8636c376d..ae7c26bbd 100644 --- a/opm/simulators/wells/StandardWellEquations.hpp +++ b/opm/simulators/wells/StandardWellEquations.hpp @@ -34,7 +34,7 @@ namespace Opm { -class ParallelWellInfo; +template class ParallelWellInfo; template class StandardWellEquationAccess; #if COMPILE_BDA_BRIDGE class WellContributions; @@ -65,7 +65,7 @@ public: // block vector type using BVector = Dune::BlockVector>; - StandardWellEquations(const ParallelWellInfo& parallel_well_info); + StandardWellEquations(const ParallelWellInfo& parallel_well_info); //! \brief Setup sparsity pattern for the matrices. //! \param num_cells Total number of cells diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 2578dc166..e09c20c7d 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -70,7 +70,7 @@ namespace Opm template StandardWell:: StandardWell(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/WGState.cpp b/opm/simulators/wells/WGState.cpp index 5d78af585..26ebbcf64 100644 --- a/opm/simulators/wells/WGState.cpp +++ b/opm/simulators/wells/WGState.cpp @@ -35,7 +35,7 @@ WGState::WGState(const PhaseUsage& pu) : template WGState WGState:: -serializationTestObject(const ParallelWellInfo& pinfo) +serializationTestObject(const ParallelWellInfo& pinfo) { WGState result(PhaseUsage{}); result.well_state = WellState::serializationTestObject(pinfo); diff --git a/opm/simulators/wells/WGState.hpp b/opm/simulators/wells/WGState.hpp index 9fd84b12e..8cea11c5a 100644 --- a/opm/simulators/wells/WGState.hpp +++ b/opm/simulators/wells/WGState.hpp @@ -26,7 +26,7 @@ namespace Opm { -class ParallelWellInfo; +template class ParallelWellInfo; /* Microscopic class to handle well, group and well test state. @@ -39,7 +39,7 @@ struct WGState { WGState(const PhaseUsage& pu); - static WGState serializationTestObject(const ParallelWellInfo& pinfo); + static WGState serializationTestObject(const ParallelWellInfo& pinfo); void wtest_state(WellTestState wtest_state); diff --git a/opm/simulators/wells/WellHelpers.cpp b/opm/simulators/wells/WellHelpers.cpp index 0a0feb42f..f95d82138 100644 --- a/opm/simulators/wells/WellHelpers.cpp +++ b/opm/simulators/wells/WellHelpers.cpp @@ -41,7 +41,8 @@ namespace wellhelpers { template ParallelStandardWellB:: -ParallelStandardWellB(const Matrix& B, const ParallelWellInfo& parallel_well_info) +ParallelStandardWellB(const Matrix& B, + const ParallelWellInfo& parallel_well_info) : B_(B), parallel_well_info_(parallel_well_info) {} diff --git a/opm/simulators/wells/WellHelpers.hpp b/opm/simulators/wells/WellHelpers.hpp index 2be2dc1e1..6e86c06b1 100644 --- a/opm/simulators/wells/WellHelpers.hpp +++ b/opm/simulators/wells/WellHelpers.hpp @@ -28,7 +28,7 @@ namespace Opm { -class ParallelWellInfo; +template class ParallelWellInfo; struct WellProductionControls; struct WellInjectionControls; enum class WellProducerCMode; @@ -53,7 +53,8 @@ public: using Block = Dune::DynamicMatrix; using Matrix = Dune::BCRSMatrix; - ParallelStandardWellB(const Matrix& B, const ParallelWellInfo& parallel_well_info); + ParallelStandardWellB(const Matrix& B, + const ParallelWellInfo& parallel_well_info); //! y = A x template @@ -65,7 +66,7 @@ public: private: const Matrix& B_; - const ParallelWellInfo& parallel_well_info_; + const ParallelWellInfo& parallel_well_info_; }; template diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index 2d9384749..5df1faa4b 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -133,7 +133,7 @@ public: Indices::numPhases >; /// Constructor WellInterface(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.cpp b/opm/simulators/wells/WellInterfaceFluidSystem.cpp index 8dae9df55..a377e9e68 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -46,7 +46,7 @@ namespace Opm template WellInterfaceFluidSystem:: WellInterfaceFluidSystem(const Well& well, - const ParallelWellInfo& parallel_well_info, + const ParallelWellInfo& parallel_well_info, const int time_step, const RateConverterType& rate_converter, const int pvtRegionIdx, diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.hpp b/opm/simulators/wells/WellInterfaceFluidSystem.hpp index eacd611ca..c2c15f242 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.hpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.hpp @@ -68,7 +68,7 @@ public: protected: WellInterfaceFluidSystem(const Well& well, - const ParallelWellInfo& parallel_well_info, + const ParallelWellInfo& parallel_well_info, const int time_step, const RateConverterType& rate_converter, const int pvtRegionIdx, diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index 4c472462d..5c0417544 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -54,7 +54,7 @@ namespace Opm { template WellInterfaceGeneric:: WellInterfaceGeneric(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const int pvtRegionIdx, const int num_components, diff --git a/opm/simulators/wells/WellInterfaceGeneric.hpp b/opm/simulators/wells/WellInterfaceGeneric.hpp index c8d16cf1e..440561e5d 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.hpp +++ b/opm/simulators/wells/WellInterfaceGeneric.hpp @@ -36,7 +36,7 @@ namespace Opm class DeferredLogger; class GuideRate; -class ParallelWellInfo; +template class ParallelWellInfo; template struct PerforationData; struct PhaseUsage; class SummaryState; @@ -51,7 +51,7 @@ template class WellInterfaceGeneric { public: WellInterfaceGeneric(const Well& well, - const ParallelWellInfo& parallel_well_info, + const ParallelWellInfo& parallel_well_info, const int time_step, const int pvtRegionIdx, const int num_components, @@ -131,7 +131,7 @@ public: const VFPProperties* vfpProperties() const { return vfp_properties_; } - const ParallelWellInfo& parallelWellInfo() const { return parallel_well_info_; } + const ParallelWellInfo& parallelWellInfo() const { return parallel_well_info_; } const std::vector& perfDepth() const { return perf_depth_; } @@ -271,7 +271,7 @@ protected: Well well_ecl_; - const ParallelWellInfo& parallel_well_info_; + const ParallelWellInfo& parallel_well_info_; const int current_step_; // The pvt region of the well. We assume diff --git a/opm/simulators/wells/WellInterfaceIndices.cpp b/opm/simulators/wells/WellInterfaceIndices.cpp index e564cef04..ba88f3d12 100644 --- a/opm/simulators/wells/WellInterfaceIndices.cpp +++ b/opm/simulators/wells/WellInterfaceIndices.cpp @@ -36,7 +36,7 @@ namespace Opm template WellInterfaceIndices:: WellInterfaceIndices(const Well& well, - const ParallelWellInfo& parallel_well_info, + const ParallelWellInfo& parallel_well_info, const int time_step, const typename WellInterfaceFluidSystem::RateConverterType& rate_converter, const int pvtRegionIdx, diff --git a/opm/simulators/wells/WellInterfaceIndices.hpp b/opm/simulators/wells/WellInterfaceIndices.hpp index c87c6590c..b339625c5 100644 --- a/opm/simulators/wells/WellInterfaceIndices.hpp +++ b/opm/simulators/wells/WellInterfaceIndices.hpp @@ -56,7 +56,7 @@ public: protected: WellInterfaceIndices(const Well& well, - const ParallelWellInfo& parallel_well_info, + const ParallelWellInfo& parallel_well_info, const int time_step, const typename WellInterfaceFluidSystem::RateConverterType& rate_converter, const int pvtRegionIdx, diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 391eeb6bc..a5ef4a64d 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -53,7 +53,7 @@ namespace Opm template WellInterface:: WellInterface(const Well& well, - const ParallelWellInfo& pw_info, + const ParallelWellInfo& pw_info, const int time_step, const ModelParameters& param, const RateConverterType& rate_converter, diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index d88fc656c..02a471ff9 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -128,7 +128,7 @@ void PackUnpackXConn::unpack([[maybe_unused]] const int link, namespace Opm { template -WellState::WellState(const ParallelWellInfo& pinfo) +WellState::WellState(const ParallelWellInfo& pinfo) : phase_usage_{} { wells_.add("test4", @@ -137,7 +137,7 @@ WellState::WellState(const ParallelWellInfo& pinfo) template WellState WellState:: -serializationTestObject(const ParallelWellInfo& pinfo) +serializationTestObject(const ParallelWellInfo& pinfo) { WellState result(PhaseUsage{}); result.alq_state = ALQState::serializationTestObject(); @@ -150,7 +150,7 @@ serializationTestObject(const ParallelWellInfo& pinfo) template void WellState::base_init(const std::vector& cellPressures, const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const std::vector>>& well_perf_data, const SummaryState& summary_state) { @@ -171,7 +171,7 @@ void WellState::base_init(const std::vector& cellPressures, template void WellState::initSingleProducer(const Well& well, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, Scalar pressure_first_connection, const std::vector>& well_perf_data, const SummaryState& summary_state) @@ -200,7 +200,7 @@ void WellState::initSingleProducer(const Well& well, template void WellState::initSingleInjector(const Well& well, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, Scalar pressure_first_connection, const std::vector>& well_perf_data, const SummaryState& summary_state) @@ -230,7 +230,7 @@ template void WellState::initSingleWell(const std::vector& cellPressures, const Well& well, const std::vector>& well_perf_data, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, const SummaryState& summary_state) { Scalar pressure_first_connection = -1; @@ -251,7 +251,7 @@ template void WellState::init(const std::vector& cellPressures, const Schedule& schedule, const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const int report_step, const WellState* prevState, const std::vector>>& well_perf_data, @@ -420,7 +420,7 @@ void WellState::init(const std::vector& cellPressures, template void WellState::resize(const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const Schedule& schedule, const bool handle_ms_well, const std::size_t numCells, @@ -1044,7 +1044,7 @@ bool WellState::operator==(const WellState& rhs) const } template -const ParallelWellInfo& +const ParallelWellInfo& WellState::parallelWellInfo(std::size_t well_index) const { const auto& ws = this->well(well_index); diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 5541ab475..7ddfddff7 100644 --- a/opm/simulators/wells/WellState.hpp +++ b/opm/simulators/wells/WellState.hpp @@ -50,7 +50,7 @@ namespace Opm { -class ParallelWellInfo; +template class ParallelWellInfo; template struct PerforationData; class Schedule; enum class WellStatus; @@ -68,13 +68,13 @@ public: static const int Gas = BlackoilPhases::Vapour; // Only usable for testing purposes - explicit WellState(const ParallelWellInfo& pinfo); + explicit WellState(const ParallelWellInfo& pinfo); explicit WellState(const PhaseUsage& pu) : phase_usage_(pu) {} - static WellState serializationTestObject(const ParallelWellInfo& pinfo); + static WellState serializationTestObject(const ParallelWellInfo& pinfo); std::size_t size() const { @@ -91,7 +91,7 @@ public: return this->size(); } - const ParallelWellInfo& parallelWellInfo(std::size_t well_index) const; + const ParallelWellInfo& parallelWellInfo(std::size_t well_index) const; /// Allocate and initialize if wells is non-null. Also tries /// to give useful initial values to the bhp(), wellRates() @@ -99,14 +99,14 @@ public: void init(const std::vector& cellPressures, const Schedule& schedule, const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const int report_step, const WellState* prevState, const std::vector>>& well_perf_data, const SummaryState& summary_state); void resize(const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const Schedule& schedule, const bool handle_ms_well, const std::size_t numCells, @@ -378,24 +378,24 @@ private: /// with -1e100. void base_init(const std::vector& cellPressures, const std::vector& wells_ecl, - const std::vector>& parallel_well_info, + const std::vector>>& parallel_well_info, const std::vector>>& well_perf_data, const SummaryState& summary_state); void initSingleWell(const std::vector& cellPressures, const Well& well, const std::vector>& well_perf_data, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, const SummaryState& summary_state); void initSingleProducer(const Well& well, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, Scalar pressure_first_connection, const std::vector>& well_perf_data, const SummaryState& summary_state); void initSingleInjector(const Well& well, - const ParallelWellInfo& well_info, + const ParallelWellInfo& well_info, Scalar pressure_first_connection, const std::vector>& well_perf_data, const SummaryState& summary_state); diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index 7645c45c8..f5709482a 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -149,7 +149,7 @@ TEST_FOR_TYPE_NAMED(BVec, BlockVectorWrapper) BOOST_AUTO_TEST_CASE(SingleWellState) { - Opm::ParallelWellInfo dummy; + Opm::ParallelWellInfo dummy; auto data_out = Opm::SingleWellState::serializationTestObject(dummy); Opm::Serialization::MemPacker packer; Opm::Serializer ser(packer); @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(WellContainer) BOOST_AUTO_TEST_CASE(WellState) { - Opm::ParallelWellInfo dummy; + Opm::ParallelWellInfo dummy; auto data_out = Opm::WellState::serializationTestObject(dummy); Opm::Serialization::MemPacker packer; Opm::Serializer ser(packer); @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(WellState) BOOST_AUTO_TEST_CASE(WGState) { - Opm::ParallelWellInfo dummy; + Opm::ParallelWellInfo dummy; auto data_out = Opm::WGState::serializationTestObject(dummy); Opm::Serialization::MemPacker packer; Opm::Serializer ser(packer); @@ -354,7 +354,7 @@ public: } private: - ParallelWellInfo dummy; + ParallelWellInfo dummy; }; } diff --git a/tests/test_parallel_wbp_calculation.cpp b/tests/test_parallel_wbp_calculation.cpp index de28824d6..8a0b16010 100644 --- a/tests/test_parallel_wbp_calculation.cpp +++ b/tests/test_parallel_wbp_calculation.cpp @@ -457,10 +457,10 @@ namespace { return w; } - Opm::ParallelWellInfo + Opm::ParallelWellInfo parallelWellInfo(const Opm::Parallel::Communication& comm) { - auto pwi = Opm::ParallelWellInfo { + auto pwi = Opm::ParallelWellInfo { std::pair { std::string{ "P" }, true }, comm }; @@ -469,7 +469,7 @@ namespace { const auto numLocalPerf = 3; const auto perfOffset = comm.rank() * numLocalPerf; - auto prev = Opm::ParallelWellInfo::INVALID_ECL_INDEX; + auto prev = Opm::ParallelWellInfo::INVALID_ECL_INDEX; for (auto perf = 0; perf < numLocalPerf; ++perf) { const auto curr = perfOffset + perf; pwi.pushBackEclIndex(prev, curr); @@ -552,7 +552,7 @@ namespace { Opm::Parallel::Communication comm; Opm::GridDims cellIndexMap; Opm::ParallelWBPCalculation wbpCalcService; - Opm::ParallelWellInfo pwi; + Opm::ParallelWellInfo pwi; }; } // Anonymous namespace diff --git a/tests/test_parallelwellinfo.cpp b/tests/test_parallelwellinfo.cpp index 79bb83c16..2da84d22d 100644 --- a/tests/test_parallelwellinfo.cpp +++ b/tests/test_parallelwellinfo.cpp @@ -97,7 +97,7 @@ std::ostream& operator<<(std::ostream& os, const std::pair& p } namespace Opm { -std::ostream& operator<<(std::ostream& os, const Opm::ParallelWellInfo& w) +std::ostream& operator<<(std::ostream& os, const Opm::ParallelWellInfo& w) { return os << "{" << w.name() << " "<< w.hasLocalCells() << " "<< w.isOwner() << "}"; @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(ParallelWellComparison) else pairs = {{"Test1", false},{"Test2", true}, {"Test1", true} }; - std::vector well_info; + std::vector> well_info; for (const auto& wellinfo : pairs) { well_info.emplace_back(wellinfo, Opm::Parallel::Communication()); @@ -138,16 +138,16 @@ BOOST_AUTO_TEST_CASE(ParallelWellComparison) BOOST_CHECK(well_info[0] != well_info[1]); - Opm::ParallelWellInfo well0, well1; + Opm::ParallelWellInfo well0, well1; BOOST_CHECK(well0 == well1); #if HAVE_MPI BOOST_CHECK(well0.communication()==helper.getLocalCommunicator()); #endif - Opm::ParallelWellInfo well2("Test", false); + Opm::ParallelWellInfo well2("Test", false); std::pair pwell={"Test", true}; BOOST_CHECK(well2 < pwell); - Opm::ParallelWellInfo well3("Test", true); + Opm::ParallelWellInfo well3("Test", true); BOOST_CHECK(! (well3 < pwell)); pwell.second = false; BOOST_CHECK(! (well3 < pwell)); @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(ParallelWellComparison) BOOST_AUTO_TEST_CASE(CommunicateAboveBelowSelf) { auto comm = Dune::MPIHelper::getLocalCommunicator(); - Opm::CommunicateAboveBelow commAboveBelow{ comm }; + Opm::CommunicateAboveBelow commAboveBelow{ comm }; for(std::size_t count=0; count < 2; ++count) { std::vector eclIndex = {0, 1, 2, 3, 7 , 8, 10, 11}; @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(CommunicateAboveBelowSelf) BOOST_AUTO_TEST_CASE(CommunicateAboveBelowSelf1) { auto comm = Dune::MPIHelper::getLocalCommunicator(); - Opm::CommunicateAboveBelow commAboveBelow{ comm }; + Opm::CommunicateAboveBelow commAboveBelow{ comm }; for(std::size_t count=0; count < 2; ++count) { std::vector eclIndex = {0}; @@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(CommunicateAboveBelowParallel) { auto comm = Opm::Parallel::Communication(Dune::MPIHelper::getCommunicator()); - Opm::CommunicateAboveBelow commAboveBelow{ comm }; + Opm::CommunicateAboveBelow commAboveBelow{ comm }; for(std::size_t count=0; count < 2; ++count) { auto globalEclIndex = createGlobalEclIndex(comm); @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(PartialSumself) { auto comm = Dune::MPIHelper::getLocalCommunicator(); - Opm::CommunicateAboveBelow commAboveBelow{ comm }; + Opm::CommunicateAboveBelow commAboveBelow{ comm }; std::vector eclIndex = {0, 1, 2, 3, 7 , 8, 10, 11}; std::vector current(eclIndex.size()); std::transform(eclIndex.begin(), eclIndex.end(), current.begin(), @@ -383,7 +383,7 @@ BOOST_AUTO_TEST_CASE(PartialSumParallel) auto comm = Opm::Parallel::Communication(Dune::MPIHelper::getCommunicator()); - Opm::CommunicateAboveBelow commAboveBelow{ comm }; + Opm::CommunicateAboveBelow commAboveBelow{ comm }; auto globalEclIndex = createGlobalEclIndex(comm); std::vector globalCurrent(globalEclIndex.size()); initRandomNumbers(std::begin(globalCurrent), std::end(globalCurrent), @@ -411,7 +411,7 @@ void testGlobalPerfFactoryParallel(int num_component, bool local_consecutive = f { auto comm = Opm::Parallel::Communication(Dune::MPIHelper::getCommunicator()); - Opm::ParallelWellInfo wellInfo{ {"Test", true }, comm }; + Opm::ParallelWellInfo wellInfo{ {"Test", true }, comm }; auto globalEclIndex = createGlobalEclIndex(comm); std::vector globalCurrent(globalEclIndex.size() * num_component); std::vector globalAdd(globalEclIndex.size() * num_component); @@ -425,7 +425,7 @@ void testGlobalPerfFactoryParallel(int num_component, bool local_consecutive = f local_consecutive); // A hack to get local values to add. - Opm::ParallelWellInfo dummy{ {"Test", true }, comm }; + Opm::ParallelWellInfo dummy{ {"Test", true }, comm }; auto localAdd = populateCommAbove(dummy, comm, globalEclIndex, globalAdd, num_component, local_consecutive); @@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE(GlobalPerfFactoryParallel1) BOOST_AUTO_TEST_CASE(EmptyWell) { auto comm = Opm::Parallel::Communication(Dune::MPIHelper::getCommunicator()); - Opm::ParallelWellInfo pw({"WELL1", true}, comm); + Opm::ParallelWellInfo pw({"WELL1", true}, comm); pw.communicateFirstPerforation(false); double local_p = 1; auto global_p = pw.broadcastFirstPerforationValue(local_p); diff --git a/tests/test_wellmodel.cpp b/tests/test_wellmodel.cpp index 96b1982c6..978b6f951 100644 --- a/tests/test_wellmodel.cpp +++ b/tests/test_wellmodel.cpp @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(TestStandardWellInput) { pdata[c].ecl_index = c; } - Opm::ParallelWellInfo pinfo{well.name()}; + Opm::ParallelWellInfo pinfo{well.name()}; BOOST_CHECK_THROW( StandardWell( well, pinfo, -1, param, *rateConverter, 0, 3, 3, 0, pdata), std::invalid_argument); } @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(TestBehavoir) { pdata[c].ecl_index = c; } - Opm::ParallelWellInfo pinfo{wells_ecl[w].name()}; + Opm::ParallelWellInfo pinfo{wells_ecl[w].name()}; wells.emplace_back(new StandardWell(wells_ecl[w], pinfo, current_timestep, param, *rateConverter, 0, 3, 3, w, pdata) ); } } diff --git a/tests/test_wellstate.cpp b/tests/test_wellstate.cpp index 274098c80..2d7340003 100644 --- a/tests/test_wellstate.cpp +++ b/tests/test_wellstate.cpp @@ -139,7 +139,7 @@ struct Setup namespace { Opm::WellState buildWellState(const Setup& setup, const std::size_t timeStep, - std::vector& pinfos) + std::vector>& pinfos) { auto state = Opm::WellState{setup.pu}; @@ -149,7 +149,7 @@ namespace { auto wells = setup.sched.getWells(timeStep); pinfos.resize(wells.size()); - std::vector> ppinfos; + std::vector>> ppinfos; auto pw = pinfos.begin(); for (const auto& well : wells) @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(Linearisation) const Setup setup{ "msw.data" }; const auto tstep = std::size_t{0}; - std::vector pinfos; + std::vector> pinfos; const auto wstate = buildWellState(setup, tstep, pinfos); const auto& ws = wstate.well("PROD01"); @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(Pressure) const Setup setup{ "msw.data" }; const auto tstep = std::size_t{0}; - std::vector pinfos; + std::vector> pinfos; auto wstate = buildWellState(setup, tstep, pinfos); const auto& wells = setup.sched.getWells(tstep); @@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(Rates) const Setup setup{ "msw.data" }; const auto tstep = std::size_t{0}; - std::vector pinfos; + std::vector> pinfos; auto wstate = buildWellState(setup, tstep, pinfos); const auto wells = setup.sched.getWells(tstep); @@ -368,7 +368,7 @@ BOOST_AUTO_TEST_CASE(STOP_well) */ const Setup setup{ "wells_manager_data_wellSTOP.data" }; - std::vector pinfos; + std::vector> pinfos; auto wstate = buildWellState(setup, 0, pinfos); for (std::size_t well_index = 0; well_index < setup.sched.numWells(0); well_index++) { const auto& ws = wstate.well(well_index); @@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(TESTSegmentState) { BOOST_AUTO_TEST_CASE(TESTSegmentState2) { const Setup setup{ "msw.data" }; - std::vector pinfo; + std::vector> pinfo; const auto wstate = buildWellState(setup, 0, pinfo); const auto& well = setup.sched.getWell("PROD01", 0); const auto& ws = wstate.well("PROD01"); @@ -581,7 +581,7 @@ BOOST_AUTO_TEST_CASE(TESTPerfData) { BOOST_AUTO_TEST_CASE(TestSingleWellState) { - Opm::ParallelWellInfo pinfo; + Opm::ParallelWellInfo pinfo; std::vector> connections = {{0,1,1,0,0},{1,1,1,0,1},{2,1,1,0,2}}; Opm::PhaseUsage pu;