3 #ifndef DUNE_REMOTEINDICES_HH 4 #define DUNE_REMOTEINDICES_HH 33 template<
typename TG,
typename TA>
38 inline static MPI_Datatype
getType();
40 static MPI_Datatype type;
44 template<
typename T,
typename A>
47 template<
typename T1,
typename T2>
53 template<
typename T1,
typename T2>
54 std::ostream& operator<<(std::ostream& os, const RemoteIndex<T1,T2>& index);
57 template<
typename T,
typename A,
bool mode>
64 template<
typename T1,
typename T2>
70 template<
typename T,
typename A,
typename A1>
75 template<
typename T,
typename A,
bool mode>
104 const Attribute attribute()
const;
111 const PairType& localIndexPair()
const;
146 template<
class T,
class A>
147 std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices);
151 template<
class T,
class A>
158 template<
typename T1,
typename T2>
178 template<
class T,
class A=std::allocator<
RemoteIndex<
typename T::GlobalIndex,
179 typename T::LocalIndex::Attribute> > >
184 template<
typename T1,
typename A2,
typename A1>
189 template<
class G,
class T1,
class T2>
229 typedef typename A::template rebind<RemoteIndex>::other
Allocator;
236 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
258 inline RemoteIndices(
const ParallelIndexSet& source,
const ParallelIndexSet& destination,
259 const MPI_Comm& comm,
const std::vector<int>& neighbours=std::vector<int>(),
bool includeSelf=
false);
270 void setIncludeSelf(
bool includeSelf);
288 void setIndexSets(
const ParallelIndexSet& source,
const ParallelIndexSet& destination,
289 const MPI_Comm& comm,
const std::vector<int>& neighbours=std::vector<int>());
294 neighbourIds.clear();
295 neighbourIds.insert(neighbours.begin(), neighbours.end());
318 template<
bool ignorePublic>
330 inline bool isSynced()
const;
335 inline MPI_Comm communicator()
const;
351 template<
bool mode,
bool send>
360 inline const_iterator find(
int proc)
const;
366 inline const_iterator begin()
const;
372 inline const_iterator end()
const;
378 inline CollectiveIteratorT iterator()
const;
389 inline int neighbours()
const;
392 inline const ParallelIndexSet& sourceIndexSet()
const;
395 inline const ParallelIndexSet& destinationIndexSet()
const;
403 const ParallelIndexSet* source_;
406 const ParallelIndexSet* target_;
413 std::set<int> neighbourIds;
416 const static int commTag_=333;
470 template<
bool ignorePublic>
471 inline void buildRemote(
bool includeSelf);
478 inline int noPublic(
const ParallelIndexSet& indexSet);
491 template<
bool ignorePublic>
492 inline void packEntries(PairType** myPairs,
const ParallelIndexSet& indexSet,
493 char* p_out, MPI_Datatype type,
int bufferSize,
494 int* position,
int n);
510 PairType** local,
int localEntries,
char* p_in,
511 MPI_Datatype type,
int* positon,
int bufferSize,
515 int remoteEntries, PairType** localSource,
516 int localSourceEntries, PairType** localDest,
517 int localDestEntries,
char* p_in,
518 MPI_Datatype type,
int* position,
int bufferSize);
520 void unpackCreateRemote(
char* p_in, PairType** sourcePairs, PairType** DestPairs,
521 int remoteProc,
int sourcePublish,
int destPublish,
522 int bufferSize,
bool sendTwo,
bool fromOurSelf=
false);
542 template<
class T,
class A,
bool mode>
546 template<
typename T1,
typename A1>
639 void insert(
const RemoteIndex& index,
const GlobalIndex& global)
throw(
InvalidPosition);
671 RemoteIndexListModifier()
686 typedef typename GlobalList::ModifyIterator GlobalModifyIterator;
688 const ParallelIndexSet* indexSet_;
690 ModifyIterator iter_;
691 GlobalModifyIterator giter_;
701 template<
class T,
class A>
708 typedef T ParallelIndexSet;
723 typedef typename LocalIndex::Attribute Attribute;
729 typedef typename A::template rebind<RemoteIndex>::other Allocator;
736 const typename RemoteIndexList::const_iterator> >
742 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
760 inline void advance(
const GlobalIndex& global);
771 inline void advance(
const GlobalIndex& global,
const Attribute& attribute);
794 iterator(
const RealIterator& iter,
const ConstRealIterator& end, GlobalIndex& index)
795 : iter_(iter), end_(end), index_(index), hasAttribute(false)
798 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_)
802 iterator(
const RealIterator& iter,
const ConstRealIterator& end, GlobalIndex index,
804 : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true)
807 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_
808 || iter_->second.first->localIndexPair().local().attribute()!=attribute))
813 : iter_(other.iter_), end_(other.end_), index_(other.index_)
821 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ ||
823 iter_->second.first->localIndexPair().local().attribute()!=attribute_)))
825 assert(iter_==end_ ||
826 (iter_->second.first->localIndexPair().global()==index_));
827 assert(iter_==end_ || !hasAttribute ||
828 (iter_->second.first->localIndexPair().local().attribute()==attribute_));
835 return *(iter_->second.first);
847 return iter_->second.first.operator->();
853 return other.iter_==iter_;
859 return other.iter_!=iter_;
868 Attribute attribute_;
880 Attribute attribute_;
884 template<
typename TG,
typename TA>
887 if(type==MPI_DATATYPE_NULL) {
893 length[0]=length[1]=length[2]=length[3]=1;
894 MPI_Get_address(rep, disp);
895 MPI_Get_address(&(rep[0].global_), disp+1);
896 MPI_Get_address(&(rep[0].local_), disp+2);
897 MPI_Get_address(rep+1, disp+3);
898 for(
int i=3; i >= 0; --i)
900 MPI_Type_create_struct(4, length, disp, types, &type);
901 MPI_Type_commit(&type);
906 template<
typename TG,
typename TA>
909 template<
typename T1,
typename T2>
911 : localIndex_(local), attribute_(attribute)
914 template<
typename T1,
typename T2>
916 : localIndex_(0), attribute_(attribute)
919 template<
typename T1,
typename T2>
921 : localIndex_(0), attribute_()
923 template<
typename T1,
typename T2>
926 return localIndex_==ri.localIndex_ && attribute_==ri.
attribute;
929 template<
typename T1,
typename T2>
932 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_;
935 template<
typename T1,
typename T2>
938 return T2(attribute_);
941 template<
typename T1,
typename T2>
947 template<
typename T,
typename A>
949 const ParallelIndexSet& destination,
950 const MPI_Comm& comm,
951 const std::vector<int>& neighbours,
953 : source_(&source), target_(&destination), comm_(comm),
954 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true),
955 includeSelf(includeSelf_)
960 template<
typename T,
typename A>
966 template<
typename T,
typename A>
968 : source_(0), target_(0), sourceSeqNo_(-1),
969 destSeqNo_(-1), publicIgnored(false), firstBuild(true)
972 template<
class T,
typename A>
974 const ParallelIndexSet& destination,
975 const MPI_Comm& comm,
980 target_ = &destination;
986 template<
typename T,
typename A>
994 template<
typename T,
typename A>
1002 template<
typename T,
typename A>
1008 template<
typename T,
typename A>
1009 template<
bool ignorePublic>
1011 const ParallelIndexSet& indexSet,
1012 char* p_out, MPI_Datatype type,
1014 int *position,
int n)
1020 const const_iterator
end = indexSet.end();
1024 for(const_iterator index = indexSet.begin(); index !=
end; ++index)
1025 if(ignorePublic || index->local().isPublic()) {
1027 MPI_Pack(const_cast<PairType*>(&(*index)), 1,
1029 p_out, bufferSize, position, comm_);
1030 pairs[i++] =
const_cast<PairType*
>(&(*index));
1036 template<
typename T,
typename A>
1043 const const_iterator
end=indexSet.end();
1044 for(const_iterator index=indexSet.begin(); index!=
end; ++index)
1045 if(index->local().isPublic())
1053 template<
typename T,
typename A>
1055 PairType** destPairs,
int remoteProc,
1056 int sourcePublish,
int destPublish,
1057 int bufferSize,
bool sendTwo,
1062 int noRemoteSource=-1, noRemoteDest=-1;
1063 char twoIndexSets=0;
1066 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_);
1068 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_);
1070 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_);
1084 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish,
1085 destPairs, destPublish, p_in, type, &position, bufferSize);
1088 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish,
1089 p_in, type, &position, bufferSize, fromOurSelf);
1094 int oldPos=position;
1096 unpackIndices(*receive, noRemoteSource, destPairs, destPublish,
1097 p_in, type, &position, bufferSize, fromOurSelf);
1103 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish,
1104 p_in, type, &position, bufferSize, fromOurSelf);
1115 remoteIndices_.insert(std::make_pair(remoteProc,
1116 std::make_pair(send,receive)));
1121 template<
typename T,
typename A>
1122 template<
bool ignorePublic>
1127 MPI_Comm_rank(comm_, &rank);
1128 MPI_Comm_size(comm_, &procs);
1132 int sourcePublish, destPublish;
1135 char sendTwo = (source_ != target_);
1137 if(procs==1 && !(sendTwo || includeSelf_))
1141 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_);
1144 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_);
1149 int maxPublish, publish=sourcePublish+destPublish;
1152 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_);
1157 PairType** destPairs;
1158 PairType** sourcePairs =
new PairType*[sourcePublish>0 ? sourcePublish : 1];
1161 destPairs =
new PairType*[destPublish>0 ? destPublish : 1];
1163 destPairs=sourcePairs;
1165 char** buffer =
new char*[2];
1174 MPI_Pack_size(maxPublish, type, comm_,
1176 MPI_Pack_size(1, MPI_INT, comm_,
1178 MPI_Pack_size(1, MPI_CHAR, comm_,
1184 bufferSize += 2 * intSize + charSize;
1186 if(bufferSize<=0) bufferSize=1;
1188 buffer[0] =
new char[bufferSize];
1189 buffer[1] =
new char[bufferSize];
1193 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position,
1197 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1199 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1203 packEntries<ignorePublic>(sourcePairs, *source_, buffer[0], type,
1204 bufferSize, &position, sourcePublish);
1207 packEntries<ignorePublic>(destPairs, *target_, buffer[0], type,
1208 bufferSize, &position, destPublish);
1212 if(sendTwo|| includeSelf_)
1213 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish,
1214 destPublish, bufferSize, sendTwo, includeSelf_);
1216 neighbourIds.erase(rank);
1218 if(neighbourIds.size()==0)
1220 Dune::dvverb<<rank<<
": Sending messages in a ring"<<std::endl;
1222 for(
int proc=1; proc<procs; proc++) {
1224 char* p_out = buffer[1-(proc%2)];
1225 char* p_in = buffer[proc%2];
1229 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1231 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1232 commTag_, comm_, &status);
1234 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1235 commTag_, comm_, &status);
1236 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1242 int remoteProc = (rank+procs-proc)%procs;
1244 unpackCreateRemote(p_in, sourcePairs, destPairs, remoteProc, sourcePublish,
1245 destPublish, bufferSize, sendTwo);
1252 MPI_Request* requests=
new MPI_Request[neighbourIds.size()];
1253 MPI_Request* req=requests;
1255 typedef typename std::set<int>::size_type size_type;
1256 size_type noNeighbours=neighbourIds.size();
1259 for(std::set<int>::iterator neighbour=neighbourIds.begin();
1260 neighbour!= neighbourIds.end(); ++neighbour) {
1262 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++);
1267 for(size_type received=0; received <noNeighbours; ++received)
1271 MPI_Probe(MPI_ANY_SOURCE, commTag_, comm_, &status);
1272 int remoteProc=status.MPI_SOURCE;
1274 MPI_Get_count(&status, MPI_PACKED, &size);
1276 MPI_Recv(buffer[1], size, MPI_PACKED, remoteProc,
1277 commTag_, comm_, &status);
1279 unpackCreateRemote(buffer[1], sourcePairs, destPairs, remoteProc, sourcePublish,
1280 destPublish, bufferSize, sendTwo);
1283 MPI_Status* statuses =
new MPI_Status[neighbourIds.size()];
1285 if(MPI_ERR_IN_STATUS==MPI_Waitall(neighbourIds.size(), requests, statuses)) {
1286 for(size_type i=0; i < neighbourIds.size(); ++i)
1287 if(statuses[i].MPI_ERROR!=MPI_SUCCESS) {
1288 std::cerr<<rank<<
": MPI_Error occurred while receiving message."<<std::endl;
1289 MPI_Abort(comm_, 999);
1298 if(destPairs!=sourcePairs)
1301 delete[] sourcePairs;
1307 template<
typename T,
typename A>
1318 if(remoteEntries==0)
1322 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1324 GlobalIndex oldGlobal=index.
global();
1325 int n_in=0, localIndex=0;
1328 while(localIndex<localEntries) {
1329 if(local[localIndex]->global()==index.
global()) {
1330 int oldLocalIndex=localIndex;
1332 while(localIndex<localEntries &&
1333 local[localIndex]->global()==index.
global()) {
1334 if(!fromOurSelf || index.
local().attribute() !=
1335 local[localIndex]->
local().attribute())
1338 local[localIndex]));
1343 if((++n_in) < remoteEntries) {
1344 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1346 if(index.
global()==oldGlobal)
1348 localIndex=oldLocalIndex;
1350 oldGlobal=index.
global();
1358 if (local[localIndex]->global()<index.
global()) {
1363 if((++n_in) < remoteEntries) {
1364 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1366 oldGlobal=index.
global();
1374 while(++n_in < remoteEntries)
1375 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1380 template<
typename T,
typename A>
1385 int localSourceEntries,
1387 int localDestEntries,
1393 int n_in=0, sourceIndex=0, destIndex=0;
1396 while(n_in<remoteEntries && (sourceIndex<localSourceEntries || destIndex<localDestEntries)) {
1399 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1404 while(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()<index.
global())
1407 while(destIndex<localDestEntries && localDest[destIndex]->global()<index.
global())
1411 if(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()==index.
global())
1413 localSource[sourceIndex]));
1415 if(destIndex < localDestEntries && localDest[destIndex]->global() == index.
global())
1417 localDest[sourceIndex]));
1422 template<
typename T,
typename A>
1425 typedef typename RemoteIndexMap::iterator Iterator;
1426 Iterator lend = remoteIndices_.end();
1427 for(Iterator lists=remoteIndices_.begin(); lists != lend; ++lists) {
1428 if(lists->second.first==lists->second.second) {
1430 delete lists->second.first;
1432 delete lists->second.first;
1433 delete lists->second.second;
1436 remoteIndices_.clear();
1440 template<
typename T,
typename A>
1443 return remoteIndices_.size();
1446 template<
typename T,
typename A>
1447 template<
bool ignorePublic>
1452 ignorePublic!=publicIgnored || !
1456 buildRemote<ignorePublic>(includeSelf);
1458 sourceSeqNo_ = source_->seqNo();
1459 destSeqNo_ = target_->seqNo();
1461 publicIgnored=ignorePublic;
1467 template<
typename T,
typename A>
1470 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo();
1473 template<
typename T,
typename A>
1474 template<
bool mode,
bool send>
1481 sourceSeqNo_ = source_->seqNo();
1482 destSeqNo_ = target_->seqNo();
1484 typename RemoteIndexMap::iterator found = remoteIndices_.find(process);
1486 if(found == remoteIndices_.end())
1488 if(source_ != target_)
1489 found = remoteIndices_.insert(found, std::make_pair(process,
1494 found = remoteIndices_.insert(found,
1495 std::make_pair(process,
1496 std::make_pair(rlist, rlist)));
1508 template<
typename T,
typename A>
1512 return remoteIndices_.find(proc);
1515 template<
typename T,
typename A>
1519 return remoteIndices_.begin();
1522 template<
typename T,
typename A>
1526 return remoteIndices_.end();
1530 template<
typename T,
typename A>
1539 const const_iterator rend = remoteIndices_.end();
1541 for(const_iterator rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) {
1542 if(rindex->first != rindex1->first)
1544 if(*(rindex->second.first) != *(rindex1->second.first))
1546 if(*(rindex->second.second) != *(rindex1->second.second))
1552 template<
class T,
class A,
bool mode>
1555 : rList_(&rList), indexSet_(&indexSet), iter_(rList.
beginModify()), end_(rList.
end()), first_(
true)
1557 if(MODIFYINDEXSET) {
1559 for(ConstIterator iter=iter_; iter != end_; ++iter)
1560 glist_.push_back(iter->localIndexPair().global());
1561 giter_ = glist_.beginModify();
1565 template<
typename T,
typename A,
bool mode>
1567 : rList_(other.rList_), indexSet_(other.indexSet_),
1568 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_),
1569 first_(other.first_), last_(other.last_)
1572 template<
typename T,
typename A,
bool mode>
1577 #ifdef DUNE_ISTL_WITH_CHECKING 1578 if(indexSet_->state()!=
GROUND)
1579 DUNE_THROW(InvalidIndexSetState,
"Index has to be in ground mode for repairing pointers to indices");
1584 GlobalIterator giter = glist_.
begin();
1585 IndexIterator index = indexSet_->begin();
1587 for(Iterator iter=rList_->
begin(); iter != end_; ++iter) {
1588 while(index->global()<*giter) {
1590 #ifdef DUNE_ISTL_WITH_CHECKING 1591 if(index == indexSet_->end())
1596 #ifdef DUNE_ISTL_WITH_CHECKING 1597 if(index->global() != *giter)
1600 iter->localIndex_ = &(*index);
1605 template<
typename T,
typename A,
bool mode>
1608 static_assert(!mode,
"Not allowed if the mode indicates that new indices" 1609 "might be added to the underlying index set. Use " 1610 "insert(const RemoteIndex&, const GlobalIndex&) instead");
1612 #ifdef DUNE_ISTL_WITH_CHECKING 1613 if(!first_ && index.localIndexPair().global()<last_)
1624 last_ = index.localIndexPair().global();
1628 template<
typename T,
typename A,
bool mode>
1631 static_assert(mode,
"Not allowed if the mode indicates that no new indices" 1632 "might be added to the underlying index set. Use " 1633 "insert(const RemoteIndex&) instead");
1634 #ifdef DUNE_ISTL_WITH_CHECKING 1635 if(!first_ && global<last_)
1639 while(iter_ != end_ && *giter_ < global) {
1647 giter_.insert(global);
1653 template<
typename T,
typename A,
bool mode>
1656 #ifdef DUNE_ISTL_WITH_CHECKING 1657 if(!first_ && global<last_)
1665 while(iter_!=end_ && *giter_< global) {
1669 if(*giter_ == global) {
1689 template<
typename T,
typename A>
1696 template<
typename T,
typename A>
1703 template<
typename T,
typename A>
1706 typedef typename RemoteIndexMap::const_iterator const_iterator;
1708 const const_iterator end=pmap.end();
1709 for(const_iterator process=pmap.begin(); process != end; ++process) {
1710 const RemoteIndexList* list = send ? process->second.first : process->second.second;
1712 map_.insert(std::make_pair(process->first,
1713 std::pair<iterator, const iterator>(list->
begin(), list->
end())));
1717 template<
typename T,
typename A>
1720 typedef typename Map::iterator
iterator;
1721 typedef typename Map::const_iterator const_iterator;
1722 const const_iterator end = map_.end();
1724 for(iterator iter = map_.begin(); iter != end;) {
1728 RemoteIndex remoteIndex;
1730 remoteIndex = *current;
1732 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1733 ++(iter->second.first);
1736 if(iter->second.first == iter->second.second)
1746 template<
typename T,
typename A>
1748 const Attribute& attribute)
1750 typedef typename Map::iterator
iterator;
1751 typedef typename Map::const_iterator const_iterator;
1752 const const_iterator end = map_.end();
1754 for(iterator iter = map_.begin(); iter != end;) {
1758 RemoteIndex remoteIndex;
1760 remoteIndex = *current;
1763 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1764 ++(iter->second.first);
1767 while(iter->second.first!=iter->second.second
1768 && iter->second.first->localIndexPair().global()==index
1769 && iter->second.first->localIndexPair().local().attribute()<attribute)
1770 ++(iter->second.first);
1773 if(iter->second.first == iter->second.second)
1780 attribute_=attribute;
1784 template<
typename T,
typename A>
1787 typedef typename Map::iterator
iterator;
1788 typedef typename Map::const_iterator const_iterator;
1789 const const_iterator end = map_.end();
1791 for(iterator iter = map_.begin(); iter != end;) {
1797 if(iter->second.first->localIndexPair().global()==index_ &&
1798 (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_))
1799 ++(iter->second.first);
1802 if(iter->second.first == iter->second.second)
1811 template<
typename T,
typename A>
1814 return map_.empty();
1817 template<
typename T,
typename A>
1822 return iterator(map_.begin(), map_.end(), index_);
1824 return iterator(map_.begin(), map_.end(), index_,
1828 template<
typename T,
typename A>
1832 return iterator(map_.end(), map_.end(), index_);
1835 template<
typename TG,
typename TA>
1836 inline std::ostream& operator<<(std::ostream& os, const RemoteIndex<TG,TA>& index)
1838 os<<
"[global="<<index.localIndexPair().global()<<
", remote attribute="<<index.attribute()<<
" local attribute="<<index.localIndexPair().local().attribute()<<
"]";
1842 template<
typename T,
typename A>
1843 inline std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices)
1846 MPI_Comm_rank(indices.comm_, &rank);
1849 typedef typename std::map<int,std::pair<RList*,RList*> >::const_iterator const_iterator;
1851 const const_iterator rend = indices.remoteIndices_.
end();
1853 for(const_iterator rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) {
1854 os<<rank<<
": Prozess "<<rindex->first<<
":";
1856 if(!rindex->second.first->empty()) {
1859 const typename RList::const_iterator send= rindex->second.first->
end();
1861 for(
typename RList::const_iterator index = rindex->second.first->begin();
1862 index != send; ++index)
1866 if(!rindex->second.second->empty()) {
1867 os<<rank<<
": Prozess "<<rindex->first<<
": "<<
"receive: ";
1869 const typename RList::const_iterator rend= rindex->second.second->end();
1871 for(
typename RList::const_iterator index = rindex->second.second->begin();
1872 index != rend; ++index)
1873 os << *index <<
" ";
1875 os<<std::endl<<std::flush;
void insert(const T &v)
Insert an element at the current position.
Definition: sllist.hh:511
A::template rebind< RemoteIndex >::other Allocator
The type of the allocator for the remote index list.
Definition: remoteindices.hh:229
bool operator==(const iterator &other)
Definition: remoteindices.hh:851
An index present on the local process with an additional attribute flag.
Definition: plocalindex.hh:27
Iterator over the valid underlying iterators.
Definition: remoteindices.hh:786
RemoteIndexListModifier()
Default constructor.
Definition: remoteindices.hh:671
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: indexset.hh:225
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
Information about an index residing on another processor.
Definition: remoteindices.hh:48
Class for recomputing missing indices of a distributed index set.
Definition: indicessyncer.hh:39
void setIncludeSelf(bool includeSelf)
Tell whether sending from indices of the processor to other indices on the same processor is enabled ...
Definition: remoteindices.hh:961
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition: sllist.hh:657
A pair consisting of a global and local index.
Definition: indexset.hh:30
Standard Dune debug streams.
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: remoteindices.hh:218
Base class of all classes representing a communication interface.
Definition: interface.hh:32
A Allocator
The type of the allocator for the remote index list.
Definition: remoteindices.hh:593
bool operator==(const RemoteIndices &ri)
Definition: remoteindices.hh:1531
Traits classes for mapping types onto MPI_Datatype.
A constant iterator for the SLList.
Definition: sllist.hh:28
const GlobalIndex & global() const
Get the global index.
void repairLocalIndexPointers()
Repair the pointers to the local index pairs.
Definition: remoteindices.hh:1573
void advance(const GlobalIndex &global)
Advances all underlying iterators.
Definition: remoteindices.hh:1718
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition: indexset.hh:238
RemoteIndexList::const_iterator ConstIterator
The type of the remote index list iterator.
Definition: remoteindices.hh:607
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentional unused function parameters with.
Definition: unused.hh:18
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition: sllist.hh:801
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: remoteindices.hh:583
Definition: remoteindices.hh:550
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: remoteindices.hh:573
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: remoteindices.hh:213
SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator
The type of the modifying iterator of the remote index list.
Definition: remoteindices.hh:602
RemoteIndices()
Definition: remoteindices.hh:967
Provides a map between global and local indices.
iterator begin()
Definition: remoteindices.hh:1819
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:252
void insert(const RemoteIndex &index)
Insert an index to the list.
Definition: remoteindices.hh:1606
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex &index)
Definition: remoteindices.hh:794
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex index, Attribute attribute)
Definition: remoteindices.hh:802
CollectiveIterator & operator++()
Definition: remoteindices.hh:1785
void free()
Free the index lists.
Definition: remoteindices.hh:1423
A single linked list.
Definition: sllist.hh:41
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:223
T ParallelIndexSet
Type of the index set we use.
Definition: remoteindices.hh:568
IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType
The type of the index pair.
Definition: remoteindices.hh:98
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition: remoteindices.hh:743
void setNeighbours(const C &neighbours)
Definition: remoteindices.hh:292
iterator(const iterator &other)
Definition: remoteindices.hh:812
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: remoteindices.hh:578
iterator & operator++()
Definition: remoteindices.hh:817
bool operator!=(const iterator &other)
Definition: remoteindices.hh:857
static MPI_Datatype getType()
Definition: mpitraits.hh:44
The default mode. Indicates that the index set is ready to be used.
Definition: indexset.hh:185
MPI_Comm communicator() const
Get the mpi communicator used.
Definition: remoteindices.hh:1697
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: remoteindices.hh:207
The indices present on remote processes.
Definition: remoteindices.hh:45
const_iterator begin() const
Get an iterator over all remote index lists.
Definition: remoteindices.hh:1517
bool operator!=(const RemoteIndex &ri) const
Definition: remoteindices.hh:930
iterator begin()
Get an iterator pointing to the first element in the list.
Definition: sllist.hh:776
bool empty() const
Check whether the list is empty.
Definition: sllist.hh:764
Map::iterator ConstRealIterator
Definition: remoteindices.hh:790
bool isSynced() const
Checks whether the remote indices are synced with the indexsets.
Definition: remoteindices.hh:1468
Map::iterator RealIterator
Definition: remoteindices.hh:789
bool operator==(const RemoteIndex &ri) const
Definition: remoteindices.hh:924
void remove()
Delete the entry at the current position.
Definition: sllist.hh:524
LocalIndex & local()
Get the local index.
Exception indicating that the index set is not in the expected state.
Definition: indexset.hh:204
const RemoteIndex & operator*() const
Definition: remoteindices.hh:833
If true the index set corresponding to the remote indices might get modified.
Definition: remoteindices.hh:562
int neighbours() const
Get the number of processors we share indices with.
Definition: remoteindices.hh:1441
A few common exception classes.
CollectiveIteratorT iterator() const
Get an iterator for colletively iterating over the remote indices of all remote processes.
Definition: remoteindices.hh:1691
iterator end()
Definition: remoteindices.hh:1830
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
const ParallelIndexSet & destinationIndexSet() const
Get the index set at destination.
Definition: remoteindices.hh:996
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition: remoteindices.hh:233
const Attribute attribute() const
Get the attribute of the index on the remote process.
Definition: remoteindices.hh:936
CollectiveIterator(const RemoteIndexMap &map_, bool send)
Constructor.
Definition: remoteindices.hh:1704
bool remove(const GlobalIndex &global)
Remove a remote index.
Definition: remoteindices.hh:1654
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:230
RemoteIndexListModifier< T, A, mode > getModifier(int process)
Get a modifier for a remote index list.
Definition: remoteindices.hh:1475
An stl-compliant pool allocator.
Modifier for adding and/or deleting remote indices from the remote index list.
Definition: remoteindices.hh:58
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition: remoteindices.hh:237
A collective iterator for moving over the remote indices for all processes collectively.
Definition: remoteindices.hh:152
Default exception class for range errors.
Definition: exceptions.hh:279
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:588
iterator end()
Get an iterator pointing to the end of the list.
Definition: sllist.hh:788
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:973
A traits class describing the mapping of types onto MPI_Datatypes.
Definition: bigunsignedint.hh:30
T ParallelIndexSet
Type of the index set we use, e.g. ParallelLocalIndexSet.
Definition: remoteindices.hh:198
const_iterator end() const
Get an iterator over all remote index lists.
Definition: remoteindices.hh:1524
RemoteIndexMap::const_iterator const_iterator
Definition: remoteindices.hh:239
const ParallelIndexSet & sourceIndexSet() const
Get the index set at the source.
Definition: remoteindices.hh:988
T1 GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: remoteindices.hh:83
const_iterator find(int proc) const
Find an iterator over the remote index lists of a specific process.
Definition: remoteindices.hh:1510
void rebuild()
Rebuilds the set of remote indices.
Definition: remoteindices.hh:1448
CollectiveIterator< T, A > CollectiveIteratorT
The type of the collective iterator over all remote indices.
Definition: remoteindices.hh:202
const std::set< int > & getNeighbours() const
Definition: remoteindices.hh:299
A constant random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:20
int process() const
Definition: remoteindices.hh:839
bool empty()
Checks whether there are still iterators in the map.
Definition: remoteindices.hh:1812
const RemoteIndex * operator->() const
Definition: remoteindices.hh:845
RemoteIndex()
Parameterless Constructor.
Definition: remoteindices.hh:920
~RemoteIndices()
Destructor.
Definition: remoteindices.hh:1003
T2 Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition: remoteindices.hh:92
const PairType & localIndexPair() const
Get the corresponding local index pair.
Definition: remoteindices.hh:942
Dune namespace.
Definition: alignment.hh:9
Implements a singly linked list together with the necessary iterators.
Provides classes for use as the local index in ParallelIndexSet for distributed computing.
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition: remoteindices.hh:597
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition: stdstreams.hh:93
Definition: remoteindices.hh:159