mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Support broadcasting value of first perforation for distributed well
This needed to e.g. determine bottom hole pressure, pvt region, etc.
This commit is contained in:
parent
317e29d15a
commit
73919d6136
@ -45,7 +45,8 @@ void ParallelWellInfo::DestroyComm::operator()(Communication* comm)
|
||||
ParallelWellInfo::ParallelWellInfo(const std::string& name,
|
||||
bool hasLocalCells)
|
||||
: name_(name), hasLocalCells_ (hasLocalCells),
|
||||
isOwner_(true), comm_(new Communication(Dune::MPIHelper::getLocalCommunicator()))
|
||||
isOwner_(true), rankWithFirstPerf_(-1),
|
||||
comm_(new Communication(Dune::MPIHelper::getLocalCommunicator()))
|
||||
{}
|
||||
|
||||
ParallelWellInfo::ParallelWellInfo(const std::pair<std::string,bool>& well_info,
|
||||
@ -63,6 +64,16 @@ ParallelWellInfo::ParallelWellInfo(const std::pair<std::string,bool>& well_info,
|
||||
isOwner_ = (comm_->rank() == 0);
|
||||
}
|
||||
|
||||
void ParallelWellInfo::communicateFirstPerforation(bool hasFirst)
|
||||
{
|
||||
int first = hasFirst;
|
||||
std::vector<int> firstVec(comm_->size());
|
||||
comm_->allgather(&first, 1, firstVec.data());
|
||||
auto found = std::find_if(firstVec.begin(), firstVec.end(),
|
||||
[](int i) -> bool{ return i;});
|
||||
rankWithFirstPerf_ = found - firstVec.begin();
|
||||
}
|
||||
|
||||
bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2)
|
||||
{
|
||||
return well1.name() < well2.name() || (! (well2.name() < well1.name()) && well1.hasLocalCells() < well2.hasLocalCells());
|
||||
|
@ -61,6 +61,17 @@ public:
|
||||
return *comm_;
|
||||
}
|
||||
|
||||
/// \brief Collectively decide which ran has first perforation.
|
||||
void communicateFirstPerforation(bool hasFirst);
|
||||
|
||||
template<class T>
|
||||
T broadcastFirstPerforationValue(const T& t) const
|
||||
{
|
||||
T res=t;
|
||||
comm_->broadcast(&res, 1, rankWithFirstPerf_);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// \brief Name of the well.
|
||||
const std::string& name() const
|
||||
{
|
||||
@ -92,6 +103,8 @@ private:
|
||||
bool hasLocalCells_;
|
||||
/// \brief Whether we own the well and should do reports etc.
|
||||
bool isOwner_;
|
||||
/// \brief Rank with the first perforation on it.
|
||||
int rankWithFirstPerf_;
|
||||
/// \brief Communication object for the well
|
||||
///
|
||||
/// Contains only ranks where this well will perforate local cells.
|
||||
|
Loading…
Reference in New Issue
Block a user