1 #ifndef DUNE_ALU3DITERATORS_HH
2 #define DUNE_ALU3DITERATORS_HH
13 namespace ALUGridSpace
20 template<
int codim,
class Comm >
23 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType
HElementType;
24 typedef typename AccessIterator< HElementType >::Handle
IteratorType;
30 template<
int codim,
class Comm >
31 struct ALUHElementType;
33 template<
class Comm >
34 struct ALUHElementType< 0, Comm >
36 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType
ElementType;
39 template<
class Comm >
40 struct ALUHElementType< 1, Comm >
42 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HFaceType
ElementType;
45 template<
class Comm >
46 struct ALUHElementType< 2, Comm >
48 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HEdgeType
ElementType;
51 template<
class Comm >
52 struct ALUHElementType< 3, Comm >
54 typedef typename Dune::ALU3dBasicImplTraits< Comm >::VertexType
ElementType;
61 template<
class val_t >
67 virtual int size () = 0;
68 virtual void next () = 0;
69 virtual void first() = 0;
70 virtual int done ()
const = 0;
71 virtual val_t &
item ()
const = 0;
78 template<
int codim,
class Comm >
82 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HBndSegType
HBndSegType;
83 typedef pair< ElType *, HBndSegType * >
val_t;
86 template<
int codim, PartitionIteratorType pitype,
class Comm >
87 class ALU3dGridLevelIteratorWrapper;
90 template< PartitionIteratorType pitype,
class Comm >
91 class ALU3dGridLevelIteratorWrapper< 0, pitype, Comm >
96 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
106 template<
class Gr
idImp >
107 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
108 : it_( grid.myGrid(), level ),
109 elem_( (ElType *)0, (HBndSegType *)0 )
113 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
114 : it_( org.it_ ), elem_(org.elem_)
118 int size () {
return it_->size(); }
121 int done ()
const {
return it_->done(); }
125 elem_.first = & it_->item();
131 template< PartitionIteratorType pitype,
class Comm >
132 class ALU3dGridLevelIteratorWrapper< 1, pitype, Comm >
137 #ifdef ALUGRID_PERIODIC_BOUNDARY
138 typedef ALU3DSPACE any_has_level_periodic< ElType > StopRule_t;
139 typedef GridIterator< ElType, StopRule_t > IteratorType;
141 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
152 template<
class Gr
idImp >
153 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
154 #ifdef ALUGRID_PERIODIC_BOUNDARY
155 : it_( grid.myGrid(), StopRule_t(level) ),
157 : it_( grid.myGrid(), level ),
159 elem_( (ElType *)0, (HBndSegType*)0 )
163 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
164 : it_( org.it_ ), elem_(org.elem_)
167 int size () {
return it_->size(); }
170 int done ()
const {
return it_->done(); }
174 elem_.first = & it_->item();
182 template< PartitionIteratorType pitype,
class Comm >
183 class ALU3dGridLevelIteratorWrapper< 3, pitype, Comm >
201 template<
class Gr
idImp >
202 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
203 : vxList_ ( grid.getVertexList( level ) ),
205 size_( vxList_.size() ),
206 elem_( (ElType *)0, (HBndSegType *)0 )
208 assert( vxList_.up2Date() );
212 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
213 : vxList_(org.vxList_) , count_(org.count_) , size_(org.size_)
224 if( done () ) return ;
230 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
234 elem_.first = vxList_.getItemList()[count_];
235 assert( elem_.first );
240 template<
int codim, PartitionIteratorType pitype,
class Comm >
241 class ALU3dGridLeafIteratorWrapper;
249 template< PartitionIteratorType pitype,
class Comm >
250 class ALU3dGridLeafIteratorWrapper< 0, pitype, Comm >
255 typedef LeafIterator< ElType > IteratorType;
268 template<
class Gr
idImp >
269 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int links )
270 : it_( grid.myGrid() ),
271 elem_( (ElType *)0, (HBndSegType *)0 )
275 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
276 : it_( org.it_ ), elem_(org.elem_)
279 int size () {
return it_->size(); }
282 int done ()
const {
return it_->done(); }
286 elem_.first = & it_->item();
291 template<
class ElType, PartitionIteratorType pitype,
class Comm >
300 #if ALU3DGRID_PARALLEL
301 template<
class ElType >
304 typedef is_interior_leaf_entity< ElType >
StopRule_t;
306 #endif // #if ALU3DGRID_PARALLEL
309 template< PartitionIteratorType pitype,
class Comm >
310 class ALU3dGridLeafIteratorWrapper< 1, pitype, Comm >
316 typedef GridIterator< ElType, StopRule_t > IteratorType;
327 template<
class Gr
idImp >
328 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int links )
329 : it_( grid.myGrid(), StopRule_t() ),
330 elem_( (ElType *)0, (HBndSegType *)0 )
334 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
335 : it_( org.it_ ), elem_(org.elem_) {}
337 ~ALU3dGridLeafIteratorWrapper ()
341 int size () {
return it_->size(); }
344 int done ()
const {
return it_->done(); }
348 elem_.first = & it_->item();
353 template< PartitionIteratorType pitype,
class Comm >
354 class ALU3dGridLeafIteratorWrapper< 2, pitype, Comm >
360 typedef GridIterator< ElType, StopRule_t > IteratorType;
373 template<
class Gr
idImp >
374 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int links )
375 : it_( grid.myGrid(), StopRule_t() ),
376 elem_( (ElType *)0, (HBndSegType *)0 )
380 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
381 : it_( org.it_ ), elem_(org.elem_) {}
383 int size () {
return it_->size(); }
386 int done ()
const {
return it_->done(); }
390 elem_.first = & it_->item();
397 template< PartitionIteratorType pitype,
class Comm >
398 class ALU3dGridLeafIteratorWrapper< 3, pitype, Comm >
420 template<
class Gr
idImp >
421 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
422 : vxList_( grid.getLeafVertexList() ),
424 size_( vxList_.size() ),
425 elem_( (ElType *)0, (HBndSegType *)0 ),
428 assert( vxList_.up2Date() );
432 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
433 : vxList_(org.vxList_)
434 , count_(org.count_) , size_(org.size_)
456 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
460 assert( elem_.first );
464 val_t & getItem ()
const
468 elem_.first = vxList_.getItemList()[count_].first;
473 if( done() ) return ;
474 if( getItem().first == 0)
481 assert( elem_.first );
482 if(! rule_( elem_.first ) )
542 #if ALU3DGRID_PARALLEL
543 template<
int codim >
544 class LeafLevelIteratorTTProxy
549 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::GitterImplType GitterImplType;
552 IteratorType * inner_;
553 IteratorType * outer_;
557 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link )
560 p = gitter.leafBorderIteratorTT( (ElType *) 0 , link );
567 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link ,
int level )
570 p = gitter.levelBorderIteratorTT( (ElType *) 0 , link , level );
576 LeafLevelIteratorTTProxy(
const LeafLevelIteratorTTProxy & org )
577 : inner_(org.inner_->clone())
578 , outer_(org.outer_->clone())
581 ~LeafLevelIteratorTTProxy()
587 IteratorType & inner () { assert(inner_);
return *inner_; }
588 IteratorType & outer () { assert(outer_);
return *outer_; }
600 struct ALU3dGridGhostIterator
601 :
public IteratorWrapperInterface< LeafValType >
603 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::GitterImplType GitterImplType;
605 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::HElementType HElementType;
606 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::HBndSegType HBndSegType;
609 GitterImplType & gitter_;
614 typedef LeafLevelIteratorTTProxy< 1 > IteratorType;
616 IteratorType * iterTT_;
619 InnerIteratorType * it_;
629 typedef LeafValType val_t;
634 typedef ElementPllXIF_t ItemType;
636 template<
class Gr
idImp >
637 ALU3dGridGhostIterator (
const GridImp &grid,
int level,
const int nlinks )
638 : gitter_( grid.myGrid() ),
643 elem_( (HElementType *)0, (HBndSegType *)0 )
646 ALU3dGridGhostIterator (
const ALU3dGridGhostIterator & org)
647 : gitter_(org.gitter_)
648 , iterTT_(0) , it_(0)
656 iterTT_ =
new IteratorType ( *org.iterTT_ );
657 usingInner_ = org.usingInner_;
660 assert( ! org.it_->done() );
661 it_ = (usingInner_) ? &( iterTT_->inner() ) : &( iterTT_->outer() );
666 ~ALU3dGridGhostIterator ()
672 virtual IteratorType * newIterator()
674 return new IteratorType ( gitter_, link_ );
677 void removeIterators()
679 if(iterTT_)
delete iterTT_;
685 void createIterator()
687 if (usingInner_) checkInnerOuter();
696 iterTT_ = newIterator();
699 if (!it_) createIterator();
704 void checkInnerOuter()
710 it_ = &( iterTT_->inner() );
711 InnerIteratorType & it = iterTT_->inner();
716 pair < ElementPllXIF_t *, int > p = it.item ().accessPllX ().accessOuterPllX () ;
717 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
718 p.first->getAttachedElement(elems);
720 assert( elems.first || elems.second );
730 InnerIteratorType & out = iterTT_->outer();
734 pair < ElementPllXIF_t *, int > p = out.item ().accessPllX ().accessOuterPllX () ;
735 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
736 p.first->getAttachedElement(elems);
738 assert( elems.second );
746 virtual void checkLeafEntity ()
753 HBndSegType * pll = el.second;
758 if ( ! pll->isLeafEntity() ) next();
781 if( !it_->done() ) it_->next();
784 if( it_->done() ) createIterator();
797 if( it_ ) assert( !it_->done());
802 assert( (link_ >= nl_) ? (it_ == 0) : 1 );
803 return ((link_ >= nl_ || !it_ ) ? 1 : 0);
806 val_t & item ()
const
809 pair < ElementPllXIF_t *, int > p = it_->item ().accessPllX ().accessOuterPllX () ;
810 pair < HElementType * , HBndSegType * > p2;
811 p.first->getAttachedElement(p2);
813 elem_.second = p2.second;
822 class ALU3dGridLeafIteratorWrapper< 0, Dune::
Ghost_Partition, MPI_Comm >
823 :
public ALU3dGridGhostIterator
826 typedef LeafLevelIteratorTTProxy<1> IteratorType;
827 IteratorType * newIterator()
829 return new IteratorType ( this->gitter_, this->link_ );
832 void checkLeafEntity ()
836 if(! this->it_->done())
838 val_t & el = this->item();
839 HBndSegType * pll = el.second;
844 if ( ! pll->isLeafEntity() ) this->next();
850 template <
class Gr
idImp>
851 ALU3dGridLeafIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
852 : ALU3dGridGhostIterator(grid,level,nlinks) {}
854 ALU3dGridLeafIteratorWrapper(
const ALU3dGridLeafIteratorWrapper & org)
855 : ALU3dGridGhostIterator(org) {}
860 class ALU3dGridLevelIteratorWrapper< 0, Dune::
Ghost_Partition, MPI_Comm >
861 :
public ALU3dGridGhostIterator
866 typedef LeafLevelIteratorTTProxy<1> IteratorType;
867 IteratorType * newIterator()
870 return new IteratorType ( this->gitter_, this->link_ , level_ );
874 void checkLeafEntity ()
878 if(! this->it_->done())
880 val_t & el = this->item();
883 HBndSegType & pll = *(el.second);
890 if( pll.ghostLevel() != level_ ) this->next();
897 template <
class Gr
idImp>
898 ALU3dGridLevelIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
899 : ALU3dGridGhostIterator(grid,level,nlinks)
900 , level_(level) , mxl_(grid.maxLevel()){}
902 ALU3dGridLevelIteratorWrapper(
const ALU3dGridLevelIteratorWrapper & org)
903 : ALU3dGridGhostIterator(org) , level_(org.level_) , mxl_(org.mxl_){}
911 template<
class Gr
idImp,
int cd >
914 template<
class Gr
idImp >
915 struct GetItem< GridImp, 1 >
918 enum { elType = GridImp::elementType };
920 typedef typename GridImp::MPICommunicatorType Comm;
922 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
923 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
926 static ItemType *getItemFromEl (
typename Dune::ALU3dImplTraits< Dune::tetra, Comm >::GEOElementType &el,
int i )
928 return el.myhface3( i );
931 static ItemType *getItemFromEl (
typename Dune::ALU3dImplTraits< Dune::hexa, Comm >::GEOElementType &el,
int i )
933 return el.myhface4( i );
936 static ItemType *getItem ( HElementType &el,
int i )
938 return getItemFromEl( static_cast< GEOElementType & >( el ), i );
941 static int numItems ()
947 template<
class Gr
idImp >
948 struct GetItem< GridImp, 2 >
951 enum { elType = GridImp::elementType };
953 typedef typename GridImp::MPICommunicatorType Comm;
955 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
956 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
959 static ItemType *getItem ( HElementType &el,
int i )
961 return static_cast< GEOElementType &
>( el ).myhedge1( i );
964 static int numItems ()
970 template<
class Gr
idImp >
971 struct GetItem< GridImp, 3 >
974 enum { elType = GridImp::elementType };
976 typedef typename GridImp::MPICommunicatorType Comm;
978 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
979 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
982 static ItemType *getItem ( HElementType &el,
int i )
984 return static_cast< GEOElementType &
>( el ).myvertex( i );
987 static int numItems ()
995 template<
int codim >
996 struct ALU3dGridGhostIteratorHigherCodim
997 :
public IteratorWrapperInterface< typename IteratorElType< codim, MPI_Comm >::val_t >
999 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::HElementType HElementType;
1000 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::HBndSegType HBndSegType;
1001 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::GhostPairType GhostPairType;
1002 typedef typename IteratorElType< codim, MPI_Comm >::ElType ElType;
1003 typedef typename IteratorElType< codim, MPI_Comm >::val_t val_t;
1006 template< Dune::ALU3dGr
idElementType elType,
int cd >
1007 struct SelectVector;
1009 template< Dune::ALU3dGr
idElementType elType >
1010 struct SelectVector< elType, 1 >
1012 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
1014 static const vector< int > &getNotOnItemVector (
int face )
1016 return GEOElementType::facesNotOnFace( face );
1020 template< Dune::ALU3dGr
idElementType elType >
1021 struct SelectVector< elType, 2 >
1023 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
1024 static const vector< int > &getNotOnItemVector(
int face )
1026 return GEOElementType::edgesNotOnFace( face );
1030 template< Dune::ALU3dGr
idElementType elType >
1031 struct SelectVector< elType, 3 >
1033 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
1034 static const vector< int > &getNotOnItemVector (
int face )
1036 return GEOElementType::verticesNotOnFace( face );
1040 typedef ElType *getItemFunc_t ( HElementType &el,
int i );
1044 GhostItemListType &ghList_;
1045 typedef typename GhostItemListType :: IteratorType IteratorType;
1048 mutable val_t elem_;
1052 template<
class GhostElementIteratorImp,
class Gr
idImp >
1053 ALU3dGridGhostIteratorHigherCodim ( GhostElementIteratorImp *,
const GridImp &grid,
1054 int level,
const int nlinks, GhostItemListType &ghList )
1055 : ghList_( ghList ),
1056 elem_( (ElType *)0, (HBndSegType *)0 ),
1059 if( ! ghList_.up2Date() )
1061 GhostElementIteratorImp ghostIter(grid,level,nlinks);
1062 updateGhostList(grid,ghostIter,ghList_);
1066 ALU3dGridGhostIteratorHigherCodim(
const ALU3dGridGhostIteratorHigherCodim & org)
1067 : ghList_( org.ghList_ )
1069 , count_(org.count_)
1072 int size () {
return ghList_.getItemList().size(); }
1073 void first() { count_ = 0; }
1074 void next () { ++count_; }
1075 int done ()
const {
return (count_ >= (
int) ghList_.getItemList().size() ? 1 : 0); }
1076 val_t & item ()
const
1079 void * item = ghList_.getItemList()[count_];
1080 elem_.first = ((ElType * ) item);
1081 assert( elem_.first );
1086 template <
class Gr
idImp,
class GhostElementIteratorImp>
1087 void updateGhostList(
const GridImp & grid, GhostElementIteratorImp & ghostIter, GhostItemListType & ghList)
1090 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1095 const int numItems = SelectVector<GridImp::elementType,codim>::getNotOnItemVector(0).size();
1096 const int maxSize = numItems * count;
1098 ghList.getItemList().reserve(maxSize);
1099 ghList.getItemList().resize(0);
1100 map< int , int > visited;
1102 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1104 GhostPairType ghPair = ghostIter.item().second->getGhost();
1105 const vector<int> & notOnFace = SelectVector<GridImp::elementType,codim>::
1106 getNotOnItemVector(ghPair.second);
1107 for(
int i=0; i<numItems; ++i)
1109 ElType * item = GetItem<GridImp,codim>::getItem( *(ghPair.first) , notOnFace[i] );
1110 int idx = item->getIndex();
1111 if( visited.find(idx) == visited.end() )
1113 ghList.getItemList().push_back( (
void *) item );
1118 ghList.markAsUp2Date();
1124 class ALU3dGridLeafIteratorWrapper< 1, Dune::
Ghost_Partition, MPI_Comm >
1125 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1128 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1131 template <
class Gr
idImp>
1132 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1133 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1135 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1136 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1141 class ALU3dGridLeafIteratorWrapper< 2, Dune::
Ghost_Partition, MPI_Comm >
1142 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1145 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1148 template <
class Gr
idImp>
1149 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1150 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1152 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1153 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1158 class ALU3dGridLeafIteratorWrapper< 3, Dune::
Ghost_Partition, MPI_Comm >
1159 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
1162 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1165 template <
class Gr
idImp>
1166 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1167 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1169 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1170 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1175 class ALU3dGridLevelIteratorWrapper< 1, Dune::
Ghost_Partition, MPI_Comm >
1176 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1179 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1182 template <
class Gr
idImp>
1183 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1184 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1186 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1187 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1192 class ALU3dGridLevelIteratorWrapper< 2, Dune::
Ghost_Partition, MPI_Comm >
1193 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1196 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1199 template <
class Gr
idImp>
1200 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1201 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1203 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1204 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1209 class ALU3dGridLevelIteratorWrapper< 3, Dune::
Ghost_Partition, MPI_Comm >
1210 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
1213 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1216 template <
class Gr
idImp>
1217 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1218 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *)0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1220 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1221 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1226 class ALU3dGridLeafIteratorWrapper< 0, Dune::
All_Partition, MPI_Comm >
1227 :
public IteratorWrapperInterface< IteratorElType< 0, MPI_Comm >::val_t >
1230 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1231 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1234 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1236 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1241 template <
class Gr
idImp>
1242 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1243 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1244 GhostIteratorType ( grid, level, nlinks ) )
1248 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1249 : iter_ (org.iter_) {}
1251 int size () {
return iter_.size(); }
1252 void next () { iter_.next(); }
1253 void first() { iter_.first(); }
1254 int done ()
const {
return iter_.done(); }
1255 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1260 class ALU3dGridLeafIteratorWrapper< 1, Dune::
All_Partition, MPI_Comm >
1261 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1264 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1265 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1268 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1270 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1275 template <
class Gr
idImp>
1276 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1277 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1278 GhostIteratorType ( grid, level, nlinks ) )
1282 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1283 : iter_ (org.iter_) {}
1285 int size () {
return iter_.size(); }
1286 void next () { iter_.next(); }
1287 void first() { iter_.first(); }
1288 int done ()
const {
return iter_.done(); }
1289 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1294 class ALU3dGridLeafIteratorWrapper< 2, Dune::
All_Partition, MPI_Comm >
1295 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1298 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1299 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1302 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1304 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1309 template <
class Gr
idImp>
1310 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1311 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1312 GhostIteratorType ( grid, level, nlinks ) )
1316 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1317 : iter_ (org.iter_) {}
1319 int size () {
return iter_.size(); }
1320 void next () { iter_.next(); }
1321 void first() { iter_.first(); }
1322 int done ()
const {
return iter_.done(); }
1323 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1328 class ALU3dGridLeafIteratorWrapper< 3, Dune::
All_Partition, MPI_Comm >
1329 :
public IteratorWrapperInterface< IteratorElType< 3, MPI_Comm >::val_t >
1332 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1333 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1336 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1338 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1343 template <
class Gr
idImp>
1344 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1345 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1346 GhostIteratorType ( grid, level, nlinks ) )
1350 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1351 : iter_ (org.iter_) {}
1353 int size () {
return iter_.size(); }
1354 void next () { iter_.next(); }
1355 void first() { iter_.first(); }
1356 int done ()
const {
return iter_.done(); }
1357 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1362 class ALU3dGridLevelIteratorWrapper< 0, Dune::
All_Partition, MPI_Comm >
1363 :
public IteratorWrapperInterface< LeafValType >
1365 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1366 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1369 typedef LeafValType val_t;
1371 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1376 template <
class Gr
idImp>
1377 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1378 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1379 GhostIteratorType ( grid, level, nlinks ) )
1383 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org)
1384 : iter_(org.iter_) {}
1386 int size () {
return iter_.size(); }
1387 void next () { iter_.next(); }
1388 void first() { iter_.first(); }
1389 int done ()
const {
return iter_.done(); }
1390 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1392 #endif // #if ALU3DGRID_PARALLEL
1396 template< PartitionIteratorType pitype,
class Comm >
1397 struct ALU3dGridLevelIteratorWrapper< 2, pitype, Comm >
1401 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HBndSegType
HBndSegType;
1402 typedef typename Dune::ALU3dBasicImplTraits< Comm >::GEOEdgeType
GEOEdgeType;
1407 mutable val_t elem_;
1418 template<
class Gr
idImp >
1419 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
1422 edgeList_( grid.getEdgeList( level ) ),
1425 if( ! edgeList_.up2Date() )
1426 updateEdgeList(grid,level,nlinks);
1430 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1432 , level_(org.level_)
1433 , edgeList_( org.edgeList_ )
1434 , count_(org.count_)
1438 int size () {
return edgeList_.getItemList().size(); }
1449 int done ()
const {
return ((count_ >= edgeList_.size()) ? 1: 0); }
1453 assert( ! done () );
1454 elem_.first = ( (
ElType *) edgeList_.getItemList()[count_]);
1456 assert( elem_.first );
1461 template <
class Gr
idImp>
1462 void updateEdgeList(
const GridImp & grid,
int level,
int nlinks)
1464 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::All_Partition, Comm > ElementLevelIterator;
1465 typedef typename ElementLevelIterator :: val_t el_val_t;
1466 ElementLevelIterator iter(grid,level,nlinks);
1468 edgeList_.getItemList().resize(0);
1469 map < int , int > visited;
1471 for( iter.first(); ! iter.done(); iter.next() )
1473 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
1476 GEOElementType *elem = 0;
1477 el_val_t & item = iter.item();
1480 elem =
static_cast< GEOElementType *
> (item.first);
1481 else if( item.second )
1482 elem =
static_cast< GEOElementType *
> (item.second->getGhost().first);
1485 for(
int e=0; e<numEdges; ++e)
1487 ElType * edge = elem->myhedge1(e);
1488 if( edge->isGhost() )
continue;
1490 int idx = edge->getIndex();
1491 if( visited.find(idx) == visited.end() )
1493 edgeList_.getItemList().push_back( (
void *) edge );
1498 edgeList_.markAsUp2Date();
1502 #if ALU3DGRID_PARALLEL
1505 class ALU3dGridLevelIteratorWrapper< 1, Dune::
All_Partition, MPI_Comm >
1506 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1509 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1510 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1513 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1515 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1520 template <
class Gr
idImp>
1521 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1522 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1523 GhostIteratorType ( grid, level, nlinks ) )
1527 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1528 : iter_ (org.iter_) {}
1530 int size () {
return iter_.size(); }
1531 void next () { iter_.next(); }
1532 void first() { iter_.first(); }
1533 int done ()
const {
return iter_.done(); }
1534 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1539 class ALU3dGridLevelIteratorWrapper< 2, Dune::
All_Partition, MPI_Comm >
1540 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1543 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1544 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1547 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1549 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1554 template <
class Gr
idImp>
1555 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1556 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1557 GhostIteratorType ( grid, level, nlinks ) )
1561 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1562 : iter_ (org.iter_) {}
1564 int size () {
return iter_.size(); }
1565 void next () { iter_.next(); }
1566 void first() { iter_.first(); }
1567 int done ()
const {
return iter_.done(); }
1568 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1573 class ALU3dGridLevelIteratorWrapper< 3, Dune::
All_Partition, MPI_Comm >
1574 :
public IteratorWrapperInterface < IteratorElType< 3, MPI_Comm >::val_t >
1577 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1578 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1581 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1583 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1588 template <
class Gr
idImp>
1589 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1590 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1591 GhostIteratorType ( grid, level, nlinks ) )
1595 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1596 : iter_ (org.iter_) {}
1598 int size () {
return iter_.size(); }
1599 void next () { iter_.next(); }
1600 void first() { iter_.first(); }
1601 int done ()
const {
return iter_.done(); }
1602 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1604 #endif // #if ALU3DGRID_PARALLEL
1608 #endif // #ifndef DUNE_ALU3DITERATORS_HH