Dune Core Modules (2.10.0)

indexset.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_COMMON_PARALLEL_INDEXSET_HH
6#define DUNE_COMMON_PARALLEL_INDEXSET_HH
7
8#include <algorithm>
9#include <cstdint> // for uint32_t
10#include <iostream>
11
16
17namespace Dune
18{
28 // forward declarations
29
30 template<class TG, class TL>
31 class IndexPair;
32
38 template<class TG, class TL>
39 std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair);
40
41 template<class TG, class TL>
42 bool operator==(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
43
44 template<class TG, class TL>
45 bool operator!=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
46
47 template<class TG, class TL>
48 bool operator<(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
49
50 template<class TG, class TL>
51 bool operator>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
52
53 template<class TG, class TL>
54 bool operator<=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
55
56 template<class TG, class TL>
57 bool operator >=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
58
59 template<class TG, class TL>
60 bool operator==(const IndexPair<TG,TL>&, const TG&);
61
62 template<class TG, class TL>
63 bool operator!=(const IndexPair<TG,TL>&, const TG&);
64
65 template<class TG, class TL>
66 bool operator<(const IndexPair<TG,TL>&, const TG&);
67
68 template<class TG, class TL>
69 bool operator>(const IndexPair<TG,TL>&, const TG&);
70
71 template<class TG, class TL>
72 bool operator<=(const IndexPair<TG,TL>&, const TG&);
73
74 template<class TG, class TL>
75 bool operator >=(const IndexPair<TG,TL>&, const TG&);
76
77 template<typename T>
78 struct MPITraits;
79
83 template<class TG, class TL>
85 {
86 friend std::ostream& operator<<<>(std::ostream&, const IndexPair<TG,TL>&);
87 friend bool operator==<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
88 friend bool operator!=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
89 friend bool operator< <>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
90 friend bool operator><>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
91 friend bool operator<=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
92 friend bool operator>=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
93 friend bool operator==<>(const IndexPair<TG,TL>&, const TG &);
94 friend bool operator!=<>(const IndexPair<TG,TL>&, const TG &);
95 friend bool operator< <>(const IndexPair<TG,TL>&, const TG &);
96 friend bool operator> <>(const IndexPair<TG,TL>&, const TG &);
97 friend bool operator<=<>(const IndexPair<TG,TL>&, const TG &);
98 friend bool operator>=<>(const IndexPair<TG,TL>&, const TG &);
99 friend struct MPITraits<IndexPair<TG,TL> >;
100
101 public:
107 typedef TG GlobalIndex;
108
120 typedef TL LocalIndex;
121
129
141
147 inline const GlobalIndex& global() const;
148
154 inline LocalIndex& local();
155
161 inline const LocalIndex& local() const;
162
168 inline void setLocal(int index);
169 private:
171 GlobalIndex global_;
173 LocalIndex local_;
174 };
175
181 {
190 RESIZE
200 };
201
206
207 // Forward declaration
208 template<class I> class GlobalLookupIndexSet;
209
216 template<typename TG, typename TL, int N=100>
218 {
219 friend class GlobalLookupIndexSet<ParallelIndexSet<TG,TL,N> >;
220
221 public:
226 typedef TG GlobalIndex;
227
239 typedef TL LocalIndex;
240
245
252 constexpr static int arraySize = (N>0) ? N : 1;
253
255 class iterator :
256 public ArrayList<IndexPair,N>::iterator
257 {
258 typedef typename ArrayList<IndexPair,N>::iterator
259 Father;
261 public:
262 iterator(ParallelIndexSet<TG,TL,N>& indexSet, const Father& father)
263 : Father(father), indexSet_(&indexSet)
264 {}
265
266 private:
276 inline void markAsDeleted() const
277 {
278#ifndef NDEBUG
279 if(indexSet_->state_ != RESIZE)
280 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
281 <<"while in RESIZE state!");
282#endif
283 Father::operator*().local().setState(DELETED);
284 }
285
287 ParallelIndexSet<TG,TL,N>* indexSet_;
288
289 };
290
291
292
294 typedef typename
297
302
308 {
309 return state_;
310 }
311
318
327 inline void add(const GlobalIndex& global);
328
337 inline void add(const GlobalIndex& global, const LocalIndex& local);
338
346 inline void markAsDeleted(const iterator& position);
347
360 void endResize();
361
372 inline IndexPair&
373 operator[](const GlobalIndex& global);
374
384 inline IndexPair&
385 at(const GlobalIndex& global);
386
396 inline bool
397 exists (const GlobalIndex& global) const;
398
409 inline const IndexPair&
410 operator[](const GlobalIndex& global) const;
411
421 inline const IndexPair&
422 at(const GlobalIndex& global) const;
423
428 inline iterator begin();
429
434 inline iterator end();
435
440 inline const_iterator begin() const;
441
446 inline const_iterator end() const;
447
457 inline void renumberLocal();
458
465 inline int seqNo() const;
466
471 inline size_t size() const;
472
473 private:
475 ArrayList<IndexPair,N> localIndices_;
477 ArrayList<IndexPair,N> newIndices_;
481 int seqNo_;
483 bool deletedEntries_;
488 inline void merge();
489 };
490
491
497 template<class TG, class TL, int N>
498 std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet);
499
505 template<class I>
507 {
508 public:
513
518
523
528
530
537 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size);
538
545
550
560 inline const IndexPair&
561 operator[](const GlobalIndex& global) const;
562
566 inline const IndexPair*
567 pair(const std::size_t& local) const;
568
573 inline const_iterator begin() const;
574
579 inline const_iterator end() const;
580
587 inline int seqNo() const;
588
593 inline size_t size() const;
594 private:
598 const ParallelIndexSet& indexSet_;
599
603 std::size_t size_;
604
608 std::vector<const IndexPair*> indices_;
609
610 };
611
612
613 template<typename T>
614 struct LocalIndexComparator
615 {
616 static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& t2)
617 {
618 return false;
619 }
620 };
621
622 template<class TG, class TL>
623 struct IndexSetSortFunctor
624 {
625 bool operator()(const IndexPair<TG,TL>& i1, const IndexPair<TG,TL>& i2)
626 {
627 return i1.global()<i2.global() || (i1.global()==i2.global() &&
628 LocalIndexComparator<TL>::compare(i1.local(),
629 i2.local()));
630 }
631 };
632
633
634
635 template<class TG, class TL>
636 inline std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair)
637 {
638 os<<"{global="<<pair.global_<<", local="<<pair.local_<<"}";
639 return os;
640 }
641
642 template<class TG, class TL, int N>
643 inline std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet)
644 {
645 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iterator;
646 Iterator end = indexSet.end();
647 os<<"{";
648 for(Iterator index = indexSet.begin(); index != end; ++index)
649 os<<*index<<" ";
650 os<<"}";
651 return os;
652
653 }
654
655 template<class TG, class TL>
656 inline bool operator==(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
657 {
658 return a.global_==b.global_;
659 }
660
661 template<class TG, class TL>
662 inline bool operator!=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
663 {
664 return a.global_!=b.global_;
665 }
666
667 template<class TG, class TL>
668 inline bool operator<(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
669 {
670 return a.global_<b.global_;
671 }
672
673 template<class TG, class TL>
674 inline bool operator>(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
675 {
676 return a.global_>b.global_;
677 }
678
679 template<class TG, class TL>
680 inline bool operator<=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
681 {
682 return a.global_<=b.global_;
683 }
684
685 template<class TG, class TL>
686 inline bool operator >=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
687 {
688 return a.global_>=b.global_;
689 }
690
691 template<class TG, class TL>
692 inline bool operator==(const IndexPair<TG,TL>& a, const TG& b)
693 {
694 return a.global_==b;
695 }
696
697 template<class TG, class TL>
698 inline bool operator!=(const IndexPair<TG,TL>& a, const TG& b)
699 {
700 return a.global_!=b;
701 }
702
703 template<class TG, class TL>
704 inline bool operator<(const IndexPair<TG,TL>& a, const TG& b)
705 {
706 return a.global_<b;
707 }
708
709 template<class TG, class TL>
710 inline bool operator>(const IndexPair<TG,TL>& a, const TG& b)
711 {
712 return a.global_>b;
713 }
714
715 template<class TG, class TL>
716 inline bool operator<=(const IndexPair<TG,TL>& a, const TG& b)
717 {
718 return a.global_<=b;
719 }
720
721 template<class TG, class TL>
722 inline bool operator >=(const IndexPair<TG,TL>& a, const TG& b)
723 {
724 return a.global_>=b;
725 }
726
727#ifndef DOXYGEN
728
729 template<class TG, class TL>
730 IndexPair<TG,TL>::IndexPair(const TG& global, const TL& local)
731 : global_(global), local_(local){}
732
733 template<class TG, class TL>
734 IndexPair<TG,TL>::IndexPair(const TG& global)
735 : global_(global), local_(){}
736
737 template<class TG, class TL>
738 IndexPair<TG,TL>::IndexPair()
739 : global_(), local_(){}
740
741 template<class TG, class TL>
742 inline const TG& IndexPair<TG,TL>::global() const {
743 return global_;
744 }
745
746 template<class TG, class TL>
747 inline TL& IndexPair<TG,TL>::local() {
748 return local_;
749 }
750
751 template<class TG, class TL>
752 inline const TL& IndexPair<TG,TL>::local() const {
753 return local_;
754 }
755
756 template<class TG, class TL>
757 inline void IndexPair<TG,TL>::setLocal(int local){
758 local_=local;
759 }
760
761 template<class TG, class TL, int N>
763 : state_(GROUND), seqNo_(0), deletedEntries_()
764 {}
765
766 template<class TG, class TL, int N>
768 {
769
770 // Checks in unproductive code
771#ifndef NDEBUG
772 if(state_!=GROUND)
773 DUNE_THROW(InvalidIndexSetState,
774 "IndexSet has to be in GROUND state, when "
775 << "beginResize() is called!");
776#endif
777
778 state_ = RESIZE;
779 deletedEntries_ = false;
780 }
781
782 template<class TG, class TL, int N>
783 inline void ParallelIndexSet<TG,TL,N>::add(const GlobalIndex& global)
784 {
785 // Checks in unproductive code
786#ifndef NDEBUG
787 if(state_ != RESIZE)
788 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
789 <<"while in RESIZE state!");
790#endif
791 newIndices_.push_back(IndexPair(global));
792 }
793
794 template<class TG, class TL, int N>
795 inline void ParallelIndexSet<TG,TL,N>::add(const TG& global, const TL& local)
796 {
797 // Checks in unproductive code
798#ifndef NDEBUG
799 if(state_ != RESIZE)
800 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
801 <<"while in RESIZE state!");
802#endif
803 newIndices_.push_back(IndexPair(global,local));
804 }
805
806 template<class TG, class TL, int N>
807 inline void ParallelIndexSet<TG,TL,N>::markAsDeleted(const iterator& global)
808 {
809 // Checks in unproductive code
810#ifndef NDEBUG
811 if(state_ != RESIZE)
812 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
813 <<"while in RESIZE state!");
814#endif
815 deletedEntries_ = true;
816
817 global.markAsDeleted();
818 }
819
820 template<class TG, class TL, int N>
822 // Checks in unproductive code
823#ifndef NDEBUG
824 if(state_ != RESIZE)
825 DUNE_THROW(InvalidIndexSetState, "endResize called while not "
826 <<"in RESIZE state!");
827#endif
828
829 std::sort(newIndices_.begin(), newIndices_.end(), IndexSetSortFunctor<TG,TL>());
830 merge();
831 seqNo_++;
832 state_ = GROUND;
833 }
834
835
836 template<class TG, class TL, int N>
837 inline void ParallelIndexSet<TG,TL,N>::merge(){
838 if(localIndices_.size()==0)
839 {
840 localIndices_=newIndices_;
841 newIndices_.clear();
842 }
843 else if(newIndices_.size()>0 || deletedEntries_)
844 {
845 ArrayList<IndexPair,N> tempPairs;
846
847 auto old = localIndices_.begin();
848 auto added = newIndices_.begin();
849 const auto endold = localIndices_.end();
850 const auto endadded = newIndices_.end();
851
852 while(old != endold && added!= endadded)
853 {
854 if(old->local().state()==DELETED) {
855 old.eraseToHere();
856 }
857 else
858 {
859 if(old->global() < added->global() ||
860 (old->global() == added->global()
861 && LocalIndexComparator<TL>::compare(old->local(),added->local())))
862 {
863 tempPairs.push_back(*old);
864 old.eraseToHere();
865 continue;
866 }else
867 {
868 tempPairs.push_back(*added);
869 added.eraseToHere();
870 }
871 }
872 }
873
874 while(old != endold)
875 {
876 if(old->local().state()!=DELETED) {
877 tempPairs.push_back(*old);
878 }
879 old.eraseToHere();
880 }
881
882 while(added!= endadded)
883 {
884 tempPairs.push_back(*added);
885 added.eraseToHere();
886 }
887 localIndices_ = tempPairs;
888 }
889 }
890
891
892 template<class TG, class TL, int N>
893 inline const IndexPair<TG,TL>&
894 ParallelIndexSet<TG,TL,N>::at(const TG& global) const
895 {
896 // perform a binary search
897 int low=0, high=localIndices_.size()-1, probe=-1;
898
899 while(low<high)
900 {
901 probe = (high + low) / 2;
902 if(global <= localIndices_[probe].global())
903 high = probe;
904 else
905 low = probe+1;
906 }
907
908 if(probe==-1)
909 DUNE_THROW(RangeError, "No entries!");
910
911 if( localIndices_[low].global() != global)
912 DUNE_THROW(RangeError, "Could not find entry of "<<global);
913 else
914 return localIndices_[low];
915 }
916
917 template<class TG, class TL, int N>
918 inline const IndexPair<TG,TL>&
919 ParallelIndexSet<TG,TL,N>::operator[](const TG& global) const
920 {
921 // perform a binary search
922 int low=0, high=localIndices_.size()-1, probe=-1;
923
924 while(low<high)
925 {
926 probe = (high + low) / 2;
927 if(global <= localIndices_[probe].global())
928 high = probe;
929 else
930 low = probe+1;
931 }
932
933 return localIndices_[low];
934 }
935 template<class TG, class TL, int N>
936 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::at(const TG& global)
937 {
938 // perform a binary search
939 int low=0, high=localIndices_.size()-1, probe=-1;
940
941 while(low<high)
942 {
943 probe = (high + low) / 2;
944 if(localIndices_[probe].global() >= global)
945 high = probe;
946 else
947 low = probe+1;
948 }
949
950 if(probe==-1)
951 DUNE_THROW(RangeError, "No entries!");
952
953 if( localIndices_[low].global() != global)
954 DUNE_THROW(RangeError, "Could not find entry of "<<global);
955 else
956 return localIndices_[low];
957 }
958
959 template<class TG, class TL, int N>
960 inline bool ParallelIndexSet<TG,TL,N>::exists (const TG& global) const
961 {
962 // perform a binary search
963 int low=0, high=localIndices_.size()-1, probe=-1;
964
965 while(low<high)
966 {
967 probe = (high + low) / 2;
968 if(localIndices_[probe].global() >= global)
969 high = probe;
970 else
971 low = probe+1;
972 }
973
974 if(probe==-1)
975 return false;
976
977 if( localIndices_[low].global() != global)
978 return false;
979 return true;
980 }
981
982 template<class TG, class TL, int N>
983 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::operator[](const TG& global)
984 {
985 // perform a binary search
986 int low=0, high=localIndices_.size()-1, probe=-1;
987
988 while(low<high)
989 {
990 probe = (high + low) / 2;
991 if(localIndices_[probe].global() >= global)
992 high = probe;
993 else
994 low = probe+1;
995 }
996
997 return localIndices_[low];
998 }
999 template<class TG, class TL, int N>
1000 inline typename ParallelIndexSet<TG,TL,N>::iterator
1002 {
1003 return iterator(*this, localIndices_.begin());
1004 }
1005
1006
1007 template<class TG, class TL, int N>
1008 inline typename ParallelIndexSet<TG,TL,N>::iterator
1010 {
1011 return iterator(*this,localIndices_.end());
1012 }
1013
1014 template<class TG, class TL, int N>
1017 {
1018 return localIndices_.begin();
1019 }
1020
1021
1022 template<class TG, class TL, int N>
1025 {
1026 return localIndices_.end();
1027 }
1028
1029 template<class TG, class TL, int N>
1031#ifndef NDEBUG
1032 if(state_==RESIZE)
1033 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in "
1034 <<"GROUND state for renumberLocal()");
1035#endif
1036
1037 const auto end_ = end();
1038 uint32_t index=0;
1039
1040 for(auto pair=begin(); pair!=end_; index++, ++pair)
1041 pair->local()=index;
1042 }
1043
1044 template<class TG, class TL, int N>
1045 inline int ParallelIndexSet<TG,TL,N>::seqNo() const
1046 {
1047 return seqNo_;
1048 }
1049
1050 template<class TG, class TL, int N>
1051 inline size_t ParallelIndexSet<TG,TL,N>::size() const
1052 {
1053 return localIndices_.size();
1054 }
1055
1056 template<class I>
1057 GlobalLookupIndexSet<I>::GlobalLookupIndexSet(const I& indexset,
1058 std::size_t size)
1059 : indexSet_(indexset), size_(size),
1060 indices_(size_, static_cast<const IndexPair*>(0))
1061 {
1062 const_iterator end_ = indexSet_.end();
1063
1064 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) {
1065 assert(pair->local()<size_);
1066 indices_[pair->local()] = &(*pair);
1067 }
1068 }
1069
1070 template<class I>
1071 GlobalLookupIndexSet<I>::GlobalLookupIndexSet(const I& indexset)
1072 : indexSet_(indexset), size_(0)
1073 {
1074 const_iterator end_ = indexSet_.end();
1075 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
1076 size_=std::max(size_,static_cast<std::size_t>(pair->local()));
1077
1078 indices_.resize(++size_, 0);
1079
1080 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
1081 indices_[pair->local()] = &(*pair);
1082 }
1083
1084 template<class I>
1085 GlobalLookupIndexSet<I>::~GlobalLookupIndexSet()
1086 {}
1087
1088 template<class I>
1089 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>*
1090 GlobalLookupIndexSet<I>::pair(const std::size_t& local) const
1091 {
1092 return indices_[local];
1093 }
1094
1095 template<class I>
1096 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>&
1097 GlobalLookupIndexSet<I>::operator[](const GlobalIndex& global) const
1098 {
1099 return indexSet_[global];
1100 }
1101
1102 template<class I>
1103 typename I::const_iterator GlobalLookupIndexSet<I>::begin() const
1104 {
1105 return indexSet_.begin();
1106 }
1107
1108 template<class I>
1109 typename I::const_iterator GlobalLookupIndexSet<I>::end() const
1110 {
1111 return indexSet_.end();
1112 }
1113
1114 template<class I>
1115 inline size_t GlobalLookupIndexSet<I>::size() const
1116 {
1117 return size_;
1118 }
1119
1120 template<class I>
1121 inline int GlobalLookupIndexSet<I>::seqNo() const
1122 {
1123 return indexSet_.seqNo();
1124 }
1125
1126 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
1127 bool operator==(const ParallelIndexSet<TG,TL,N>& idxset,
1128 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
1129 {
1130 if(idxset.size()!=idxset1.size())
1131 return false;
1132 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iter;
1133 typedef typename ParallelIndexSet<TG1,TL1,N1>::const_iterator Iter1;
1134 Iter iter=idxset.begin();
1135 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) {
1136 if(iter1->global()!=iter->global())
1137 return false;
1138 typedef typename ParallelIndexSet<TG,TL,N>::LocalIndex PI;
1139 const PI& pi=iter->local(), pi1=iter1->local();
1140
1141 if(pi!=pi1)
1142 return false;
1143 }
1144 return true;
1145 }
1146
1147 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
1148 bool operator!=(const ParallelIndexSet<TG,TL,N>& idxset,
1149 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
1150 {
1151 return !(idxset==idxset1);
1152 }
1153
1154
1155#endif // DOXYGEN
1156
1157}
1158
1159#endif // DUNE_COMMON_PARALLEL_INDEXSET_HH
Implements a random-access container that can efficiently change size (similar to std::deque)
A random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:255
A dynamically growing random access list.
Definition: arraylist.hh:62
A constant random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:368
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition: indexset.hh:507
A pair consisting of a global and local index.
Definition: indexset.hh:85
Exception indicating that the index set is not in the expected state.
Definition: indexset.hh:205
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
The iterator over the pairs.
Definition: indexset.hh:257
Manager class for the mapping between local indices and globally unique indices.
Definition: indexset.hh:218
A few common exception classes.
IndexPair & operator[](const GlobalIndex &global)
Find the index pair with a specific global id.
static constexpr int arraySize
The size of the individual arrays in the underlying ArrayList.
Definition: indexset.hh:252
void beginResize()
Indicate that the index set is to be resized.
ParallelIndexSetState
The states the index set can be in.
Definition: indexset.hh:181
void renumberLocal()
Renumbers the local index numbers.
bool exists(const GlobalIndex &global) const
Find the index pair with a specific global id.
size_t size() const
Get the total number (public and nonpublic) indices.
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition: indexset.hh:296
void add(const GlobalIndex &global)
Add an new index to the set.
const_iterator end() const
Get an iterator over the indices positioned after the last index.
const LocalIndex & local() const
Get the local index.
const IndexPair & at(const GlobalIndex &global) const
Find the index pair with a specific global id.
GlobalLookupIndexSet(const ParallelIndexSet &indexset)
Constructor.
TL LocalIndex
the type of the local index.
Definition: indexset.hh:120
int seqNo() const
Get the internal sequence number.
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.
ParallelIndexSet::const_iterator const_iterator
The iterator over the index pairs.
Definition: indexset.hh:527
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
const ParallelIndexSetState & state()
Get the state the index set is in.
Definition: indexset.hh:307
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
IndexPair()
Construct a new Pair.
I ParallelIndexSet
The type of the index set.
Definition: indexset.hh:512
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition: indexset.hh:239
void markAsDeleted(const iterator &position)
Mark an index as deleted.
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: indexset.hh:517
IndexPair(const GlobalIndex &global, const LocalIndex &local)
Constructs a new Pair.
void setLocal(int index)
Set the local index.
const GlobalIndex & global() const
Get the global index.
void add(const GlobalIndex &global, const LocalIndex &local)
Add an new index to the set.
const_iterator end() const
Get an iterator over the indices positioned after the last index.
IndexPair & at(const GlobalIndex &global)
Find the index pair with a specific global id.
ParallelIndexSet()
Constructor.
void endResize()
Indicate that the resizing finishes.
~GlobalLookupIndexSet()
Destructor.
const IndexPair * pair(const std::size_t &local) const
Get the index pair corresponding to a local index.
LocalIndex & local()
Get the local index.
size_t size() const
Get the total number (public and nonpublic) indices.
IndexPair(const GlobalIndex &global)
Constructs a new Pair.
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: indexset.hh:226
std::ostream & operator<<(std::ostream &os, const ParallelIndexSet< TG, TL, N > &indexSet)
Print an index set.
Definition: indexset.hh:643
TG GlobalIndex
the type of the global index.
Definition: indexset.hh:107
int seqNo() const
Get the internal sequence number.
GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size)
Constructor.
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: indexset.hh:522
Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair
The type of the pair stored.
Definition: indexset.hh:244
@ RESIZE
Indicates that the index set is currently being resized.
Definition: indexset.hh:190
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition: indexset.hh:186
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:638
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:684
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:661
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:238
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:706
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:260
Provides classes for use as the local index in ParallelIndexSet.
Traits classes for mapping types onto MPI_Datatype.
Dune namespace.
Definition: alignedallocator.hh:13
A traits class describing the mapping of types onto MPI_Datatypes.
Definition: mpitraits.hh:41
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)