19#ifndef OPM_PARALLELWELLINFO_HEADER_INCLUDED
20#define OPM_PARALLELWELLINFO_HEADER_INCLUDED
22#include <dune/common/parallel/communicator.hh>
23#include <dune/common/parallel/interface.hh>
24#include <dune/common/parallel/mpihelper.hh>
25#include <dune/common/parallel/plocalindex.hh>
26#include <dune/common/parallel/remoteindices.hh>
28#include <opm/simulators/utils/ParallelCommunication.hpp>
51 using LocalIndex = Dune::ParallelLocalIndex<Attribute>;
52 using IndexSet = Dune::ParallelIndexSet<int,LocalIndex,50>;
54 using RI = Dune::RemoteIndices<IndexSet>;
87 const Scalar* current,
96 const Scalar* current,
106 template<
class RAIterator>
112 int numLocalPerfs()
const;
115 Parallel::Communication comm_;
117 IndexSet current_indices_;
120 IndexSet above_indices_;
122 Dune::Interface interface_;
123 Dune::BufferedCommunicator communicator_;
125 std::size_t num_local_perfs_{};
134template<
class Scalar>
138 using IndexSet =
typename CommunicateAboveBelow<Scalar>::IndexSet;
139 using Attribute =
typename CommunicateAboveBelow<Scalar>::Attribute;
140 using GlobalIndex =
typename IndexSet::IndexPair::GlobalIndex;
145 const Parallel::Communication comm,
146 int num_local_perfs);
153 std::vector<Scalar>
createGlobal(
const std::vector<Scalar>& local_perf_container,
154 std::size_t num_components)
const;
160 void copyGlobalToLocal(
const std::vector<Scalar>& global, std::vector<Scalar>& local,
161 std::size_t num_components)
const;
163 int numGlobalPerfs()
const;
166 const IndexSet& local_indices_;
167 Parallel::Communication comm_;
168 int num_global_perfs_;
170 std::vector<int> sizes_;
172 std::vector<int> displ_;
174 std::vector<int> map_received_;
178 std::vector<int> perf_ecl_index_;
184template<
class Scalar>
188 static constexpr int INVALID_ECL_INDEX = -1;
201 Parallel::Communication allComm);
203 const Parallel::Communication& communication()
const
224 const Scalar* current,
225 std::size_t size)
const;
231 const std::vector<Scalar>& current)
const;
239 const Scalar* current,
240 std::size_t size)
const;
246 const std::vector<Scalar>& current)
const;
258 const std::string&
name()
const
266 return hasLocalCells_;
282 template<
typename It>
283 typename It::value_type
sumPerfValues(It begin, It end)
const;
292 template<
class RAIterator>
295 commAboveBelow_->partialSumPerfValues(begin, end);
313 void operator()(Parallel::Communication* comm);
324 int rankWithFirstPerf_;
328 std::unique_ptr<Parallel::Communication, DestroyComm> comm_;
331 std::unique_ptr<CommunicateAboveBelow<Scalar>> commAboveBelow_;
333 std::unique_ptr<GlobalPerfContainerFactory<Scalar>> globalPerfCont_;
339template<
class Scalar>
352 bool checkAllConnectionsFound();
355 std::vector<std::size_t> foundConnections_;
360template<
class Scalar>
363template<
class Scalar>
366template<
class Scalar>
369template<
class Scalar>
372template<
class Scalar>
375template<
class Scalar>
378template<
class Scalar>
381template<
class Scalar>
384template<
class Scalar>
Class checking that all connections are on active cells.
Definition ParallelWellInfo.hpp:341
void connectionFound(std::size_t index)
Inidicate that the i-th completion was found.
Definition ParallelWellInfo.cpp:674
Class to facilitate getting values associated with the above/below perforation.
Definition ParallelWellInfo.hpp:40
std::vector< Scalar > communicateBelow(Scalar first_value, const Scalar *current, std::size_t size)
Creates an array of values for the perforation below.
Definition ParallelWellInfo.cpp:371
void clear()
Clear all the parallel information.
Definition ParallelWellInfo.cpp:221
void pushBackEclIndex(int above, int current, bool owner=true)
Adds information about original index of the perforations in ECL Schedule.
Definition ParallelWellInfo.cpp:401
const IndexSet & getIndexSet() const
Get index set for the local perforations.
Definition ParallelWellInfo.cpp:442
int endReset()
Indicates that the index information is complete.
Definition ParallelWellInfo.cpp:246
std::vector< Scalar > communicateAbove(Scalar first_value, const Scalar *current, std::size_t size)
Creates an array of values for the perforation above.
Definition ParallelWellInfo.cpp:341
void beginReset()
Indicates that we will add the index information.
Definition ParallelWellInfo.cpp:233
void partialSumPerfValues(RAIterator begin, RAIterator end) const
Do a (in place) partial sum on values attached to all perforations.
Definition ParallelWellInfo.cpp:267
A factory for creating a global data representation for distributed wells.
Definition ParallelWellInfo.hpp:136
GlobalPerfContainerFactory(const IndexSet &local_indices, const Parallel::Communication comm, int num_local_perfs)
Constructor.
Definition ParallelWellInfo.cpp:72
std::vector< Scalar > createGlobal(const std::vector< Scalar > &local_perf_container, std::size_t num_components) const
Creates a container that holds values for all perforations.
Definition ParallelWellInfo.cpp:124
void copyGlobalToLocal(const std::vector< Scalar > &global, std::vector< Scalar > &local, std::size_t num_components) const
Copies the values of the global perforation to the local representation.
Definition ParallelWellInfo.cpp:175
Class encapsulating some information about parallel wells.
Definition WGState.hpp:31
std::vector< Scalar > communicateBelowValues(Scalar last_value, const Scalar *current, std::size_t size) const
Creates an array of values for the perforation below.
Definition ParallelWellInfo.cpp:573
ParallelWellInfo(const std::string &name={""}, bool hasLocalCells=true)
Constructs object using MPI_COMM_SELF.
Definition ParallelWellInfo.cpp:454
const std::string & name() const
Name of the well.
Definition ParallelWellInfo.hpp:258
T broadcastFirstPerforationValue(const T &t) const
If the well does not have any open connections the member rankWithFirstPerf is not initialized,...
Definition ParallelWellInfo.cpp:534
std::vector< Scalar > communicateAboveValues(Scalar first_value, const Scalar *current, std::size_t size) const
Creates an array of values for the perforation above.
Definition ParallelWellInfo.cpp:554
void beginReset()
Inidicate that we will reset the ecl index information.
Definition ParallelWellInfo.cpp:499
void pushBackEclIndex(int above, int current)
Adds information about the ecl indices of the perforations.
Definition ParallelWellInfo.cpp:493
bool hasLocalCells() const
Whether local cells are perforated somewhen.
Definition ParallelWellInfo.hpp:264
It::value_type sumPerfValues(It begin, It end) const
Sum all the values of the perforations.
Definition ParallelWellInfo.cpp:517
void partialSumPerfValues(RAIterator begin, RAIterator end) const
Do a (in place) partial sum on values attached to all perforations.
Definition ParallelWellInfo.hpp:293
void clear()
Free data of communication data structures.
Definition ParallelWellInfo.cpp:526
const GlobalPerfContainerFactory< Scalar > & getGlobalPerfContainerFactory() const
Get a factor to create a global representation of peforation data.
Definition ParallelWellInfo.cpp:592
void communicateFirstPerforation(bool hasFirst)
Collectively decide which rank has first perforation.
Definition ParallelWellInfo.cpp:481
void endReset()
Inidicate completion of reset of the ecl index information.
Definition ParallelWellInfo.cpp:505
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37