27#ifndef EWOMS_BLACK_LIST_HH
28#define EWOMS_BLACK_LIST_HH
35#include <dune/grid/common/datahandleif.hh>
36#include <dune/grid/common/gridenums.hh>
64 {
return nativeBlackListedIndices_.count(nativeIdx) > 0; }
67 { nativeBlackListedIndices_.insert(nativeIdx); }
71 auto it = nativeToDomesticMap_.find(nativeIdx);
72 if (it == nativeToDomesticMap_.end())
78 { peerBlackLists_[peerRank] = peerBlackList; }
80 template <
class DomesticOverlap>
84 auto peerListIt = peerBlackLists_.begin();
85 const auto& peerListEndIt = peerBlackLists_.end();
86 for (; peerListIt != peerListEndIt; ++peerListIt) {
87 sendGlobalIndices_(peerListIt->first,
92 peerListIt = peerBlackLists_.begin();
93 for (; peerListIt != peerListEndIt; ++peerListIt) {
94 receiveGlobalIndices_(peerListIt->first, domesticOverlap);
97 peerListIt = peerBlackLists_.begin();
98 for (; peerListIt != peerListEndIt; ++peerListIt) {
99 numGlobalIdxSendBuff_.at(peerListIt->first).wait();
100 globalIdxSendBuff_.at(peerListIt->first).wait();
107 std::cout <<
"my own blacklisted indices:\n";
108 auto idxIt = nativeBlackListedIndices_.begin();
109 const auto& idxEndIt = nativeBlackListedIndices_.end();
110 for (; idxIt != idxEndIt; ++idxIt)
111 std::cout <<
" (native index: " << *idxIt
113 std::cout <<
"blacklisted indices of the peers in my own domain:\n";
114 auto peerListIt = peerBlackLists_.begin();
115 const auto& peerListEndIt = peerBlackLists_.end();
116 for (; peerListIt != peerListEndIt; ++peerListIt) {
118 std::cout <<
" peer " << peerRank <<
":\n";
119 auto idx2It = peerListIt->second.begin();
120 const auto& idx2EndIt = peerListIt->second.end();
121 for (; idx2It != idx2EndIt; ++ idx2It)
122 std::cout <<
" (native index: " << idx2It->myOwnNativeIndex
123 <<
", native peer index: " << idx2It->nativeIndexOfPeer <<
")\n";
129 template <
class DomesticOverlap>
132 const DomesticOverlap& domesticOverlap)
134 auto& numIdxBuff = numGlobalIdxSendBuff_[peerRank];
135 auto& idxBuff = globalIdxSendBuff_[peerRank];
137 numIdxBuff.resize(1);
138 numIdxBuff[0] =
static_cast<unsigned>(peerIndices.size());
139 numIdxBuff.send(peerRank);
141 idxBuff.resize(2*peerIndices.size());
142 for (
size_t i = 0; i < peerIndices.size(); ++i) {
144 Index myNativeIdx = peerIndices[i].myOwnNativeIndex;
145 Index myDomesticIdx = domesticOverlap.nativeToDomestic(myNativeIdx);
146 idxBuff[2*i + 0] = domesticOverlap.domesticToGlobal(myDomesticIdx);
149 idxBuff[2*i + 1] = peerIndices[i].nativeIndexOfPeer;
151 idxBuff.send(peerRank);
154 template <
class DomesticOverlap>
156 const DomesticOverlap& domesticOverlap)
158 MpiBuffer<unsigned> numGlobalIdxBuf(1);
159 numGlobalIdxBuf.receive(peerRank);
160 unsigned numIndices = numGlobalIdxBuf[0];
162 MpiBuffer<Index> globalIdxBuf(2*numIndices);
163 globalIdxBuf.receive(peerRank);
164 for (
unsigned i = 0; i < numIndices; ++i) {
165 Index globalIdx = globalIdxBuf[2*i + 0];
166 Index nativeIdx = globalIdxBuf[2*i + 1];
168 nativeToDomesticMap_[nativeIdx] = domesticOverlap.globalToDomestic(globalIdx);
173 std::set<Index> nativeBlackListedIndices_;
174 std::map<Index, Index> nativeToDomesticMap_;
176 std::map<ProcessRank, MpiBuffer<unsigned>> numGlobalIdxSendBuff_;
177 std::map<ProcessRank, MpiBuffer<Index>> globalIdxSendBuff_;
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:49
void addIndex(Index nativeIdx)
Definition: blacklist.hh:66
std::vector< PeerBlackListedEntry > PeerBlackList
Definition: blacklist.hh:55
void setPeerList(ProcessRank peerRank, const PeerBlackList &peerBlackList)
Definition: blacklist.hh:77
bool hasIndex(Index nativeIdx) const
Definition: blacklist.hh:63
BlackList(const BlackList &)=default
void print() const
Definition: blacklist.hh:105
Index nativeToDomestic(Index nativeIdx) const
Definition: blacklist.hh:69
BlackList()
Definition: blacklist.hh:58
std::map< ProcessRank, PeerBlackList > PeerBlackLists
Definition: blacklist.hh:56
void updateNativeToDomesticMap(const DomesticOverlap &domesticOverlap)
Definition: blacklist.hh:81
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:49
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:44
Definition: blackoilboundaryratevector.hh:37
This files provides several data structures for storing tuples of indices of remote and/or local proc...
Definition: blacklist.hh:51
Index myOwnNativeIndex
Definition: blacklist.hh:53
Index nativeIndexOfPeer
Definition: blacklist.hh:52