3 #ifndef DUNE_REMOTEINDICES_HH 4 #define DUNE_REMOTEINDICES_HH 37 template<
typename TG,
typename TA>
42 inline static MPI_Datatype
getType();
44 static MPI_Datatype type;
48 template<
typename T,
typename A>
51 template<
typename T1,
typename T2>
58 template<
typename T1,
typename T2>
59 std::ostream& operator<<(std::ostream& os, const RemoteIndex<T1,T2>& index);
62 template<
typename T,
typename A,
bool mode>
69 template<
typename T1,
typename T2>
75 template<
typename T,
typename A,
typename A1>
80 template<
typename T,
typename A,
bool mode>
109 const Attribute attribute()
const;
116 const PairType& localIndexPair()
const;
151 template<
class T,
class A>
152 std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices);
156 template<
class T,
class A>
164 template<
typename T1,
typename T2>
184 template<
class T,
class A=std::allocator<
RemoteIndex<
typename T::GlobalIndex,
185 typename T::LocalIndex::Attribute> > >
190 template<
typename T1,
typename A2,
typename A1>
195 template<
class G,
class T1,
class T2>
235 typedef typename A::template rebind<RemoteIndex>::other
Allocator;
242 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
264 inline RemoteIndices(
const ParallelIndexSet& source,
const ParallelIndexSet& destination,
265 const MPI_Comm& comm,
const std::vector<int>& neighbours=std::vector<int>(),
bool includeSelf=
false);
276 void setIncludeSelf(
bool includeSelf);
294 void setIndexSets(
const ParallelIndexSet& source,
const ParallelIndexSet& destination,
295 const MPI_Comm& comm,
const std::vector<int>& neighbours=std::vector<int>());
300 neighbourIds.clear();
301 neighbourIds.insert(neighbours.begin(), neighbours.end());
324 template<
bool ignorePublic>
336 inline bool isSynced()
const;
341 inline MPI_Comm communicator()
const;
357 template<
bool mode,
bool send>
366 inline const_iterator find(
int proc)
const;
372 inline const_iterator begin()
const;
378 inline const_iterator end()
const;
384 inline CollectiveIteratorT iterator()
const;
395 inline int neighbours()
const;
398 inline const ParallelIndexSet& sourceIndexSet()
const;
401 inline const ParallelIndexSet& destinationIndexSet()
const;
409 const ParallelIndexSet* source_;
412 const ParallelIndexSet* target_;
419 std::set<int> neighbourIds;
422 const static int commTag_=333;
476 template<
bool ignorePublic>
477 inline void buildRemote(
bool includeSelf);
484 inline int noPublic(
const ParallelIndexSet& indexSet);
497 template<
bool ignorePublic>
498 inline void packEntries(PairType** myPairs,
const ParallelIndexSet& indexSet,
499 char* p_out, MPI_Datatype type,
int bufferSize,
500 int* position,
int n);
516 PairType** local,
int localEntries,
char* p_in,
517 MPI_Datatype type,
int* position,
int bufferSize,
521 int remoteEntries, PairType** localSource,
522 int localSourceEntries, PairType** localDest,
523 int localDestEntries,
char* p_in,
524 MPI_Datatype type,
int* position,
int bufferSize);
526 void unpackCreateRemote(
char* p_in, PairType** sourcePairs, PairType** DestPairs,
527 int remoteProc,
int sourcePublish,
int destPublish,
528 int bufferSize,
bool sendTwo,
bool fromOurSelf=
false);
548 template<
class T,
class A,
bool mode>
552 template<
typename T1,
typename A1>
628 void insert(
const RemoteIndex& index);
645 void insert(
const RemoteIndex& index,
const GlobalIndex& global);
654 bool remove(
const GlobalIndex& global);
692 typedef typename GlobalList::ModifyIterator GlobalModifyIterator;
694 const ParallelIndexSet* indexSet_;
696 ModifyIterator iter_;
697 GlobalModifyIterator giter_;
707 template<
class T,
class A>
714 typedef T ParallelIndexSet;
729 typedef typename LocalIndex::Attribute Attribute;
735 typedef typename A::template rebind<RemoteIndex>::other Allocator;
742 const typename RemoteIndexList::const_iterator> >
748 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
766 inline void advance(
const GlobalIndex& global);
777 inline void advance(
const GlobalIndex& global,
const Attribute& attribute);
800 iterator(
const RealIterator& iter,
const ConstRealIterator& end, GlobalIndex& index)
801 : iter_(iter), end_(end), index_(index), hasAttribute(false)
804 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_)
808 iterator(
const RealIterator& iter,
const ConstRealIterator& end, GlobalIndex index,
810 : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true)
813 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_
814 || iter_->second.first->localIndexPair().local().attribute()!=attribute))
819 : iter_(other.iter_), end_(other.end_), index_(other.index_)
827 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ ||
829 iter_->second.first->localIndexPair().local().attribute()!=attribute_)))
831 assert(iter_==end_ ||
832 (iter_->second.first->localIndexPair().global()==index_));
833 assert(iter_==end_ || !hasAttribute ||
834 (iter_->second.first->localIndexPair().local().attribute()==attribute_));
841 return *(iter_->second.first);
853 return iter_->second.first.operator->();
859 return other.iter_==iter_;
865 return other.iter_!=iter_;
874 Attribute attribute_;
886 Attribute attribute_;
890 template<
typename TG,
typename TA>
893 if(type==MPI_DATATYPE_NULL) {
894 int length[2] = {1, 1};
900 MPI_Get_address(&rep, &base);
901 MPI_Get_address(&(rep.global_), &disp[0]);
902 MPI_Get_address(&(rep.local_), &disp[1]);
903 for (MPI_Aint& d : disp)
907 MPI_Type_create_struct(2, length, disp, types, &tmp);
910 MPI_Type_commit(&type);
917 template<
typename TG,
typename TA>
920 template<
typename T1,
typename T2>
922 : localIndex_(local), attribute_(attribute)
925 template<
typename T1,
typename T2>
927 : localIndex_(0), attribute_(attribute)
930 template<
typename T1,
typename T2>
932 : localIndex_(0), attribute_()
934 template<
typename T1,
typename T2>
937 return localIndex_==ri.localIndex_ && attribute_==ri.
attribute;
940 template<
typename T1,
typename T2>
943 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_;
946 template<
typename T1,
typename T2>
949 return T2(attribute_);
952 template<
typename T1,
typename T2>
958 template<
typename T,
typename A>
960 const ParallelIndexSet& destination,
961 const MPI_Comm& comm,
962 const std::vector<int>& neighbours,
964 : source_(&source), target_(&destination), comm_(comm),
965 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true),
966 includeSelf(includeSelf_)
971 template<
typename T,
typename A>
977 template<
typename T,
typename A>
979 : source_(0), target_(0), sourceSeqNo_(-1),
980 destSeqNo_(-1), publicIgnored(false), firstBuild(true),
984 template<
class T,
typename A>
986 const ParallelIndexSet& destination,
987 const MPI_Comm& comm,
992 target_ = &destination;
998 template<
typename T,
typename A>
1006 template<
typename T,
typename A>
1014 template<
typename T,
typename A>
1020 template<
typename T,
typename A>
1021 template<
bool ignorePublic>
1023 const ParallelIndexSet& indexSet,
1024 char* p_out, MPI_Datatype type,
1026 int *position,
int n)
1032 const const_iterator
end = indexSet.end();
1036 for(const_iterator index = indexSet.begin(); index !=
end; ++index)
1037 if(ignorePublic || index->local().isPublic()) {
1039 MPI_Pack(const_cast<PairType*>(&(*index)), 1,
1041 p_out, bufferSize, position, comm_);
1042 pairs[i++] =
const_cast<PairType*
>(&(*index));
1048 template<
typename T,
typename A>
1055 const const_iterator
end=indexSet.end();
1056 for(const_iterator index=indexSet.begin(); index!=
end; ++index)
1057 if(index->local().isPublic())
1065 template<
typename T,
typename A>
1067 PairType** destPairs,
int remoteProc,
1068 int sourcePublish,
int destPublish,
1069 int bufferSize,
bool sendTwo,
1074 int noRemoteSource=-1, noRemoteDest=-1;
1075 char twoIndexSets=0;
1078 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_);
1080 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_);
1082 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_);
1096 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish,
1097 destPairs, destPublish, p_in, type, &position, bufferSize);
1100 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish,
1101 p_in, type, &position, bufferSize, fromOurSelf);
1106 int oldPos=position;
1108 unpackIndices(*receive, noRemoteSource, destPairs, destPublish,
1109 p_in, type, &position, bufferSize, fromOurSelf);
1115 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish,
1116 p_in, type, &position, bufferSize, fromOurSelf);
1127 remoteIndices_.insert(std::make_pair(remoteProc,
1128 std::make_pair(send,receive)));
1133 template<
typename T,
typename A>
1134 template<
bool ignorePublic>
1139 MPI_Comm_rank(comm_, &rank);
1140 MPI_Comm_size(comm_, &procs);
1144 int sourcePublish, destPublish;
1147 char sendTwo = (source_ != target_);
1149 if(procs==1 && !(sendTwo || includeSelf_))
1153 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_);
1156 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_);
1161 int maxPublish, publish=sourcePublish+destPublish;
1164 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_);
1169 PairType** destPairs;
1170 PairType** sourcePairs =
new PairType*[sourcePublish>0 ? sourcePublish : 1];
1173 destPairs =
new PairType*[destPublish>0 ? destPublish : 1];
1175 destPairs=sourcePairs;
1177 char** buffer =
new char*[2];
1186 MPI_Pack_size(maxPublish, type, comm_,
1188 MPI_Pack_size(1, MPI_INT, comm_,
1190 MPI_Pack_size(1, MPI_CHAR, comm_,
1196 bufferSize += 2 * intSize + charSize;
1198 if(bufferSize<=0) bufferSize=1;
1200 buffer[0] =
new char[bufferSize];
1201 buffer[1] =
new char[bufferSize];
1205 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position,
1209 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1211 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1215 packEntries<ignorePublic>(sourcePairs, *source_, buffer[0], type,
1216 bufferSize, &position, sourcePublish);
1219 packEntries<ignorePublic>(destPairs, *target_, buffer[0], type,
1220 bufferSize, &position, destPublish);
1224 if(sendTwo|| includeSelf_)
1225 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish,
1226 destPublish, bufferSize, sendTwo, includeSelf_);
1228 neighbourIds.erase(rank);
1230 if(neighbourIds.size()==0)
1232 Dune::dvverb<<rank<<
": Sending messages in a ring"<<std::endl;
1234 for(
int proc=1; proc<procs; proc++) {
1236 char* p_out = buffer[1-(proc%2)];
1237 char* p_in = buffer[proc%2];
1241 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1243 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1244 commTag_, comm_, &status);
1246 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1247 commTag_, comm_, &status);
1248 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1254 int remoteProc = (rank+procs-proc)%procs;
1256 unpackCreateRemote(p_in, sourcePairs, destPairs, remoteProc, sourcePublish,
1257 destPublish, bufferSize, sendTwo);
1264 MPI_Request* requests=
new MPI_Request[neighbourIds.size()];
1265 MPI_Request* req=requests;
1267 typedef typename std::set<int>::size_type size_type;
1268 size_type noNeighbours=neighbourIds.size();
1271 for(std::set<int>::iterator neighbour=neighbourIds.begin();
1272 neighbour!= neighbourIds.end(); ++neighbour) {
1274 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++);
1279 for(size_type received=0; received <noNeighbours; ++received)
1283 MPI_Probe(MPI_ANY_SOURCE, commTag_, comm_, &status);
1284 int remoteProc=status.MPI_SOURCE;
1286 MPI_Get_count(&status, MPI_PACKED, &size);
1288 MPI_Recv(buffer[1], size, MPI_PACKED, remoteProc,
1289 commTag_, comm_, &status);
1291 unpackCreateRemote(buffer[1], sourcePairs, destPairs, remoteProc, sourcePublish,
1292 destPublish, bufferSize, sendTwo);
1295 MPI_Status* statuses =
new MPI_Status[neighbourIds.size()];
1297 if(MPI_ERR_IN_STATUS==MPI_Waitall(neighbourIds.size(), requests, statuses)) {
1298 for(size_type i=0; i < neighbourIds.size(); ++i)
1299 if(statuses[i].MPI_ERROR!=MPI_SUCCESS) {
1300 std::cerr<<rank<<
": MPI_Error occurred while receiving message."<<std::endl;
1301 MPI_Abort(comm_, 999);
1310 if(destPairs!=sourcePairs)
1313 delete[] sourcePairs;
1319 template<
typename T,
typename A>
1330 if(remoteEntries==0)
1334 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1336 GlobalIndex oldGlobal=index.
global();
1337 int n_in=0, localIndex=0;
1340 while(localIndex<localEntries) {
1341 if(local[localIndex]->global()==index.
global()) {
1342 int oldLocalIndex=localIndex;
1344 while(localIndex<localEntries &&
1345 local[localIndex]->global()==index.
global()) {
1346 if(!fromOurSelf || index.
local().attribute() !=
1347 local[localIndex]->
local().attribute())
1350 local[localIndex]));
1355 if((++n_in) < remoteEntries) {
1356 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1358 if(index.
global()==oldGlobal)
1360 localIndex=oldLocalIndex;
1362 oldGlobal=index.
global();
1370 if (local[localIndex]->global()<index.
global()) {
1375 if((++n_in) < remoteEntries) {
1376 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1378 oldGlobal=index.
global();
1386 while(++n_in < remoteEntries)
1387 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1392 template<
typename T,
typename A>
1397 int localSourceEntries,
1399 int localDestEntries,
1405 int n_in=0, sourceIndex=0, destIndex=0;
1408 while(n_in<remoteEntries && (sourceIndex<localSourceEntries || destIndex<localDestEntries)) {
1411 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1416 while(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()<index.
global())
1419 while(destIndex<localDestEntries && localDest[destIndex]->global()<index.
global())
1423 if(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()==index.
global())
1425 localSource[sourceIndex]));
1427 if(destIndex < localDestEntries && localDest[destIndex]->global() == index.
global())
1429 localDest[sourceIndex]));
1434 template<
typename T,
typename A>
1437 typedef typename RemoteIndexMap::iterator Iterator;
1438 Iterator lend = remoteIndices_.end();
1439 for(Iterator lists=remoteIndices_.begin(); lists != lend; ++lists) {
1440 if(lists->second.first==lists->second.second) {
1442 delete lists->second.first;
1444 delete lists->second.first;
1445 delete lists->second.second;
1448 remoteIndices_.clear();
1452 template<
typename T,
typename A>
1455 return remoteIndices_.size();
1458 template<
typename T,
typename A>
1459 template<
bool ignorePublic>
1464 ignorePublic!=publicIgnored || !
1468 buildRemote<ignorePublic>(includeSelf);
1470 sourceSeqNo_ = source_->seqNo();
1471 destSeqNo_ = target_->seqNo();
1473 publicIgnored=ignorePublic;
1479 template<
typename T,
typename A>
1482 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo();
1485 template<
typename T,
typename A>
1486 template<
bool mode,
bool send>
1493 sourceSeqNo_ = source_->seqNo();
1494 destSeqNo_ = target_->seqNo();
1496 typename RemoteIndexMap::iterator found = remoteIndices_.find(process);
1498 if(found == remoteIndices_.end())
1500 if(source_ != target_)
1501 found = remoteIndices_.insert(found, std::make_pair(process,
1506 found = remoteIndices_.insert(found,
1507 std::make_pair(process,
1508 std::make_pair(rlist, rlist)));
1520 template<
typename T,
typename A>
1524 return remoteIndices_.find(proc);
1527 template<
typename T,
typename A>
1531 return remoteIndices_.begin();
1534 template<
typename T,
typename A>
1538 return remoteIndices_.end();
1542 template<
typename T,
typename A>
1551 const const_iterator rend = remoteIndices_.end();
1553 for(const_iterator rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) {
1554 if(rindex->first != rindex1->first)
1556 if(*(rindex->second.first) != *(rindex1->second.first))
1558 if(*(rindex->second.second) != *(rindex1->second.second))
1564 template<
class T,
class A,
bool mode>
1567 : rList_(&rList), indexSet_(&indexSet), iter_(rList.
beginModify()), end_(rList.
end()), first_(
true)
1569 if(MODIFYINDEXSET) {
1571 for(ConstIterator iter=iter_; iter != end_; ++iter)
1572 glist_.push_back(iter->localIndexPair().global());
1573 giter_ = glist_.beginModify();
1577 template<
typename T,
typename A,
bool mode>
1579 : rList_(other.rList_), indexSet_(other.indexSet_),
1580 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_),
1581 first_(other.first_), last_(other.last_)
1584 template<
typename T,
typename A,
bool mode>
1589 #ifdef DUNE_ISTL_WITH_CHECKING 1590 if(indexSet_->state()!=
GROUND)
1596 GlobalIterator giter = glist_.
begin();
1597 IndexIterator index = indexSet_->begin();
1599 for(Iterator iter=rList_->
begin(); iter != end_; ++iter) {
1600 while(index->global()<*giter) {
1602 #ifdef DUNE_ISTL_WITH_CHECKING 1603 if(index == indexSet_->end())
1608 #ifdef DUNE_ISTL_WITH_CHECKING 1609 if(index->global() != *giter)
1612 iter->localIndex_ = &(*index);
1617 template<
typename T,
typename A,
bool mode>
1620 static_assert(!mode,
"Not allowed if the mode indicates that new indices" 1621 "might be added to the underlying index set. Use " 1622 "insert(const RemoteIndex&, const GlobalIndex&) instead");
1624 #ifdef DUNE_ISTL_WITH_CHECKING 1640 template<
typename T,
typename A,
bool mode>
1643 static_assert(mode,
"Not allowed if the mode indicates that no new indices" 1644 "might be added to the underlying index set. Use " 1645 "insert(const RemoteIndex&) instead");
1646 #ifdef DUNE_ISTL_WITH_CHECKING 1647 if(!first_ && global<last_)
1651 while(iter_ != end_ && *giter_ < global) {
1659 giter_.insert(global);
1665 template<
typename T,
typename A,
bool mode>
1668 #ifdef DUNE_ISTL_WITH_CHECKING 1669 if(!first_ && global<last_)
1677 while(iter_!=end_ && *giter_< global) {
1681 if(*giter_ == global) {
1701 template<
typename T,
typename A>
1708 template<
typename T,
typename A>
1715 template<
typename T,
typename A>
1718 typedef typename RemoteIndexMap::const_iterator const_iterator;
1720 const const_iterator end=pmap.end();
1721 for(const_iterator process=pmap.begin(); process != end; ++process) {
1722 const RemoteIndexList* list = send ? process->second.first : process->second.second;
1724 map_.insert(std::make_pair(process->first,
1725 std::pair<iterator, const iterator>(list->
begin(), list->
end())));
1729 template<
typename T,
typename A>
1732 typedef typename Map::iterator
iterator;
1733 typedef typename Map::const_iterator const_iterator;
1734 const const_iterator end = map_.end();
1736 for(iterator iter = map_.begin(); iter != end;) {
1740 RemoteIndex remoteIndex;
1742 remoteIndex = *current;
1744 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1745 ++(iter->second.first);
1748 if(iter->second.first == iter->second.second)
1758 template<
typename T,
typename A>
1760 const Attribute& attribute)
1762 typedef typename Map::iterator
iterator;
1763 typedef typename Map::const_iterator const_iterator;
1764 const const_iterator end = map_.end();
1766 for(iterator iter = map_.begin(); iter != end;) {
1770 RemoteIndex remoteIndex;
1772 remoteIndex = *current;
1775 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1776 ++(iter->second.first);
1779 while(iter->second.first!=iter->second.second
1780 && iter->second.first->localIndexPair().global()==index
1781 && iter->second.first->localIndexPair().local().attribute()<attribute)
1782 ++(iter->second.first);
1785 if(iter->second.first == iter->second.second)
1792 attribute_=attribute;
1796 template<
typename T,
typename A>
1799 typedef typename Map::iterator
iterator;
1800 typedef typename Map::const_iterator const_iterator;
1801 const const_iterator end = map_.end();
1803 for(iterator iter = map_.begin(); iter != end;) {
1809 if(iter->second.first->localIndexPair().global()==index_ &&
1810 (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_))
1811 ++(iter->second.first);
1814 if(iter->second.first == iter->second.second)
1823 template<
typename T,
typename A>
1826 return map_.empty();
1829 template<
typename T,
typename A>
1834 return iterator(map_.begin(), map_.end(), index_);
1836 return iterator(map_.begin(), map_.end(), index_,
1840 template<
typename T,
typename A>
1844 return iterator(map_.end(), map_.end(), index_);
1847 template<
typename TG,
typename TA>
1848 inline std::ostream& operator<<(std::ostream& os, const RemoteIndex<TG,TA>& index)
1850 os<<
"[global="<<index.localIndexPair().global()<<
", remote attribute="<<index.attribute()<<
" local attribute="<<index.localIndexPair().local().attribute()<<
"]";
1854 template<
typename T,
typename A>
1855 inline std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices)
1858 MPI_Comm_rank(indices.comm_, &rank);
1861 typedef typename std::map<int,std::pair<RList*,RList*> >::const_iterator const_iterator;
1863 const const_iterator rend = indices.remoteIndices_.
end();
1865 for(const_iterator rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) {
1866 os<<rank<<
": Prozess "<<rindex->first<<
":";
1868 if(!rindex->second.first->empty()) {
1871 const typename RList::const_iterator send= rindex->second.first->
end();
1873 for(
typename RList::const_iterator index = rindex->second.first->begin();
1874 index != send; ++index)
1878 if(!rindex->second.second->empty()) {
1879 os<<rank<<
": Prozess "<<rindex->first<<
": "<<
"receive: ";
1881 for(
const auto& index : *(rindex->second.second))
1884 os<<std::endl<<std::flush;
iterator begin()
Get an iterator pointing to the first element in the list.
Definition: sllist.hh:776
const RemoteIndex & operator*() const
Definition: remoteindices.hh:839
void advance(const GlobalIndex &global)
Advances all underlying iterators.
Definition: remoteindices.hh:1730
const ParallelIndexSet & sourceIndexSet() const
Get the index set at the source.
Definition: remoteindices.hh:1000
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
void free()
Free the index lists.
Definition: remoteindices.hh:1435
const_iterator end() const
Get an iterator over all remote index lists.
Definition: remoteindices.hh:1536
T2 Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition: remoteindices.hh:97
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: remoteindices.hh:584
bool operator!=(const RemoteIndex &ri) const
Definition: remoteindices.hh:941
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: remoteindices.hh:213
CollectiveIterator & operator++()
Definition: remoteindices.hh:1797
void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet)
Repair the pointers to the local indices in the remote indices.
Definition: indicessyncer.hh:490
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition: remoteindices.hh:603
The default mode. Indicates that the index set is ready to be used.
Definition: indexset.hh:185
bool isSynced() const
Checks whether the remote indices are synced with the indexsets.
Definition: remoteindices.hh:1480
bool operator==(const RemoteIndices &ri)
Definition: remoteindices.hh:1543
bool empty()
Checks whether there are still iterators in the map.
Definition: remoteindices.hh:1824
RemoteIndices()
Definition: remoteindices.hh:978
bool empty() const
Check whether the list is empty.
Definition: sllist.hh:764
int neighbours() const
Get the number of processors we share indices with.
Definition: remoteindices.hh:1453
void setIndexSets(const ParallelIndexSet &source, const ParallelIndexSet &destination, const MPI_Comm &comm, const std::vector< int > &neighbours=std::vector< int >())
Set the index sets and communicator we work with.
Definition: remoteindices.hh:985
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition: stdstreams.hh:93
An index present on the local process with an additional attribute flag.
Definition: plocalindex.hh:27
void setNeighbours(const C &neighbours)
Definition: remoteindices.hh:298
const ParallelIndexSet & destinationIndexSet() const
Get the index set at destination.
Definition: remoteindices.hh:1008
Map::iterator RealIterator
Definition: remoteindices.hh:795
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: remoteindices.hh:579
const std::set< int > & getNeighbours() const
Definition: remoteindices.hh:305
static MPI_Datatype getType()
Definition: mpitraits.hh:45
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: indexset.hh:225
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex index, Attribute attribute)
Definition: remoteindices.hh:808
Provides classes for use as the local index in ParallelIndexSet for distributed computing.
Information about an index residing on another processor.
Definition: remoteindices.hh:52
A pair consisting of a global and local index.
Definition: indexset.hh:30
SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator
The type of the modifying iterator of the remote index list.
Definition: remoteindices.hh:608
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:233
LocalIndex & local()
Get the local index.
A Allocator
The type of the allocator for the remote index list.
Definition: remoteindices.hh:599
void repairLocalIndexPointers()
Repair the pointers to the local index pairs.
Definition: remoteindices.hh:1585
Traits classes for mapping types onto MPI_Datatype.
CollectiveIterator(const RemoteIndexMap &map_, bool send)
Constructor.
Definition: remoteindices.hh:1716
T ParallelIndexSet
Type of the index set we use, e.g. ParallelLocalIndexSet.
Definition: remoteindices.hh:204
const_iterator find(int proc) const
Find an iterator over the remote index lists of a specific process.
Definition: remoteindices.hh:1522
void remove()
Delete the entry at the current position.
Definition: sllist.hh:524
Iterator over the valid underlying iterators.
Definition: remoteindices.hh:792
const_iterator begin() const
Get an iterator over all remote index lists.
Definition: remoteindices.hh:1529
bool remove(const GlobalIndex &global)
Remove a remote index.
Definition: remoteindices.hh:1666
RemoteIndexList::const_iterator ConstIterator
The type of the remote index list iterator.
Definition: remoteindices.hh:613
A collective iterator for moving over the remote indices for all processes collectively.
Definition: remoteindices.hh:157
Implements a singly linked list together with the necessary iterators.
const Attribute attribute() const
Get the attribute of the index on the remote process.
Definition: remoteindices.hh:947
void insert(const T &v)
Insert an element at the current position.
Definition: sllist.hh:511
RemoteIndexListModifier< T, A, mode > getModifier(int process)
Get a modifier for a remote index list.
Definition: remoteindices.hh:1487
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition: indexset.hh:238
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:594
iterator(const iterator &other)
Definition: remoteindices.hh:818
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:255
RemoteIndexMap::const_iterator const_iterator
Definition: remoteindices.hh:245
bool operator!=(const iterator &other)
Definition: remoteindices.hh:863
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition: sllist.hh:657
A few common exception classes.
const RemoteIndex * operator->() const
Definition: remoteindices.hh:851
MPI_Comm communicator() const
Get the mpi communicator used.
Definition: remoteindices.hh:1709
Dune namespace.
Definition: alignedallocator.hh:9
If true the index set corresponding to the remote indices might get modified.
Definition: remoteindices.hh:568
RemoteIndexListModifier()
Default constructor.
Definition: remoteindices.hh:677
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition: remoteindices.hh:749
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition: sllist.hh:801
The indices present on remote processes.
Definition: remoteindices.hh:49
const GlobalIndex & global() const
Get the global index.
A constant iterator for the SLList.
Definition: sllist.hh:28
IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType
The type of the index pair.
Definition: remoteindices.hh:103
iterator end()
Get an iterator pointing to the end of the list.
Definition: sllist.hh:788
Standard Dune debug streams.
void rebuild()
Rebuilds the set of remote indices.
Definition: remoteindices.hh:1460
A constant random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:20
Definition: remoteindices.hh:556
Class for recomputing missing indices of a distributed index set.
Definition: indicessyncer.hh:39
bool operator==(const RemoteIndex &ri) const
Definition: remoteindices.hh:935
Modifier for adding and/or deleting remote indices from the remote index list.
Definition: remoteindices.hh:63
A::template rebind< RemoteIndex >::other Allocator
The type of the allocator for the remote index list.
Definition: remoteindices.hh:235
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition: remoteindices.hh:239
void insert(const RemoteIndex &index)
Insert an index to the list.
Definition: remoteindices.hh:1618
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex &index)
Definition: remoteindices.hh:800
Exception indicating that the index set is not in the expected state.
Definition: indexset.hh:204
A single linked list.
Definition: sllist.hh:41
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: remoteindices.hh:589
void setIncludeSelf(bool includeSelf)
Tell whether sending from indices of the processor to other indices on the same processor is enabled ...
Definition: remoteindices.hh:972
bool operator==(const iterator &other)
Definition: remoteindices.hh:857
A traits class describing the mapping of types onto MPI_Datatypes.
Definition: bigunsignedint.hh:25
~RemoteIndices()
Destructor.
Definition: remoteindices.hh:1015
Default exception class for range errors.
Definition: exceptions.hh:252
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: remoteindices.hh:219
Definition: remoteindices.hh:165
iterator & operator++()
Definition: remoteindices.hh:823
iterator end()
Definition: remoteindices.hh:1842
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: remoteindices.hh:224
Base class of all classes representing a communication interface.
Definition: interface.hh:32
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
T ParallelIndexSet
Type of the index set we use.
Definition: remoteindices.hh:574
int process() const
Definition: remoteindices.hh:845
iterator begin()
Definition: remoteindices.hh:1831
CollectiveIteratorT iterator() const
Get an iterator for colletively iterating over the remote indices of all remote processes.
Definition: remoteindices.hh:1703
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition: remoteindices.hh:243
CollectiveIterator< T, A > CollectiveIteratorT
The type of the collective iterator over all remote indices.
Definition: remoteindices.hh:208
Provides a map between global and local indices.
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:229
T1 GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: remoteindices.hh:88
RemoteIndex()
Parameterless Constructor.
Definition: remoteindices.hh:931
Map::iterator ConstRealIterator
Definition: remoteindices.hh:796
const PairType & localIndexPair() const
Get the corresponding local index pair.
Definition: remoteindices.hh:953