dune-common  2.6-git
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 #ifndef DUNE_INDEXSET_HH
4 #define DUNE_INDEXSET_HH
5 
6 #include <algorithm>
9 #include <dune/common/unused.hh>
10 #include <iostream>
11 
12 #include "localindex.hh"
13 
14 #include <stdint.h> // for uint32_t
15 
16 namespace Dune
17 {
27  // forward declarations
28 
29  template<class TG, class TL>
30  class IndexPair;
31 
37  template<class TG, class TL>
38  std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair);
39 
40  template<class TG, class TL>
41  bool operator==(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
42 
43  template<class TG, class TL>
44  bool operator!=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
45 
46  template<class TG, class TL>
47  bool operator<(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
48 
49  template<class TG, class TL>
50  bool operator>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
51 
52  template<class TG, class TL>
53  bool operator<=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
54 
55  template<class TG, class TL>
56  bool operator >=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
57 
58  template<class TG, class TL>
59  bool operator==(const IndexPair<TG,TL>&, const TG&);
60 
61  template<class TG, class TL>
62  bool operator!=(const IndexPair<TG,TL>&, const TG&);
63 
64  template<class TG, class TL>
65  bool operator<(const IndexPair<TG,TL>&, const TG&);
66 
67  template<class TG, class TL>
68  bool operator>(const IndexPair<TG,TL>&, const TG&);
69 
70  template<class TG, class TL>
71  bool operator<=(const IndexPair<TG,TL>&, const TG&);
72 
73  template<class TG, class TL>
74  bool operator >=(const IndexPair<TG,TL>&, const TG&);
75 
76  template<typename T>
77  struct MPITraits;
78 
82  template<class TG, class TL>
83  class IndexPair
84  {
85  friend std::ostream& operator<<<>(std::ostream&, const IndexPair<TG,TL>&);
86  friend bool operator==<>(const IndexPair<TG,TL>&, 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 TG &);
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 struct MPITraits<IndexPair<TG,TL> >;
99 
100  public:
106  typedef TG GlobalIndex;
107 
119  typedef TL LocalIndex;
120 
127  IndexPair(const GlobalIndex& global, const LocalIndex& local);
128 
132  IndexPair();
139  IndexPair(const GlobalIndex& global);
140 
146  inline const GlobalIndex& global() const;
147 
153  inline LocalIndex& local();
154 
160  inline const LocalIndex& local() const;
161 
167  inline void setLocal(int index);
168  private:
170  GlobalIndex global_;
172  LocalIndex local_;
173  };
174 
180  {
199  };
200 
205 
206  // Forward declaration
207  template<class I> class GlobalLookupIndexSet;
208 
215  template<typename TG, typename TL, int N=100>
217  {
218  friend class GlobalLookupIndexSet<ParallelIndexSet<TG,TL,N> >;
219 
220  public:
225  typedef TG GlobalIndex;
226 
238  typedef TL LocalIndex;
239 
244 
245  enum {
252  arraySize= (N>0) ? N : 1
253  };
254 
256  class iterator :
257  public ArrayList<IndexPair,N>::iterator
258  {
259  typedef typename ArrayList<IndexPair,N>::iterator
260  Father;
261  friend class ParallelIndexSet<GlobalIndex,LocalIndex,N>;
262  public:
263  iterator(ParallelIndexSet<TG,TL,N>& indexSet, const Father& father)
264  : Father(father), indexSet_(&indexSet)
265  {}
266 
267  iterator(const iterator& other)
268  : Father(other), indexSet_(other.indexSet_)
269  {}
270 
271  iterator& operator==(const iterator& other)
272  {
273  Father::operator==(other);
274  indexSet_ = other.indexSet_;
275  }
276 
277  private:
287  inline void markAsDeleted() const
288  {
289 #ifndef NDEBUG
290  if(indexSet_->state_ != RESIZE)
291  DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
292  <<"while in RESIZE state!");
293 #endif
294  Father::operator*().local().setState(DELETED);
295  }
296 
298  ParallelIndexSet<TG,TL,N>* indexSet_;
299 
300  };
301 
302 
303 
305  typedef typename
308 
313 
318  inline const ParallelIndexSetState& state()
319  {
320  return state_;
321  }
322 
328  void beginResize();
329 
338  inline void add(const GlobalIndex& global);
339 
348  inline void add(const GlobalIndex& global, const LocalIndex& local);
349 
357  inline void markAsDeleted(const iterator& position);
358 
371  void endResize();
372 
383  inline IndexPair&
384  operator[](const GlobalIndex& global);
385 
395  inline IndexPair&
396  at(const GlobalIndex& global);
397 
408  inline const IndexPair&
409  operator[](const GlobalIndex& global) const;
410 
420  inline const IndexPair&
421  at(const GlobalIndex& global) const;
422 
427  inline iterator begin();
428 
433  inline iterator end();
434 
439  inline const_iterator begin() const;
440 
445  inline const_iterator end() const;
446 
456  inline void renumberLocal();
457 
464  inline int seqNo() const;
465 
470  inline size_t size() const;
471 
472  private:
474  ArrayList<IndexPair,N> localIndices_;
476  ArrayList<IndexPair,N> newIndices_;
478  ParallelIndexSetState state_;
480  int seqNo_;
482  bool deletedEntries_;
487  inline void merge();
488  };
489 
490 
496  template<class TG, class TL, int N>
497  std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet);
498 
504  template<class I>
506  {
507  public:
511  typedef I ParallelIndexSet;
512 
517 
522 
527 
529 
536  GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size);
537 
543  GlobalLookupIndexSet(const ParallelIndexSet& indexset);
544 
549 
559  inline const IndexPair&
560  operator[](const GlobalIndex& global) const;
561 
565  inline const IndexPair*
566  pair(const std::size_t& local) const;
567 
572  inline const_iterator begin() const;
573 
578  inline const_iterator end() const;
579 
586  inline int seqNo() const;
587 
592  inline size_t size() const;
593  private:
597  const ParallelIndexSet& indexSet_;
598 
602  std::size_t size_;
603 
607  std::vector<const IndexPair*> indices_;
608 
609  };
610 
611 
612  template<typename T>
614  {
615  static bool compare(const T& t1, const T& t2){
618  return false;
619  }
620  };
621 
622  template<class TG, class TL>
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() &&
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>
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)
764  {}
765 
766  template<class TG, class TL, int N>
768  {
769 
770  // Checks in unproductive code
771 #ifndef NDEBUG
772  if(state_!=GROUND)
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  typedef typename ArrayList<IndexPair,N>::iterator iterator;
847  typedef typename ArrayList<IndexPair,N>::const_iterator const_iterator;
848 
849  iterator old=localIndices_.begin();
850  iterator added=newIndices_.begin();
851  const const_iterator endold=localIndices_.end();
852  const const_iterator endadded=newIndices_.end();
853 
854  while(old != endold && added!= endadded)
855  {
856  if(old->local().state()==DELETED) {
857  old.eraseToHere();
858  }
859  else
860  {
861  if(old->global() < added->global() ||
862  (old->global() == added->global()
863  && LocalIndexComparator<TL>::compare(old->local(),added->local())))
864  {
865  tempPairs.push_back(*old);
866  old.eraseToHere();
867  continue;
868  }else
869  {
870  tempPairs.push_back(*added);
871  added.eraseToHere();
872  }
873  }
874  }
875 
876  while(old != endold)
877  {
878  if(old->local().state()!=DELETED) {
879  tempPairs.push_back(*old);
880  }
881  old.eraseToHere();
882  }
883 
884  while(added!= endadded)
885  {
886  tempPairs.push_back(*added);
887  added.eraseToHere();
888  }
889  localIndices_ = tempPairs;
890  }
891  }
892 
893 
894  template<class TG, class TL, int N>
895  inline const IndexPair<TG,TL>&
896  ParallelIndexSet<TG,TL,N>::at(const TG& global) const
897  {
898  // perform a binary search
899  int low=0, high=localIndices_.size()-1, probe=-1;
900 
901  while(low<high)
902  {
903  probe = (high + low) / 2;
904  if(global <= localIndices_[probe].global())
905  high = probe;
906  else
907  low = probe+1;
908  }
909 
910  if(probe==-1)
911  DUNE_THROW(RangeError, "No entries!");
912 
913  if( localIndices_[low].global() != global)
914  DUNE_THROW(RangeError, "Could not find entry of "<<global);
915  else
916  return localIndices_[low];
917  }
918 
919  template<class TG, class TL, int N>
920  inline const IndexPair<TG,TL>&
921  ParallelIndexSet<TG,TL,N>::operator[](const TG& global) const
922  {
923  // perform a binary search
924  int low=0, high=localIndices_.size()-1, probe=-1;
925 
926  while(low<high)
927  {
928  probe = (high + low) / 2;
929  if(global <= localIndices_[probe].global())
930  high = probe;
931  else
932  low = probe+1;
933  }
934 
935  return localIndices_[low];
936  }
937  template<class TG, class TL, int N>
938  inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::at(const TG& global)
939  {
940  // perform a binary search
941  int low=0, high=localIndices_.size()-1, probe=-1;
942 
943  while(low<high)
944  {
945  probe = (high + low) / 2;
946  if(localIndices_[probe].global() >= global)
947  high = probe;
948  else
949  low = probe+1;
950  }
951 
952  if(probe==-1)
953  DUNE_THROW(RangeError, "No entries!");
954 
955  if( localIndices_[low].global() != global)
956  DUNE_THROW(RangeError, "Could not find entry of "<<global);
957  else
958  return localIndices_[low];
959  }
960 
961  template<class TG, class TL, int N>
963  {
964  // perform a binary search
965  int low=0, high=localIndices_.size()-1, probe=-1;
966 
967  while(low<high)
968  {
969  probe = (high + low) / 2;
970  if(localIndices_[probe].global() >= global)
971  high = probe;
972  else
973  low = probe+1;
974  }
975 
976  return localIndices_[low];
977  }
978  template<class TG, class TL, int N>
981  {
982  return iterator(*this, localIndices_.begin());
983  }
984 
985 
986  template<class TG, class TL, int N>
989  {
990  return iterator(*this,localIndices_.end());
991  }
992 
993  template<class TG, class TL, int N>
996  {
997  return localIndices_.begin();
998  }
999 
1000 
1001  template<class TG, class TL, int N>
1004  {
1005  return localIndices_.end();
1006  }
1007 
1008  template<class TG, class TL, int N>
1010 #ifndef NDEBUG
1011  if(state_==RESIZE)
1012  DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in "
1013  <<"GROUND state for renumberLocal()");
1014 #endif
1015 
1016  typedef typename ArrayList<IndexPair,N>::iterator iterator;
1017  const const_iterator end_ = end();
1018  uint32_t index=0;
1019 
1020  for(iterator pair=begin(); pair!=end_; index++, ++pair)
1021  pair->local()=index;
1022  }
1023 
1024  template<class TG, class TL, int N>
1025  inline int ParallelIndexSet<TG,TL,N>::seqNo() const
1026  {
1027  return seqNo_;
1028  }
1029 
1030  template<class TG, class TL, int N>
1031  inline size_t ParallelIndexSet<TG,TL,N>::size() const
1032  {
1033  return localIndices_.size();
1034  }
1035 
1036  template<class I>
1038  std::size_t size)
1039  : indexSet_(indexset), size_(size),
1040  indices_(size_, static_cast<const IndexPair*>(0))
1041  {
1042  const_iterator end_ = indexSet_.end();
1043 
1044  for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) {
1045  assert(pair->local()<size_);
1046  indices_[pair->local()] = &(*pair);
1047  }
1048  }
1049 
1050  template<class I>
1052  : indexSet_(indexset), size_(0)
1053  {
1054  const_iterator end_ = indexSet_.end();
1055  for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
1056  size_=std::max(size_,static_cast<std::size_t>(pair->local()));
1057 
1058  indices_.resize(++size_, 0);
1059 
1060  for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
1061  indices_[pair->local()] = &(*pair);
1062  }
1063 
1064  template<class I>
1066  {}
1067 
1068  template<class I>
1070  GlobalLookupIndexSet<I>::pair(const std::size_t& local) const
1071  {
1072  return indices_[local];
1073  }
1074 
1075  template<class I>
1078  {
1079  return indexSet_[global];
1080  }
1081 
1082  template<class I>
1083  typename I::const_iterator GlobalLookupIndexSet<I>::begin() const
1084  {
1085  return indexSet_.begin();
1086  }
1087 
1088  template<class I>
1089  typename I::const_iterator GlobalLookupIndexSet<I>::end() const
1090  {
1091  return indexSet_.end();
1092  }
1093 
1094  template<class I>
1095  inline size_t GlobalLookupIndexSet<I>::size() const
1096  {
1097  return size_;
1098  }
1099 
1100  template<class I>
1101  inline int GlobalLookupIndexSet<I>::seqNo() const
1102  {
1103  return indexSet_.seqNo();
1104  }
1105 
1106  template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
1107  bool operator==(const ParallelIndexSet<TG,TL,N>& idxset,
1108  const ParallelIndexSet<TG1,TL1,N1>& idxset1)
1109  {
1110  if(idxset.size()!=idxset1.size())
1111  return false;
1112  typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iter;
1113  typedef typename ParallelIndexSet<TG1,TL1,N1>::const_iterator Iter1;
1114  Iter iter=idxset.begin();
1115  for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) {
1116  if(iter1->global()!=iter->global())
1117  return false;
1118  typedef typename ParallelIndexSet<TG,TL,N>::LocalIndex PI;
1119  const PI& pi=iter->local(), pi1=iter1->local();
1120 
1121  if(pi!=pi1)
1122  return false;
1123  }
1124  return true;
1125  }
1126 
1127  template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
1128  bool operator!=(const ParallelIndexSet<TG,TL,N>& idxset,
1129  const ParallelIndexSet<TG1,TL1,N1>& idxset1)
1130  {
1131  return !(idxset==idxset1);
1132  }
1133 
1134 
1135 #endif // DOXYGEN
1136 
1137 }
1138 #endif
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
bool operator==(const IndexPair< TG, TL > &, const TG &)
Definition: indexset.hh:692
I ParallelIndexSet
The type of the index set.
Definition: indexset.hh:511
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition: indexset.hh:307
Definition: localindex.hh:26
iterator end()
Get an iterator over the indices positioned after the last index.
void setLocal(int index)
Set the local index.
The default mode. Indicates that the index set is ready to be used.
Definition: indexset.hh:185
IndexPair & at(const GlobalIndex &global)
Find the index pair with a specific global id.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
size_t size() const
Get the total number (public and nonpublic) indices.
Dune::IndexPair< typename I::GlobalIndex, typename I::LocalIndex > IndexPair
Definition: indexset.hh:528
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: indexset.hh:225
ParallelIndexSet()
Constructor.
Manager class for the mapping between local indices and globally unique indices.
Definition: indexset.hh:216
A pair consisting of a global and local index.
Definition: indexset.hh:30
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:233
LocalIndex & local()
Get the local index.
friend bool operator>(const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
Definition: indexset.hh:674
TL LocalIndex
the type of the local index.
Definition: indexset.hh:119
GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size)
Constructor.
A dynamically growing random access list.
Definition: arraylist.hh:59
Provides classes for use as the local index in ParallelIndexSet.
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
Definition: indexset.hh:613
iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father)
Definition: indexset.hh:263
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:675
~GlobalLookupIndexSet()
Destructor.
size_t size() const
Get the total number (public and nonpublic) indices.
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition: indexset.hh:238
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:279
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:255
friend bool operator>=(const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
Definition: indexset.hh:686
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: indexset.hh:516
A few common exception classes.
const ParallelIndexSetState & state()
Get the state the index set is in.
Definition: indexset.hh:318
IndexPair()
Construct a new Pair.
Dune namespace.
Definition: alignedallocator.hh:9
void endResize()
Indicate that the resizing finishes.
Implements a random-access container that can efficiently change size (similar to std::deque) ...
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition: indexset.hh:207
Indicates that the index set is currently being resized.
Definition: indexset.hh:189
Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair
The type of the pair stored.
Definition: indexset.hh:243
const GlobalIndex & global() const
Get the global index.
void push_back(const_reference entry)
Append an entry to the list.
Definition: arraylist.hh:491
int seqNo() const
Get the internal sequence number.
A constant random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:20
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:697
The iterator over the pairs.
Definition: indexset.hh:256
Exception indicating that the index set is not in the expected state.
Definition: indexset.hh:204
iterator(const iterator &other)
Definition: indexset.hh:267
int seqNo() const
Get the internal sequence number.
bool operator()(const IndexPair< TG, TL > &i1, const IndexPair< TG, TL > &i2)
Definition: indexset.hh:625
friend bool operator==(const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
Definition: indexset.hh:656
A traits class describing the mapping of types onto MPI_Datatypes.
Definition: bigunsignedint.hh:25
iterator & operator==(const iterator &other)
Definition: indexset.hh:271
friend bool operator!=(const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
Definition: indexset.hh:662
Default exception class for range errors.
Definition: exceptions.hh:252
A random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:17
Definition: indexset.hh:623
void beginResize()
Indicate that the index set is to be resized.
ParallelIndexSetState
The states the index set can be in.
Definition: indexset.hh:179
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition: bigunsignedint.hh:543
static bool compare(const T &t1, const T &t2)
Definition: indexset.hh:615
IndexPair & operator[](const GlobalIndex &global)
Find the index pair with a specific global id.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: indexset.hh:521
const IndexPair * pair(const std::size_t &local) const
Get the index pair corresponding to a local index.
const_iterator end() const
Get an iterator over the indices positioned after the last index.
void add(const GlobalIndex &global)
Add an new index to the set.
iterator begin()
Get an iterator over the indices positioned at the first index.
void markAsDeleted(const iterator &position)
Mark an index as deleted.
ParallelIndexSet::const_iterator const_iterator
The iterator over the index pairs.
Definition: indexset.hh:526
void renumberLocal()
Renumbers the local index numbers.
TG GlobalIndex
the type of the global index.
Definition: indexset.hh:106