3#ifndef DUNE_REMOTEINDICES_HH
4#define DUNE_REMOTEINDICES_HH
34 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>
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>
146 template<
class T,
class A>
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*> >
259 const MPI_Comm& comm,
const std::vector<int>&
neighbours=std::vector<int>(),
bool includeSelf=
false);
289 const MPI_Comm& comm,
const std::vector<int>&
neighbours=std::vector<int>());
294 neighbourIds.clear();
318 template<
bool ignorePublic>
351 template<
bool mode,
bool send>
413 std::set<int> neighbourIds;
416 const static int commTag_=333;
449 typedef IndexPair<GlobalIndex, LocalIndex>
470 template<
bool ignorePublic>
471 inline void buildRemote(
bool includeSelf);
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* position,
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>
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;
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);
795 : iter_(iter), end_(
end), index_(index), hasAttribute(false)
798 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=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) {
888 int length[2] = {1, 1};
894 MPI_Get_address(&rep, &base);
895 MPI_Get_address(&(rep.global_), &disp[0]);
896 MPI_Get_address(&(rep.local_), &disp[1]);
897 for (MPI_Aint& d : disp)
901 MPI_Type_create_struct(2, length, disp, types, &tmp);
904 MPI_Type_commit(&type);
911 template<
typename TG,
typename TA>
914 template<
typename T1,
typename T2>
916 : localIndex_(local), attribute_(attribute)
919 template<
typename T1,
typename T2>
921 : localIndex_(0), attribute_(attribute)
924 template<
typename T1,
typename T2>
926 : localIndex_(0), attribute_()
928 template<
typename T1,
typename T2>
931 return localIndex_==ri.localIndex_ && attribute_==ri.
attribute;
934 template<
typename T1,
typename T2>
937 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_;
940 template<
typename T1,
typename T2>
943 return T2(attribute_);
946 template<
typename T1,
typename T2>
952 template<
typename T,
typename A>
955 const MPI_Comm& comm,
956 const std::vector<int>& neighbours,
958 : source_(&source), target_(&destination), comm_(comm),
959 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true),
960 includeSelf(includeSelf_)
965 template<
typename T,
typename A>
971 template<
typename T,
typename A>
973 : source_(0), target_(0), sourceSeqNo_(-1),
974 destSeqNo_(-1), publicIgnored(false), firstBuild(true),
978 template<
class T,
typename A>
981 const MPI_Comm& comm,
982 const std::vector<int>& neighbours)
986 target_ = &destination;
989 setNeighbours(neighbours);
992 template<
typename T,
typename A>
1000 template<
typename T,
typename A>
1008 template<
typename T,
typename A>
1014 template<
typename T,
typename A>
1015 template<
bool ignorePublic>
1018 char* p_out, MPI_Datatype type,
1020 int *position,
int n)
1030 for(
const_iterator index = indexSet.begin(); index != end; ++index)
1031 if(ignorePublic || index->local().isPublic()) {
1033 MPI_Pack(
const_cast<PairType*
>(&(*index)), 1,
1035 p_out, bufferSize, position, comm_);
1036 pairs[i++] =
const_cast<PairType*
>(&(*index));
1042 template<
typename T,
typename A>
1049 const const_iterator end=indexSet.
end();
1050 for(const_iterator index=indexSet.
begin(); index!=end; ++index)
1051 if(index->local().isPublic())
1059 template<
typename T,
typename A>
1060 inline void RemoteIndices<T,A>::unpackCreateRemote(
char* p_in, PairType** sourcePairs,
1061 PairType** destPairs,
int remoteProc,
1062 int sourcePublish,
int destPublish,
1063 int bufferSize,
bool sendTwo,
1068 int noRemoteSource=-1, noRemoteDest=-1;
1069 char twoIndexSets=0;
1072 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_);
1074 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_);
1076 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_);
1080 RemoteIndexList* receive=
new RemoteIndexList();
1082 RemoteIndexList* send=0;
1088 send =
new RemoteIndexList();
1090 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish,
1091 destPairs, destPublish, p_in, type, &position, bufferSize);
1094 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish,
1095 p_in, type, &position, bufferSize, fromOurSelf);
1100 int oldPos=position;
1102 unpackIndices(*receive, noRemoteSource, destPairs, destPublish,
1103 p_in, type, &position, bufferSize, fromOurSelf);
1108 send =
new RemoteIndexList();
1109 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish,
1110 p_in, type, &position, bufferSize, fromOurSelf);
1113 if(receive->empty() && send->empty()) {
1121 remoteIndices_.insert(std::make_pair(remoteProc,
1122 std::make_pair(send,receive)));
1127 template<
typename T,
typename A>
1128 template<
bool ignorePublic>
1129 inline void RemoteIndices<T,A>::buildRemote(
bool includeSelf_)
1133 MPI_Comm_rank(comm_, &rank);
1134 MPI_Comm_size(comm_, &procs);
1138 int sourcePublish, destPublish;
1141 char sendTwo = (source_ != target_);
1143 if(procs==1 && !(sendTwo || includeSelf_))
1147 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_);
1150 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_);
1155 int maxPublish, publish=sourcePublish+destPublish;
1158 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_);
1161 typedef IndexPair<GlobalIndex,LocalIndex> PairType;
1163 PairType** destPairs;
1164 PairType** sourcePairs =
new PairType*[sourcePublish>0 ? sourcePublish : 1];
1167 destPairs =
new PairType*[destPublish>0 ? destPublish : 1];
1169 destPairs=sourcePairs;
1171 char** buffer =
new char*[2];
1180 MPI_Pack_size(maxPublish, type, comm_,
1182 MPI_Pack_size(1, MPI_INT, comm_,
1184 MPI_Pack_size(1, MPI_CHAR, comm_,
1190 bufferSize += 2 * intSize + charSize;
1192 if(bufferSize<=0) bufferSize=1;
1194 buffer[0] =
new char[bufferSize];
1195 buffer[1] =
new char[bufferSize];
1199 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position,
1203 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1205 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position,
1209 packEntries<ignorePublic>(sourcePairs, *source_, buffer[0], type,
1210 bufferSize, &position, sourcePublish);
1213 packEntries<ignorePublic>(destPairs, *target_, buffer[0], type,
1214 bufferSize, &position, destPublish);
1218 if(sendTwo|| includeSelf_)
1219 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish,
1220 destPublish, bufferSize, sendTwo, includeSelf_);
1222 neighbourIds.erase(rank);
1224 if(neighbourIds.size()==0)
1226 Dune::dvverb<<rank<<
": Sending messages in a ring"<<std::endl;
1228 for(
int proc=1; proc<procs; proc++) {
1230 char* p_out = buffer[1-(proc%2)];
1231 char* p_in = buffer[proc%2];
1235 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1237 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1238 commTag_, comm_, &status);
1240 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
1241 commTag_, comm_, &status);
1242 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
1248 int remoteProc = (rank+procs-proc)%procs;
1250 unpackCreateRemote(p_in, sourcePairs, destPairs, remoteProc, sourcePublish,
1251 destPublish, bufferSize, sendTwo);
1258 MPI_Request* requests=
new MPI_Request[neighbourIds.size()];
1259 MPI_Request* req=requests;
1261 typedef typename std::set<int>::size_type size_type;
1262 size_type noNeighbours=neighbourIds.size();
1265 for(std::set<int>::iterator neighbour=neighbourIds.begin();
1266 neighbour!= neighbourIds.end(); ++neighbour) {
1268 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++);
1273 for(size_type received=0; received <noNeighbours; ++received)
1277 MPI_Probe(MPI_ANY_SOURCE, commTag_, comm_, &status);
1278 int remoteProc=status.MPI_SOURCE;
1280 MPI_Get_count(&status, MPI_PACKED, &size);
1282 MPI_Recv(buffer[1], size, MPI_PACKED, remoteProc,
1283 commTag_, comm_, &status);
1285 unpackCreateRemote(buffer[1], sourcePairs, destPairs, remoteProc, sourcePublish,
1286 destPublish, bufferSize, sendTwo);
1289 MPI_Status* statuses =
new MPI_Status[neighbourIds.size()];
1291 if(MPI_ERR_IN_STATUS==MPI_Waitall(neighbourIds.size(), requests, statuses)) {
1292 for(size_type i=0; i < neighbourIds.size(); ++i)
1293 if(statuses[i].MPI_ERROR!=MPI_SUCCESS) {
1294 std::cerr<<rank<<
": MPI_Error occurred while receiving message."<<std::endl;
1295 MPI_Abort(comm_, 999);
1304 if(destPairs!=sourcePairs)
1307 delete[] sourcePairs;
1313 template<
typename T,
typename A>
1314 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& remote,
1324 if(remoteEntries==0)
1328 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1330 GlobalIndex oldGlobal=index.global();
1331 int n_in=0, localIndex=0;
1334 while(localIndex<localEntries) {
1335 if(local[localIndex]->global()==index.global()) {
1336 int oldLocalIndex=localIndex;
1338 while(localIndex<localEntries &&
1339 local[localIndex]->global()==index.global()) {
1340 if(!fromOurSelf || index.local().attribute() !=
1341 local[localIndex]->local().attribute())
1343 remote.push_back(RemoteIndex(index.local().attribute(),
1344 local[localIndex]));
1349 if((++n_in) < remoteEntries) {
1350 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1352 if(index.global()==oldGlobal)
1354 localIndex=oldLocalIndex;
1356 oldGlobal=index.global();
1364 if (local[localIndex]->global()<index.global()) {
1369 if((++n_in) < remoteEntries) {
1370 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1372 oldGlobal=index.global();
1380 while(++n_in < remoteEntries)
1381 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1386 template<
typename T,
typename A>
1387 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& send,
1388 RemoteIndexList& receive,
1390 PairType** localSource,
1391 int localSourceEntries,
1392 PairType** localDest,
1393 int localDestEntries,
1399 int n_in=0, sourceIndex=0, destIndex=0;
1402 while(n_in<remoteEntries && (sourceIndex<localSourceEntries || destIndex<localDestEntries)) {
1405 MPI_Unpack(p_in, bufferSize, position, &index, 1,
1410 while(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()<index.global())
1413 while(destIndex<localDestEntries && localDest[destIndex]->global()<index.global())
1417 if(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()==index.global())
1418 send.push_back(RemoteIndex(index.local().attribute(),
1419 localSource[sourceIndex]));
1421 if(destIndex < localDestEntries && localDest[destIndex]->global() == index.global())
1422 receive.push_back(RemoteIndex(index.local().attribute(),
1423 localDest[sourceIndex]));
1428 template<
typename T,
typename A>
1431 typedef typename RemoteIndexMap::iterator Iterator;
1432 Iterator lend = remoteIndices_.end();
1433 for(Iterator lists=remoteIndices_.begin(); lists != lend; ++lists) {
1434 if(lists->second.first==lists->second.second) {
1436 delete lists->second.first;
1438 delete lists->second.first;
1439 delete lists->second.second;
1442 remoteIndices_.clear();
1446 template<
typename T,
typename A>
1449 return remoteIndices_.size();
1452 template<
typename T,
typename A>
1453 template<
bool ignorePublic>
1458 ignorePublic!=publicIgnored || !
1462 buildRemote<ignorePublic>(includeSelf);
1464 sourceSeqNo_ = source_->seqNo();
1465 destSeqNo_ = target_->seqNo();
1467 publicIgnored=ignorePublic;
1473 template<
typename T,
typename A>
1476 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo();
1479 template<
typename T,
typename A>
1480 template<
bool mode,
bool send>
1487 sourceSeqNo_ = source_->seqNo();
1488 destSeqNo_ = target_->seqNo();
1490 typename RemoteIndexMap::iterator found = remoteIndices_.find(process);
1492 if(found == remoteIndices_.end())
1494 if(source_ != target_)
1495 found = remoteIndices_.
insert(found, std::make_pair(process,
1500 found = remoteIndices_.insert(found,
1501 std::make_pair(process,
1502 std::make_pair(rlist, rlist)));
1514 template<
typename T,
typename A>
1518 return remoteIndices_.find(proc);
1521 template<
typename T,
typename A>
1525 return remoteIndices_.begin();
1528 template<
typename T,
typename A>
1532 return remoteIndices_.end();
1536 template<
typename T,
typename A>
1543 typedef typename std::map<int,std::pair<RList*,RList*> >::const_iterator
const_iterator;
1547 for(
const_iterator rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) {
1548 if(rindex->first != rindex1->first)
1550 if(*(rindex->second.first) != *(rindex1->second.first))
1552 if(*(rindex->second.second) != *(rindex1->second.second))
1558 template<
class T,
class A,
bool mode>
1560 RemoteIndexList& rList)
1561 : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_(rList.end()), first_(true)
1563 if(MODIFYINDEXSET) {
1565 for(ConstIterator iter=iter_; iter != end_; ++iter)
1566 glist_.push_back(iter->localIndexPair().global());
1567 giter_ = glist_.beginModify();
1571 template<
typename T,
typename A,
bool mode>
1573 : rList_(other.rList_), indexSet_(other.indexSet_),
1574 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_),
1575 first_(other.first_), last_(other.last_)
1578 template<
typename T,
typename A,
bool mode>
1581 if(MODIFYINDEXSET) {
1583#ifdef DUNE_ISTL_WITH_CHECKING
1584 if(indexSet_->state()!=
GROUND)
1590 GlobalIterator giter = glist_.begin();
1591 IndexIterator index = indexSet_->begin();
1593 for(Iterator iter=rList_->begin(); iter != end_; ++iter) {
1594 while(index->global()<*giter) {
1596#ifdef DUNE_ISTL_WITH_CHECKING
1597 if(index == indexSet_->end())
1602#ifdef DUNE_ISTL_WITH_CHECKING
1603 if(index->global() != *giter)
1606 iter->localIndex_ = &(*index);
1611 template<
typename T,
typename A,
bool mode>
1614 static_assert(!mode,
"Not allowed if the mode indicates that new indices"
1615 "might be added to the underlying index set. Use "
1616 "insert(const RemoteIndex&, const GlobalIndex&) instead");
1618#ifdef DUNE_ISTL_WITH_CHECKING
1619 if(!first_ && index.localIndexPair().global()<last_)
1623 while(iter_ != end_ && iter_->localIndexPair().global() < index.localIndexPair().global()) {
1628 assert(iter_==end_ || iter_->localIndexPair().global() != index.localIndexPair().global());
1629 iter_.insert(index);
1630 last_ = index.localIndexPair().global();
1634 template<
typename T,
typename A,
bool mode>
1637 static_assert(mode,
"Not allowed if the mode indicates that no new indices"
1638 "might be added to the underlying index set. Use "
1639 "insert(const RemoteIndex&) instead");
1640#ifdef DUNE_ISTL_WITH_CHECKING
1641 if(!first_ && global<last_)
1645 while(iter_ != end_ && *giter_ < global) {
1651 assert(iter_->localIndexPair().global() != global);
1652 iter_.insert(index);
1653 giter_.insert(global);
1659 template<
typename T,
typename A,
bool mode>
1662#ifdef DUNE_ISTL_WITH_CHECKING
1663 if(!first_ && global<last_)
1669 if(MODIFYINDEXSET) {
1671 while(iter_!=end_ && *giter_< global) {
1675 if(*giter_ == global) {
1681 while(iter_!=end_ && iter_->localIndexPair().global() < global)
1684 if(iter_->localIndexPair().global()==global) {
1695 template<
typename T,
typename A>
1702 template<
typename T,
typename A>
1709 template<
typename T,
typename A>
1712 typedef typename RemoteIndexMap::const_iterator const_iterator;
1714 const const_iterator end=pmap.end();
1715 for(const_iterator process=pmap.begin(); process != end; ++process) {
1716 const RemoteIndexList* list = send ? process->second.first : process->second.second;
1718 map_.insert(std::make_pair(process->first,
1719 std::pair<iterator, const iterator>(list->
begin(), list->
end())));
1723 template<
typename T,
typename A>
1726 typedef typename Map::iterator
iterator;
1727 typedef typename Map::const_iterator const_iterator;
1728 const const_iterator end = map_.end();
1730 for(
iterator iter = map_.begin(); iter != end;) {
1734 RemoteIndex remoteIndex;
1736 remoteIndex = *current;
1738 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1739 ++(iter->second.first);
1742 if(iter->second.first == iter->second.second)
1752 template<
typename T,
typename A>
1754 const Attribute& attribute)
1756 typedef typename Map::iterator
iterator;
1757 typedef typename Map::const_iterator const_iterator;
1758 const const_iterator end = map_.end();
1760 for(
iterator iter = map_.begin(); iter != end;) {
1764 RemoteIndex remoteIndex;
1766 remoteIndex = *current;
1769 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
1770 ++(iter->second.first);
1773 while(iter->second.first!=iter->second.second
1774 && iter->second.first->localIndexPair().global()==index
1775 && iter->second.first->localIndexPair().local().attribute()<attribute)
1776 ++(iter->second.first);
1779 if(iter->second.first == iter->second.second)
1786 attribute_=attribute;
1790 template<
typename T,
typename A>
1793 typedef typename Map::iterator
iterator;
1794 typedef typename Map::const_iterator const_iterator;
1795 const const_iterator end = map_.end();
1797 for(
iterator iter = map_.begin(); iter != end;) {
1803 if(iter->second.first->localIndexPair().global()==index_ &&
1804 (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_))
1805 ++(iter->second.first);
1808 if(iter->second.first == iter->second.second)
1817 template<
typename T,
typename A>
1820 return map_.empty();
1823 template<
typename T,
typename A>
1828 return iterator(map_.begin(), map_.end(), index_);
1830 return iterator(map_.begin(), map_.end(), index_,
1834 template<
typename T,
typename A>
1838 return iterator(map_.end(), map_.end(), index_);
1841 template<
typename TG,
typename TA>
1848 template<
typename T,
typename A>
1852 MPI_Comm_rank(indices.comm_, &rank);
1855 typedef typename std::map<int,std::pair<RList*,RList*> >::const_iterator const_iterator;
1857 const const_iterator rend = indices.remoteIndices_.end();
1859 for(const_iterator rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) {
1860 os<<rank<<
": Prozess "<<rindex->first<<
":";
1862 if(!rindex->second.first->empty()) {
1865 const typename RList::const_iterator send= rindex->second.first->end();
1867 for(
typename RList::const_iterator index = rindex->second.first->begin();
1868 index != send; ++index)
1872 if(!rindex->second.second->empty()) {
1873 os<<rank<<
": Prozess "<<rindex->first<<
": "<<
"receive: ";
1875 for(
const auto& index : *(rindex->second.second))
1878 os<<std::endl<<std::flush;
Traits classes for mapping types onto MPI_Datatype.
Provides classes for use as the local index in ParallelIndexSet for distributed computing.
Provides a map between global and local indices.
An stl-compliant pool allocator.
Implements a singly linked list together with the necessary iterators.
Standard Dune debug streams.
A few common exception classes.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition unused.hh:18
std::ostream & operator<<(std::ostream &s, const std::array< T, N > &e)
Output operator for array.
Definition array.hh:28
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:788
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition sllist.hh:72
SLListModifyIterator< GlobalIndex, Allocator > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:101
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:776
#define DUNE_THROW(E, m)
Definition exceptions.hh:216
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition indexset.hh:305
iterator begin()
Get an iterator over the indices positioned at the first index.
iterator end()
Get an iterator over the indices positioned after the last index.
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition indexset.hh:238
const GlobalIndex & global() const
Get the global index.
LocalIndex & local()
Get the local index.
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:225
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition indexset.hh:185
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:93
Dune namespace.
Definition alignment.hh:11
constexpr auto size(const Dune::FieldVector< T, i > *, const PriorityTag< 5 > &) -> decltype(std::integral_constant< std::size_t, i >())
Definition hybridutilities.hh:22
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:39
static MPI_Datatype getType()
Definition mpitraits.hh:46
Default exception class for range errors.
Definition exceptions.hh:252
A pair consisting of a global and local index.
Definition indexset.hh:84
Exception indicating that the index set is not in the expected state.
Definition indexset.hh:204
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:217
Class for recomputing missing indices of a distributed index set.
Definition indicessyncer.hh:40
Base class of all classes representing a communication interface.
Definition interface.hh:33
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:47
The indices present on remote processes.
Definition remoteindices.hh:181
const std::set< int > & getNeighbours() const
Definition remoteindices.hh:299
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:223
RemoteIndices()
Definition remoteindices.hh:972
friend void fillIndexSetHoles(const G &graph, Dune::OwnerOverlapCopyCommunication< T1, T2 > &oocomm)
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:979
void free()
Free the index lists.
Definition remoteindices.hh:1429
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T1::GlobalIndex, typename T1::LocalIndex::Attribute >, A2 > > &, RemoteIndices< T1, A1 > &, const T1 &)
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:207
void rebuild()
Rebuilds the set of remote indices.
Definition remoteindices.hh:1454
T ParallelIndexSet
Type of the index set we use, e.g. ParallelLocalIndexSet.
Definition remoteindices.hh:198
MPI_Comm communicator() const
Get the mpi communicator used.
Definition remoteindices.hh:1703
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:218
CollectiveIteratorT iterator() const
Get an iterator for colletively iterating over the remote indices of all remote processes.
Definition remoteindices.hh:1697
void setIncludeSelf(bool includeSelf)
Tell whether sending from indices of the processor to other indices on the same processor is enabled ...
Definition remoteindices.hh:966
const_iterator end() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1530
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:237
void setNeighbours(const C &neighbours)
Definition remoteindices.hh:292
RemoteIndexListModifier< T, A, mode > getModifier(int process)
Get a modifier for a remote index list.
Definition remoteindices.hh:1481
bool operator==(const RemoteIndices &ri)
Definition remoteindices.hh:1537
const ParallelIndexSet & sourceIndexSet() const
Get the index set at the source.
Definition remoteindices.hh:994
~RemoteIndices()
Destructor.
Definition remoteindices.hh:1009
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:233
int neighbours() const
Get the number of processors we share indices with.
Definition remoteindices.hh:1447
CollectiveIterator< T, A > CollectiveIteratorT
The type of the collective iterator over all remote indices.
Definition remoteindices.hh:202
const ParallelIndexSet & destinationIndexSet() const
Get the index set at destination.
Definition remoteindices.hh:1002
const_iterator find(int proc) const
Find an iterator over the remote index lists of a specific process.
Definition remoteindices.hh:1516
bool isSynced() const
Checks whether the remote indices are synced with the indexsets.
Definition remoteindices.hh:1474
const_iterator begin() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1523
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:213
A::template rebind< RemoteIndex >::other Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:229
RemoteIndexMap::const_iterator const_iterator
Definition remoteindices.hh:239
Information about an index residing on another processor.
Definition remoteindices.hh:66
const Attribute attribute() const
Get the attribute of the index on the remote process.
Definition remoteindices.hh:941
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &, RemoteIndices< T, A1 > &, const T &)
bool operator==(const RemoteIndex &ri) const
Definition remoteindices.hh:929
T1 GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition remoteindices.hh:83
T2 Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition remoteindices.hh:92
IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType
The type of the index pair.
Definition remoteindices.hh:98
const PairType & localIndexPair() const
Get the corresponding local index pair.
Definition remoteindices.hh:947
RemoteIndex()
Parameterless Constructor.
Definition remoteindices.hh:925
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:544
void repairLocalIndexPointers()
Repair the pointers to the local index pairs.
Definition remoteindices.hh:1579
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:597
@ MODIFYINDEXSET
If true the index set corresponding to the remote indices might get modified.
Definition remoteindices.hh:562
A Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:593
void insert(const RemoteIndex &index)
Insert an index to the list.
Definition remoteindices.hh:1612
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:578
RemoteIndexList::const_iterator ConstIterator
The type of the remote index list iterator.
Definition remoteindices.hh:607
SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator
The type of the modifying iterator of the remote index list.
Definition remoteindices.hh:602
bool remove(const GlobalIndex &global)
Remove a remote index.
Definition remoteindices.hh:1660
T ParallelIndexSet
Type of the index set we use.
Definition remoteindices.hh:568
RemoteIndexListModifier()
Default constructor.
Definition remoteindices.hh:671
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:583
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:588
A collective iterator for moving over the remote indices for all processes collectively.
Definition remoteindices.hh:703
CollectiveIterator & operator++()
Definition remoteindices.hh:1791
iterator end()
Definition remoteindices.hh:1836
CollectiveIterator(const RemoteIndexMap &map_, bool send)
Constructor.
Definition remoteindices.hh:1710
bool empty()
Checks whether there are still iterators in the map.
Definition remoteindices.hh:1818
void advance(const GlobalIndex &global)
Advances all underlying iterators.
Definition remoteindices.hh:1724
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:743
iterator begin()
Definition remoteindices.hh:1825
Definition remoteindices.hh:159
Definition remoteindices.hh:551
Iterator over the valid underlying iterators.
Definition remoteindices.hh:787
bool operator==(const iterator &other)
Definition remoteindices.hh:851
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex &index)
Definition remoteindices.hh:794
bool operator!=(const iterator &other)
Definition remoteindices.hh:857
iterator(const iterator &other)
Definition remoteindices.hh:812
const RemoteIndex & operator*() const
Definition remoteindices.hh:833
Map::iterator ConstRealIterator
Definition remoteindices.hh:790
iterator & operator++()
Definition remoteindices.hh:817
const RemoteIndex * operator->() const
Definition remoteindices.hh:845
int process() const
Definition remoteindices.hh:839
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex index, Attribute attribute)
Definition remoteindices.hh:802
Map::iterator RealIterator
Definition remoteindices.hh:789
A mutable iterator for the SLList.
Definition sllist.hh:431
A single linked list.
Definition sllist.hh:42