1 #ifndef DUNE_ALU3DITERATORS_HH
2 #define DUNE_ALU3DITERATORS_HH
13 namespace ALUGridSpace
20 template<
int codim,
class Comm >
24 typedef typename AccessIterator< HElementType >::Handle
IteratorType;
30 template<
int codim,
class Comm >
33 template<
class Comm >
39 template<
class Comm >
45 template<
class Comm >
51 template<
class Comm >
61 template<
class val_t >
63 :
public IteratorSTI< val_t >
68 virtual int size () = 0;
69 virtual void next () = 0;
70 virtual void first() = 0;
71 virtual int done ()
const = 0;
72 virtual val_t &
item ()
const = 0;
73 virtual IteratorSTI< val_t > *
clone ()
const { assert(
false); abort();
return 0; }
79 template<
int codim,
class Comm >
84 typedef pair< ElType *, HBndSegType * >
val_t;
87 template<
int codim, PartitionIteratorType pitype,
class Comm >
91 template< PartitionIteratorType pitype,
class Comm >
97 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
107 template<
class Gr
idImp >
109 : it_( grid.myGrid(), level ),
110 elem_( (ElType *)0, (HBndSegType *)0 )
115 : it_( org.it_ ), elem_(org.elem_)
119 int size () {
return it_->size(); }
122 int done ()
const {
return it_->done(); }
126 elem_.first = & it_->item();
132 template< PartitionIteratorType pitype,
class Comm >
138 #ifdef ALUGRID_PERIODIC_BOUNDARY
139 typedef ALU3DSPACE any_has_level_periodic< ElType > StopRule_t;
140 typedef GridIterator< ElType, StopRule_t > IteratorType;
142 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
153 template<
class Gr
idImp >
155 #ifdef ALUGRID_PERIODIC_BOUNDARY
156 : it_( grid.myGrid(), StopRule_t(level) ),
158 : it_( grid.myGrid(), level ),
160 elem_( (ElType *)0, (HBndSegType*)0 )
165 : it_( org.it_ ), elem_(org.elem_)
168 int size () {
return it_->size(); }
171 int done ()
const {
return it_->done(); }
175 elem_.first = & it_->item();
183 template< PartitionIteratorType pitype,
class Comm >
202 template<
class Gr
idImp >
204 : vxList_ ( grid.getVertexList( level ) ),
206 size_( vxList_.size() ),
207 elem_( (ElType *)0, (HBndSegType *)0 )
209 assert( vxList_.up2Date() );
214 : vxList_(org.vxList_) , count_(org.count_) , size_(org.size_)
225 if( done () ) return ;
231 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
235 elem_.first = vxList_.getItemList()[count_];
236 assert( elem_.first );
241 template<
int codim, PartitionIteratorType pitype,
class Comm >
250 template< PartitionIteratorType pitype,
class Comm >
256 typedef LeafIterator< ElType > IteratorType;
269 template<
class Gr
idImp >
271 : it_( grid.myGrid() ),
272 elem_( (ElType *)0, (HBndSegType *)0 )
277 : it_( org.it_ ), elem_(org.elem_)
280 int size () {
return it_->size(); }
283 int done ()
const {
return it_->done(); }
287 elem_.first = & it_->item();
292 template<
class ElType, PartitionIteratorType pitype,
class Comm >
301 #if ALU3DGRID_PARALLEL
302 template<
class ElType >
305 typedef is_interior_leaf_entity< ElType >
StopRule_t;
307 #endif // #if ALU3DGRID_PARALLEL
310 template< PartitionIteratorType pitype,
class Comm >
317 typedef GridIterator< ElType, StopRule_t > IteratorType;
328 template<
class Gr
idImp >
330 : it_( grid.myGrid(), StopRule_t() ),
331 elem_( (ElType *)0, (HBndSegType *)0 )
336 : it_( org.it_ ), elem_(org.elem_) {}
342 int size () {
return it_->size(); }
345 int done ()
const {
return it_->done(); }
349 elem_.first = & it_->item();
354 template< PartitionIteratorType pitype,
class Comm >
361 typedef GridIterator< ElType, StopRule_t > IteratorType;
374 template<
class Gr
idImp >
376 : it_( grid.myGrid(), StopRule_t() ),
377 elem_( (ElType *)0, (HBndSegType *)0 )
382 : it_( org.it_ ), elem_(org.elem_) {}
384 int size () {
return it_->size(); }
387 int done ()
const {
return it_->done(); }
391 elem_.first = & it_->item();
398 template< PartitionIteratorType pitype,
class Comm >
421 template<
class Gr
idImp >
423 : vxList_( grid.getLeafVertexList() ),
425 size_( vxList_.size() ),
426 elem_( (ElType *)0, (HBndSegType *)0 ),
429 assert( vxList_.up2Date() );
434 : vxList_(org.vxList_)
435 , count_(org.count_) , size_(org.size_)
457 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
461 assert( elem_.first );
465 val_t & getItem ()
const
469 elem_.first = vxList_.getItemList()[count_].first;
474 if( done() ) return ;
475 if( getItem().first == 0)
482 assert( elem_.first );
483 if(! rule_( elem_.first ) )
543 #if ALU3DGRID_PARALLEL
544 template<
int codim >
545 class LeafLevelIteratorTTProxy
552 typedef IteratorSTI< ElType > IteratorType;
553 IteratorType * inner_;
554 IteratorType * outer_;
558 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link )
560 pair < IteratorSTI< ElType > * , IteratorSTI< ElType > * >
561 p = gitter.leafBorderIteratorTT( (ElType *) 0 , link );
568 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link ,
int level )
570 pair < IteratorSTI< ElType > * , IteratorSTI< ElType > * >
571 p = gitter.levelBorderIteratorTT( (ElType *) 0 , link , level );
577 LeafLevelIteratorTTProxy(
const LeafLevelIteratorTTProxy & org )
578 : inner_(org.inner_->clone())
579 , outer_(org.outer_->clone())
582 ~LeafLevelIteratorTTProxy()
588 IteratorType & inner () { assert(inner_);
return *inner_; }
589 IteratorType & outer () { assert(outer_);
return *outer_; }
601 class ALU3dGridGhostIterator
602 :
public IteratorWrapperInterface< LeafValType >
611 GitterImplType & gitter_;
616 typedef LeafLevelIteratorTTProxy< 1 > IteratorType;
618 IteratorType * iterTT_;
620 typedef IteratorSTI < ElType > InnerIteratorType;
621 InnerIteratorType * it_;
631 typedef LeafValType val_t;
636 typedef ElementPllXIF_t ItemType;
638 template<
class Gr
idImp >
639 ALU3dGridGhostIterator (
const GridImp &grid,
int level,
const int nlinks )
640 : gitter_( grid.myGrid() ),
645 elem_( (HElementType *)0, (HBndSegType *)0 )
648 ALU3dGridGhostIterator (
const ALU3dGridGhostIterator & org)
649 : gitter_(org.gitter_)
650 , iterTT_(0) , it_(0)
658 iterTT_ =
new IteratorType ( *org.iterTT_ );
659 usingInner_ = org.usingInner_;
662 assert( ! org.it_->done() );
663 it_ = (usingInner_) ? &( iterTT_->inner() ) : &( iterTT_->outer() );
668 ~ALU3dGridGhostIterator ()
674 virtual IteratorType * newIterator()
676 return new IteratorType ( gitter_, link_ );
679 void removeIterators()
681 if(iterTT_)
delete iterTT_;
687 void createIterator()
689 if (usingInner_) checkInnerOuter();
698 iterTT_ = newIterator();
701 if (!it_) createIterator();
706 void checkInnerOuter()
712 it_ = &( iterTT_->inner() );
713 InnerIteratorType & it = iterTT_->inner();
718 pair < ElementPllXIF_t *, int > p = it.item ().accessPllX ().accessOuterPllX () ;
719 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
720 p.first->getAttachedElement(elems);
722 assert( elems.first || elems.second );
732 InnerIteratorType & out = iterTT_->outer();
736 pair < ElementPllXIF_t *, int > p = out.item ().accessPllX ().accessOuterPllX () ;
737 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
738 p.first->getAttachedElement(elems);
740 assert( elems.second );
748 virtual void checkLeafEntity ()
755 HBndSegType * pll = el.second;
760 if ( ! pll->isLeafEntity() ) next();
783 if( !it_->done() ) it_->next();
786 if( it_->done() ) createIterator();
799 if( it_ ) assert( !it_->done());
804 assert( (link_ >= nl_) ? (it_ == 0) : 1 );
805 return ((link_ >= nl_ || !it_ ) ? 1 : 0);
808 val_t & item ()
const
811 pair < ElementPllXIF_t *, int > p = it_->item ().accessPllX ().accessOuterPllX () ;
812 pair < HElementType * , HBndSegType * > p2;
813 p.first->getAttachedElement(p2);
815 elem_.second = p2.second;
824 class ALU3dGridLeafIteratorWrapper< 0, Dune::
Ghost_Partition, MPI_Comm >
825 :
public ALU3dGridGhostIterator
828 typedef LeafLevelIteratorTTProxy<1> IteratorType;
829 IteratorType * newIterator()
831 return new IteratorType ( this->gitter_, this->link_ );
834 void checkLeafEntity ()
838 if(! this->it_->done())
840 val_t & el = this->item();
841 HBndSegType * pll = el.second;
846 if ( ! pll->isLeafEntity() ) this->next();
852 template <
class Gr
idImp>
853 ALU3dGridLeafIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
854 : ALU3dGridGhostIterator(grid,level,nlinks) {}
856 ALU3dGridLeafIteratorWrapper(
const ALU3dGridLeafIteratorWrapper & org)
857 : ALU3dGridGhostIterator(org) {}
862 class ALU3dGridLevelIteratorWrapper< 0, Dune::
Ghost_Partition, MPI_Comm >
863 :
public ALU3dGridGhostIterator
868 typedef LeafLevelIteratorTTProxy<1> IteratorType;
869 IteratorType * newIterator()
872 return new IteratorType ( this->gitter_, this->link_ , level_ );
876 void checkLeafEntity ()
880 if(! this->it_->done())
882 val_t & el = this->item();
885 HBndSegType & pll = *(el.second);
892 if( pll.ghostLevel() != level_ ) this->next();
899 template <
class Gr
idImp>
900 ALU3dGridLevelIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
901 : ALU3dGridGhostIterator(grid,level,nlinks)
902 , level_(level) , mxl_(grid.maxLevel()){}
904 ALU3dGridLevelIteratorWrapper(
const ALU3dGridLevelIteratorWrapper & org)
905 : ALU3dGridGhostIterator(org) , level_(org.level_) , mxl_(org.mxl_){}
913 template<
class Gr
idImp,
int cd >
916 template<
class Gr
idImp >
917 struct GetItem< GridImp, 1 >
920 enum { elType = GridImp::elementType };
922 typedef typename GridImp::MPICommunicatorType Comm;
930 return el.myhface3( i );
935 return el.myhface4( i );
938 static ItemType *getItem ( HElementType &el,
int i )
940 return getItemFromEl( static_cast< GEOElementType & >( el ), i );
943 static int numItems ()
949 template<
class Gr
idImp >
950 struct GetItem< GridImp, 2 >
953 enum { elType = GridImp::elementType };
955 typedef typename GridImp::MPICommunicatorType Comm;
961 static ItemType *getItem ( HElementType &el,
int i )
963 return static_cast< GEOElementType &
>( el ).myhedge1( i );
966 static int numItems ()
972 template<
class Gr
idImp >
973 struct GetItem< GridImp, 3 >
976 enum { elType = GridImp::elementType };
978 typedef typename GridImp::MPICommunicatorType Comm;
984 static ItemType *getItem ( HElementType &el,
int i )
986 return static_cast< GEOElementType &
>( el ).myvertex( i );
989 static int numItems ()
997 template<
int codim >
998 class ALU3dGridGhostIteratorHigherCodim
999 :
public IteratorWrapperInterface< typename IteratorElType< codim, MPI_Comm >::val_t >
1005 typedef typename IteratorElType< codim, MPI_Comm >::ElType ElType;
1006 typedef typename IteratorElType< codim, MPI_Comm >::val_t val_t;
1009 template< Dune::ALU3dGr
idElementType elType,
int cd >
1010 struct SelectVector;
1012 template< Dune::ALU3dGr
idElementType elType >
1013 struct SelectVector< elType, 1 >
1017 static const vector< int > &getNotOnItemVector (
int face )
1019 return GEOElementType::facesNotOnFace( face );
1023 template< Dune::ALU3dGr
idElementType elType >
1024 struct SelectVector< elType, 2 >
1027 static const vector< int > &getNotOnItemVector(
int face )
1029 return GEOElementType::edgesNotOnFace( face );
1033 template< Dune::ALU3dGr
idElementType elType >
1034 struct SelectVector< elType, 3 >
1037 static const vector< int > &getNotOnItemVector (
int face )
1039 return GEOElementType::verticesNotOnFace( face );
1043 typedef ElType *getItemFunc_t ( HElementType &el,
int i );
1047 GhostItemListType &ghList_;
1048 typedef typename GhostItemListType :: IteratorType IteratorType;
1051 mutable val_t elem_;
1055 template<
class GhostElementIteratorImp,
class Gr
idImp >
1056 ALU3dGridGhostIteratorHigherCodim ( GhostElementIteratorImp *,
const GridImp &grid,
1057 int level,
const int nlinks, GhostItemListType &ghList )
1058 : ghList_( ghList ),
1059 elem_( (ElType *)0, (HBndSegType *)0 ),
1062 if( ! ghList_.up2Date() )
1064 GhostElementIteratorImp ghostIter(grid,level,nlinks);
1065 updateGhostList(grid,ghostIter,ghList_);
1069 ALU3dGridGhostIteratorHigherCodim(
const ALU3dGridGhostIteratorHigherCodim & org)
1070 : ghList_( org.ghList_ )
1072 , count_(org.count_)
1075 int size () {
return ghList_.getItemList().size(); }
1076 void first() { count_ = 0; }
1077 void next () { ++count_; }
1078 int done ()
const {
return (count_ >= (
int) ghList_.getItemList().size() ? 1 : 0); }
1079 val_t & item ()
const
1082 void * item = ghList_.getItemList()[count_];
1083 elem_.first = ((ElType * ) item);
1084 assert( elem_.first );
1089 template <
class Gr
idImp,
class GhostElementIteratorImp>
1090 void updateGhostList(
const GridImp & grid, GhostElementIteratorImp & ghostIter, GhostItemListType & ghList)
1093 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1098 const int numItems = SelectVector<GridImp::elementType,codim>::getNotOnItemVector(0).size();
1099 const int maxSize = numItems * count;
1101 ghList.getItemList().reserve(maxSize);
1102 ghList.getItemList().resize(0);
1103 map< int , int > visited;
1105 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1107 GhostPairType ghPair = ghostIter.item().second->getGhost();
1108 const vector<int> & notOnFace = SelectVector<GridImp::elementType,codim>::
1109 getNotOnItemVector(ghPair.second);
1110 for(
int i=0; i<numItems; ++i)
1112 ElType * item = GetItem<GridImp,codim>::getItem( *(ghPair.first) , notOnFace[i] );
1113 int idx = item->getIndex();
1114 if( visited.find(idx) == visited.end() )
1116 ghList.getItemList().push_back( (
void *) item );
1121 ghList.markAsUp2Date();
1127 class ALU3dGridLeafIteratorWrapper< 1, Dune::
Ghost_Partition, MPI_Comm >
1128 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1131 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1134 template <
class Gr
idImp>
1135 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1136 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1138 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1139 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1144 class ALU3dGridLeafIteratorWrapper< 2, Dune::
Ghost_Partition, MPI_Comm >
1145 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1148 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1151 template <
class Gr
idImp>
1152 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1153 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1155 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1156 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1161 class ALU3dGridLeafIteratorWrapper< 3, Dune::
Ghost_Partition, MPI_Comm >
1162 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
1165 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1168 template <
class Gr
idImp>
1169 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1170 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1172 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1173 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1178 class ALU3dGridLevelIteratorWrapper< 1, Dune::
Ghost_Partition, MPI_Comm >
1179 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1182 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1185 template <
class Gr
idImp>
1186 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1187 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1189 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1190 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1195 class ALU3dGridLevelIteratorWrapper< 2, Dune::
Ghost_Partition, MPI_Comm >
1196 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1199 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1202 template <
class Gr
idImp>
1203 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1204 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1206 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1207 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1212 class ALU3dGridLevelIteratorWrapper< 3, Dune::
Ghost_Partition, MPI_Comm >
1213 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
1216 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1219 template <
class Gr
idImp>
1220 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1221 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1223 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1224 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1229 class ALU3dGridLeafIteratorWrapper< 0, Dune::
All_Partition, MPI_Comm >
1230 :
public IteratorWrapperInterface< IteratorElType< 0, MPI_Comm >::val_t >
1233 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1234 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1237 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1239 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1244 template <
class Gr
idImp>
1245 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1246 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1247 GhostIteratorType ( grid, level, nlinks ) )
1251 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1252 : iter_ (org.iter_) {}
1254 int size () {
return iter_.size(); }
1255 void next () { iter_.next(); }
1256 void first() { iter_.first(); }
1257 int done ()
const {
return iter_.done(); }
1258 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1263 class ALU3dGridLeafIteratorWrapper< 1, Dune::
All_Partition, MPI_Comm >
1264 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1267 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1268 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1271 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1273 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1278 template <
class Gr
idImp>
1279 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1280 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1281 GhostIteratorType ( grid, level, nlinks ) )
1285 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1286 : iter_ (org.iter_) {}
1288 int size () {
return iter_.size(); }
1289 void next () { iter_.next(); }
1290 void first() { iter_.first(); }
1291 int done ()
const {
return iter_.done(); }
1292 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1297 class ALU3dGridLeafIteratorWrapper< 2, Dune::
All_Partition, MPI_Comm >
1298 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1301 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1302 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1305 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1307 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1312 template <
class Gr
idImp>
1313 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1314 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1315 GhostIteratorType ( grid, level, nlinks ) )
1319 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1320 : iter_ (org.iter_) {}
1322 int size () {
return iter_.size(); }
1323 void next () { iter_.next(); }
1324 void first() { iter_.first(); }
1325 int done ()
const {
return iter_.done(); }
1326 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1331 class ALU3dGridLeafIteratorWrapper< 3, Dune::
All_Partition, MPI_Comm >
1332 :
public IteratorWrapperInterface< IteratorElType< 3, MPI_Comm >::val_t >
1335 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1336 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1339 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1341 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1346 template <
class Gr
idImp>
1347 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1348 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1349 GhostIteratorType ( grid, level, nlinks ) )
1353 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1354 : iter_ (org.iter_) {}
1356 int size () {
return iter_.size(); }
1357 void next () { iter_.next(); }
1358 void first() { iter_.first(); }
1359 int done ()
const {
return iter_.done(); }
1360 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1365 class ALU3dGridLevelIteratorWrapper< 0, Dune::
All_Partition, MPI_Comm >
1366 :
public IteratorWrapperInterface< LeafValType >
1368 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1369 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1372 typedef LeafValType val_t;
1374 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1379 template <
class Gr
idImp>
1380 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1381 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1382 GhostIteratorType ( grid, level, nlinks ) )
1386 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org)
1387 : iter_(org.iter_) {}
1389 int size () {
return iter_.size(); }
1390 void next () { iter_.next(); }
1391 void first() { iter_.first(); }
1392 int done ()
const {
return iter_.done(); }
1393 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1395 #endif // #if ALU3DGRID_PARALLEL
1399 template< PartitionIteratorType pitype,
class Comm >
1411 mutable val_t elem_;
1422 template<
class Gr
idImp >
1426 edgeList_( grid.getEdgeList( level ) ),
1429 if( ! edgeList_.up2Date() )
1430 updateEdgeList(grid,level,nlinks);
1436 , level_(org.level_)
1437 , edgeList_( org.edgeList_ )
1438 , count_(org.count_)
1442 int size () {
return edgeList_.getItemList().size(); }
1453 int done ()
const {
return ((count_ >= edgeList_.size()) ? 1: 0); }
1457 assert( ! done () );
1458 elem_.first = ( (
ElType *) edgeList_.getItemList()[count_]);
1460 assert( elem_.first );
1465 template <
class Gr
idImp>
1466 void updateEdgeList(
const GridImp & grid,
int level,
int nlinks)
1469 typedef typename ElementLevelIterator :: val_t el_val_t;
1470 ElementLevelIterator iter(grid,level,nlinks);
1472 edgeList_.getItemList().resize(0);
1473 map < int , int > visited;
1475 for( iter.first(); ! iter.done(); iter.next() )
1480 GEOElementType *elem = 0;
1481 el_val_t & item = iter.item();
1484 elem =
static_cast< GEOElementType *
> (item.first);
1485 else if( item.second )
1486 elem =
static_cast< GEOElementType *
> (item.second->getGhost().first);
1489 for(
int e=0; e<numEdges; ++e)
1491 ElType * edge = elem->myhedge1(e);
1492 if( edge->isGhost() )
continue;
1494 int idx = edge->getIndex();
1495 if( visited.find(idx) == visited.end() )
1497 edgeList_.getItemList().push_back( (
void *) edge );
1502 edgeList_.markAsUp2Date();
1506 #if ALU3DGRID_PARALLEL
1509 class ALU3dGridLevelIteratorWrapper< 1, Dune::
All_Partition, MPI_Comm >
1510 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1513 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1514 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1517 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1519 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1524 template <
class Gr
idImp>
1525 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1526 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1527 GhostIteratorType ( grid, level, nlinks ) )
1531 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1532 : iter_ (org.iter_) {}
1534 int size () {
return iter_.size(); }
1535 void next () { iter_.next(); }
1536 void first() { iter_.first(); }
1537 int done ()
const {
return iter_.done(); }
1538 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1543 class ALU3dGridLevelIteratorWrapper< 2, Dune::
All_Partition, MPI_Comm >
1544 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1547 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1548 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1551 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1553 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1558 template <
class Gr
idImp>
1559 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1560 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1561 GhostIteratorType ( grid, level, nlinks ) )
1565 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1566 : iter_ (org.iter_) {}
1568 int size () {
return iter_.size(); }
1569 void next () { iter_.next(); }
1570 void first() { iter_.first(); }
1571 int done ()
const {
return iter_.done(); }
1572 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1577 class ALU3dGridLevelIteratorWrapper< 3, Dune::
All_Partition, MPI_Comm >
1578 :
public IteratorWrapperInterface < IteratorElType< 3, MPI_Comm >::val_t >
1581 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1582 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1585 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1587 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1592 template <
class Gr
idImp>
1593 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1594 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1595 GhostIteratorType ( grid, level, nlinks ) )
1599 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1600 : iter_ (org.iter_) {}
1602 int size () {
return iter_.size(); }
1603 void next () { iter_.next(); }
1604 void first() { iter_.first(); }
1605 int done ()
const {
return iter_.done(); }
1606 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1608 #endif // #if ALU3DGRID_PARALLEL
1612 #endif // #ifndef DUNE_ALU3DITERATORS_HH