25 #ifndef EWOMS_BLACK_LIST_HH
26 #define EWOMS_BLACK_LIST_HH
33 #include <dune/grid/common/datahandleif.hh>
34 #include <dune/grid/common/gridenums.hh>
61 {
return nativeBlackListedIndices_.count(nativeIdx) > 0; }
64 { nativeBlackListedIndices_.insert(nativeIdx); }
68 auto it = nativeToDomesticMap_.find(nativeIdx);
69 if (it == nativeToDomesticMap_.end())
75 { peerBlackLists_[peerRank] = peerBlackList; }
77 template <
class DomesticOverlap>
81 auto peerListIt = peerBlackLists_.begin();
82 const auto& peerListEndIt = peerBlackLists_.end();
83 for (; peerListIt != peerListEndIt; ++peerListIt) {
84 sendGlobalIndices_(peerListIt->first,
89 peerListIt = peerBlackLists_.begin();
90 for (; peerListIt != peerListEndIt; ++peerListIt) {
91 receiveGlobalIndices_(peerListIt->first, domesticOverlap);
94 peerListIt = peerBlackLists_.begin();
95 for (; peerListIt != peerListEndIt; ++peerListIt) {
96 numGlobalIdxSendBuff_.at(peerListIt->first).wait();
97 globalIdxSendBuff_.at(peerListIt->first).wait();
104 std::cout <<
"my own blacklisted indices:\n";
105 auto idxIt = nativeBlackListedIndices_.begin();
106 const auto &idxEndIt = nativeBlackListedIndices_.end();
107 for (; idxIt != idxEndIt; ++idxIt)
108 std::cout <<
" (native index: " << *idxIt
110 std::cout <<
"blacklisted indices of the peers in my own domain:\n";
111 auto peerListIt = peerBlackLists_.begin();
112 const auto& peerListEndIt = peerBlackLists_.end();
113 for (; peerListIt != peerListEndIt; ++peerListIt) {
114 int peerRank = peerListIt->first;
115 std::cout <<
" peer " << peerRank <<
":\n";
116 auto idxIt = peerListIt->second.begin();
117 const auto& idxEndIt = peerListIt->second.end();
118 for (; idxIt != idxEndIt; ++ idxIt)
119 std::cout <<
" (native index: " << idxIt->myOwnNativeIndex
120 <<
", native peer index: " << idxIt->nativeIndexOfPeer <<
")\n";
126 template <
class DomesticOverlap>
128 const PeerBlackList& peerIndices,
129 const DomesticOverlap& domesticOverlap)
131 auto& numIdxBuff = numGlobalIdxSendBuff_[peerRank];
132 auto& idxBuff = globalIdxSendBuff_[peerRank];
134 numIdxBuff.resize(1);
135 numIdxBuff[0] = peerIndices.size();
136 numIdxBuff.send(peerRank);
138 idxBuff.resize(2*peerIndices.size());
139 for (
size_t i = 0; i < peerIndices.size(); ++i) {
141 Index myNativeIdx = peerIndices[i].myOwnNativeIndex;
142 Index myDomesticIdx = domesticOverlap.nativeToDomestic(myNativeIdx);
143 idxBuff[2*i + 0] = domesticOverlap.domesticToGlobal(myDomesticIdx);
146 idxBuff[2*i + 1] = peerIndices[i].nativeIndexOfPeer;
148 idxBuff.send(peerRank);
151 template <
class DomesticOverlap>
153 const DomesticOverlap& domesticOverlap)
155 MpiBuffer<int> numGlobalIdxBuf(1);
156 numGlobalIdxBuf.receive(peerRank);
157 int numIndices = numGlobalIdxBuf[0];
159 MpiBuffer<Index> globalIdxBuf(2*numIndices);
160 globalIdxBuf.receive(peerRank);
161 for (
int i = 0; i < numIndices; ++i) {
162 Index globalIdx = globalIdxBuf[2*i + 0];
163 Index nativeIdx = globalIdxBuf[2*i + 1];
165 nativeToDomesticMap_[nativeIdx] = domesticOverlap.globalToDomestic(globalIdx);
170 std::set<Index> nativeBlackListedIndices_;
171 std::map<Index, Index> nativeToDomesticMap_;
173 std::map<ProcessRank, MpiBuffer<int>> numGlobalIdxSendBuff_;
174 std::map<ProcessRank, MpiBuffer<Index>> globalIdxSendBuff_;
177 PeerBlackLists peerBlackLists_;
Index nativeIndexOfPeer
Definition: blacklist.hh:49
void setPeerList(ProcessRank peerRank, const PeerBlackList &peerBlackList)
Definition: blacklist.hh:74
bool hasIndex(Index nativeIdx) const
Definition: blacklist.hh:60
This files provides several data structures for storing tuples of indices of remote and/or local proc...
std::vector< PeerBlackListedEntry > PeerBlackList
Definition: blacklist.hh:52
void print() const
Definition: blacklist.hh:102
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:45
Simplifies handling of buffers to be used in conjunction with MPI.
Definition: baseauxiliarymodule.hh:35
BlackList()
Definition: blacklist.hh:55
void updateNativeToDomesticMap(const DomesticOverlap &domesticOverlap)
Definition: blacklist.hh:78
Definition: blacklist.hh:48
Index nativeToDomestic(Index nativeIdx) const
Definition: blacklist.hh:66
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:43
std::map< ProcessRank, PeerBlackList > PeerBlackLists
Definition: blacklist.hh:53
void addIndex(Index nativeIdx)
Definition: blacklist.hh:63
Index myOwnNativeIndex
Definition: blacklist.hh:50
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:48