3#ifndef DUNE_ALU3DITERATORS_HH
4#define DUNE_ALU3DITERATORS_HH
12#include "alu3dinclude.hh"
22 template<
int codim,
class Comm >
23 struct BSMacroIterator
25 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
26 typedef typename AccessIterator< HElementType >::Handle IteratorType;
32 template<
int codim,
class Comm >
33 struct ALUHElementType;
35 template<
class Comm >
36 struct ALUHElementType< 0, Comm >
38 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType ElementType;
41 template<
class Comm >
42 struct ALUHElementType< 1, Comm >
44 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HFaceType ElementType;
47 template<
class Comm >
48 struct ALUHElementType< 2, Comm >
50 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HEdgeType ElementType;
53 template<
class Comm >
54 struct ALUHElementType< 3, Comm >
56 typedef typename Dune::ALU3dBasicImplTraits< Comm >::VertexType ElementType;
63 template<
class val_t >
64 class IteratorWrapperInterface
65 :
public IteratorSTI< val_t >
68 virtual ~IteratorWrapperInterface () {}
70 virtual int size () = 0;
71 virtual void next () = 0;
72 virtual void first() = 0;
73 virtual int done ()
const = 0;
74 virtual val_t & item ()
const = 0;
75 virtual IteratorSTI< val_t > * clone ()
const { assert(
false); abort();
return 0; }
81 template<
int codim,
class Comm >
84 typedef typename ALUHElementType< codim, Comm >::ElementType ElType;
85 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HBndSegType HBndSegType;
86 typedef pair< ElType *, HBndSegType * > val_t;
89 template<
int codim, PartitionIteratorType pitype,
class Comm >
90 class ALU3dGridLevelIteratorWrapper;
93 template< PartitionIteratorType pitype,
class Comm >
94 class ALU3dGridLevelIteratorWrapper< 0, pitype, Comm >
95 :
public IteratorWrapperInterface< typename IteratorElType< 0, Comm >::val_t >
97 typedef typename IteratorElType< 0, Comm >::ElType ElType;
98 typedef typename IteratorElType< 0, Comm >::HBndSegType HBndSegType;
99 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
105 typedef typename IteratorElType< 0, Comm >::val_t val_t;
109 template<
class Gr
idImp >
110 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
111 : it_( grid.myGrid(), level ),
112 elem_( (ElType *) 0, (HBndSegType *) 0 )
116 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
117 : it_( org.it_ ), elem_(org.elem_)
120 int size () {
return it_->size(); }
121 void next () { it_->next(); }
122 void first() { it_->first(); }
123 int done ()
const {
return it_->done(); }
124 val_t & item ()
const
127 elem_.first = & it_->item();
133 template< PartitionIteratorType pitype,
class Comm >
134 class ALU3dGridLevelIteratorWrapper< 1, pitype, Comm >
135 :
public IteratorWrapperInterface< typename IteratorElType< 1, Comm >::val_t >
137 typedef typename IteratorElType< 1, Comm >::ElType ElType;
138 typedef typename IteratorElType< 1, Comm >::HBndSegType HBndSegType;
139#ifdef ALUGRID_PERIODIC_BOUNDARY
140 typedef ALU3DSPACE any_has_level_periodic< ElType > StopRule_t;
141 typedef GridIterator< ElType, StopRule_t > IteratorType;
143 typedef ALU3DSPACE LevelIterator< ElType > IteratorType;
150 typedef typename IteratorElType< 1, Comm >::val_t val_t;
154 template<
class Gr
idImp >
155 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
156#ifdef ALUGRID_PERIODIC_BOUNDARY
157 : it_( grid.myGrid(), StopRule_t(level) ),
159 : it_( grid.myGrid(), level ),
161 elem_( (ElType *) 0, (HBndSegType*) 0 )
165 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
166 : it_( org.it_ ), elem_(org.elem_)
169 int size () {
return it_->size(); }
170 void next () { it_->next(); }
171 void first() { it_->first(); }
172 int done ()
const {
return it_->done(); }
173 val_t & item ()
const
176 elem_.first = & it_->item();
184 template< PartitionIteratorType pitype,
class Comm >
185 class ALU3dGridLevelIteratorWrapper< 3, pitype, Comm >
186 :
public IteratorWrapperInterface< typename IteratorElType< 3, Comm >::val_t >
188 typedef typename IteratorElType< 3, Comm >::ElType ElType;
189 typedef typename IteratorElType< 3, Comm >::HBndSegType HBndSegType;
191 typedef typename VertexListType::IteratorType IteratorType;
193 VertexListType & vxList_;
199 typedef typename IteratorElType< 3, Comm >::val_t val_t;
203 template<
class Gr
idImp >
204 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
205 : vxList_ ( grid.getVertexList( level ) ),
207 size_( vxList_.size() ),
208 elem_( (ElType *) 0, (HBndSegType *) 0 )
210 assert( vxList_.up2Date() );
214 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
215 : vxList_(org.vxList_) , count_(org.count_) , size_(org.size_)
220 int size () {
return size_; }
225 if( done () ) return ;
230 void first() { count_ = 0; }
231 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
232 val_t & item ()
const
235 elem_.first = vxList_.getItemList()[count_];
236 assert( elem_.first );
241 template<
int codim, PartitionIteratorType pitype,
class Comm >
242 class ALU3dGridLeafIteratorWrapper;
250 template< PartitionIteratorType pitype,
class Comm >
251 class ALU3dGridLeafIteratorWrapper< 0, pitype, Comm >
252 :
public IteratorWrapperInterface< typename IteratorElType< 0, Comm >::val_t >
254 typedef typename IteratorElType< 0, Comm >::ElType ElType;
255 typedef typename IteratorElType< 0, Comm >::HBndSegType HBndSegType;
256 typedef LeafIterator< ElType > IteratorType;
262 typedef typename IteratorElType< 0, Comm >::val_t val_t;
269 template<
class Gr
idImp >
270 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int links )
271 : it_( grid.myGrid() ),
272 elem_( (ElType *) 0, (HBndSegType *) 0 )
276 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
277 : it_( org.it_ ), elem_(org.elem_)
280 int size () {
return it_->size(); }
281 void next () { it_->next(); }
282 void first() { it_->first(); }
283 int done ()
const {
return it_->done(); }
284 val_t & item ()
const
287 elem_.first = & it_->item();
292 template<
class ElType, PartitionIteratorType pitype,
class Comm >
295 typedef is_leaf_entity< ElType > StopRule_t;
301#if ALU3DGRID_PARALLEL
302 template<
class ElType >
305 typedef is_interior_leaf_entity< ElType > StopRule_t;
310 template< PartitionIteratorType pitype,
class Comm >
311 class ALU3dGridLeafIteratorWrapper< 1, pitype, Comm >
312 :
public IteratorWrapperInterface< typename IteratorElType< 1, Comm >::val_t >
314 typedef typename IteratorElType< 1, Comm >::ElType ElType;
315 typedef typename IteratorElType< 1, Comm >::HBndSegType HBndSegType;
316 typedef typename LeafStopRule< ElType, pitype, Comm >::StopRule_t StopRule_t;
317 typedef GridIterator< ElType, StopRule_t > IteratorType;
323 typedef typename IteratorElType< 1, Comm >::val_t val_t;
328 template<
class Gr
idImp >
329 ALU3dGridLeafIteratorWrapper (
const GridImp &grid,
int level,
const int links )
330 : it_( grid.myGrid(), StopRule_t() ),
331 elem_( (ElType *) 0, (HBndSegType *) 0 )
335 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
336 : it_( org.it_ ), elem_(org.elem_) {}
338 ~ALU3dGridLeafIteratorWrapper ()
341 int size () {
return it_->size(); }
342 void next () { it_->next(); }
343 void first() { it_->first(); }
344 int done ()
const {
return it_->done(); }
345 val_t & item ()
const
348 elem_.first = & it_->item();
353 template< PartitionIteratorType pitype,
class Comm >
354 class ALU3dGridLeafIteratorWrapper< 2, pitype, Comm >
355 :
public IteratorWrapperInterface< typename IteratorElType< 2, Comm >::val_t >
357 typedef typename IteratorElType< 2, Comm >::ElType ElType;
358 typedef typename IteratorElType< 2, Comm >::HBndSegType HBndSegType;
359 typedef typename LeafStopRule< ElType, pitype, Comm >::StopRule_t StopRule_t;
360 typedef GridIterator< ElType, StopRule_t > IteratorType;
363 typedef typename IteratorElType< 2, Comm >::val_t val_t;
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(); }
384 void next () { it_->next(); }
385 void first() { it_->first(); }
386 int done ()
const {
return it_->done(); }
387 val_t & item ()
const
390 elem_.first = & it_->item();
397 template< PartitionIteratorType pitype,
class Comm >
398 class ALU3dGridLeafIteratorWrapper< 3, pitype, Comm >
399 :
public IteratorWrapperInterface< typename IteratorElType< 3, Comm >::val_t >
401 typedef typename IteratorElType< 3, Comm >::ElType ElType;
402 typedef typename IteratorElType< 3, Comm >::HBndSegType HBndSegType;
404 typedef typename LeafVertexListType::IteratorType IteratorType;
405 typedef typename LeafVertexListType::ItemType VxItemType;
406 typedef typename LeafStopRule< ElType, pitype, Comm >::StopRule_t StopRule_t;
408 LeafVertexListType & vxList_;
409 typedef typename LeafVertexListType :: IteratorType ListIteratorType;
415 typedef typename IteratorElType< 3, Comm >::val_t val_t;
417 const StopRule_t rule_;
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_)
440 int size () {
return size_; }
455 int done ()
const {
return (count_ >= size_) ? 1 : 0; }
456 val_t & item ()
const
459 assert( elem_.first );
463 val_t & getItem ()
const
467 elem_.first = vxList_.getItemList()[count_].first;
472 if( done() ) return ;
473 if( getItem().first == 0)
480 assert( elem_.first );
481 if(! rule_( elem_.first ) )
490#if ALU3DGRID_PARALLEL
491 template<
int codim >
492 class LeafLevelIteratorTTProxy
495 typedef typename ALUHElementType< codim, MPI_Comm >::ElementType ElType;
497 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::GitterImplType GitterImplType;
499 typedef IteratorSTI< ElType > IteratorType;
500 IteratorType * inner_;
501 IteratorType * outer_;
505 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link )
507 pair < IteratorSTI< ElType > * , IteratorSTI< ElType > * >
508 p = gitter.leafBorderIteratorTT( (ElType *) 0 , link );
515 LeafLevelIteratorTTProxy( GitterImplType & gitter ,
int link ,
int level )
517 pair < IteratorSTI< ElType > * , IteratorSTI< ElType > * >
518 p = gitter.levelBorderIteratorTT( (ElType *) 0 , link , level );
524 LeafLevelIteratorTTProxy(
const LeafLevelIteratorTTProxy & org )
525 : inner_(org.inner_->clone())
526 , outer_(org.outer_->clone())
529 ~LeafLevelIteratorTTProxy()
535 IteratorType & inner () { assert(inner_);
return *inner_; }
536 IteratorType & outer () { assert(outer_);
return *outer_; }
540 typedef pair< ALUHElementType< 0, MPI_Comm >::ElementType *, Dune::ALU3dBasicImplTraits< MPI_Comm >::HBndSegType * > LeafValType;
547 class ALU3dGridGhostIterator
548 :
public IteratorWrapperInterface< LeafValType >
551 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::GitterImplType GitterImplType;
553 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::HElementType HElementType;
554 typedef Dune::ALU3dBasicImplTraits< MPI_Comm >::HBndSegType HBndSegType;
557 GitterImplType & gitter_;
560 typedef ALUHElementType< 1, MPI_Comm >::ElementType ElType;
562 typedef LeafLevelIteratorTTProxy< 1 > IteratorType;
564 IteratorType * iterTT_;
566 typedef IteratorSTI < ElType > InnerIteratorType;
567 InnerIteratorType * it_;
577 typedef LeafValType val_t;
582 const bool ghostCellsEnabled_ ;
584 typedef ElementPllXIF_t ItemType;
586 template<
class Gr
idImp >
587 ALU3dGridGhostIterator (
const GridImp &grid,
int level,
const int nlinks )
588 : gitter_( grid.myGrid() ),
593 elem_( (HElementType *) 0, (HBndSegType *) 0 ),
594 ghostCellsEnabled_( grid.ghostCellsEnabled() )
597 ALU3dGridGhostIterator (
const ALU3dGridGhostIterator & org)
598 : gitter_(org.gitter_)
599 , iterTT_(0) , it_(0)
604 , ghostCellsEnabled_( org.ghostCellsEnabled_ )
608 iterTT_ =
new IteratorType ( *org.iterTT_ );
609 usingInner_ = org.usingInner_;
612 assert( ! org.it_->done() );
613 it_ = (usingInner_) ? &( iterTT_->inner() ) : &( iterTT_->outer() );
618 ~ALU3dGridGhostIterator ()
624 virtual IteratorType * newIterator()
626 return new IteratorType ( gitter_, link_ );
629 void removeIterators()
631 if(iterTT_)
delete iterTT_;
637 void createIterator()
639 if (usingInner_) checkInnerOuter();
648 iterTT_ = newIterator();
651 if (!it_) createIterator();
656 void checkInnerOuter()
662 it_ = &( iterTT_->inner() );
663 InnerIteratorType & it = iterTT_->inner();
668 pair < ElementPllXIF_t *, int > p = it.item ().accessPllX ().accessOuterPllX () ;
669 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
670 p.first->getAttachedElement(elems);
672 assert( elems.first || elems.second );
682 InnerIteratorType & out = iterTT_->outer();
686 pair < ElementPllXIF_t *, int > p = out.item ().accessPllX ().accessOuterPllX () ;
687 pair< HElementType *, HBndSegType * > elems( (HElementType *)0, (HBndSegType *)0 );
688 p.first->getAttachedElement(elems);
690 assert( elems.second );
698 virtual void checkLeafEntity ()
705 HBndSegType * pll = el.second;
710 if ( ! pll->isLeafEntity() ) next();
733 if( !it_->done() ) it_->next();
736 if( it_->done() ) createIterator();
744 if( ghostCellsEnabled_ )
751 if( it_ ) assert( !it_->done());
757 assert( (link_ >= nl_) ? (it_ == 0) : 1 );
758 return ((link_ >= nl_ || !it_ ) ? 1 : 0);
761 val_t & item ()
const
764 pair < ElementPllXIF_t *, int > p = it_->item ().accessPllX ().accessOuterPllX () ;
765 pair < HElementType * , HBndSegType * > p2;
766 p.first->getAttachedElement(p2);
768 elem_.second = p2.second;
778 :
public ALU3dGridGhostIterator
781 typedef LeafLevelIteratorTTProxy<1> IteratorType;
782 IteratorType * newIterator()
784 return new IteratorType ( this->gitter_, this->link_ );
787 void checkLeafEntity ()
791 if(! this->it_->done())
793 val_t & el = this->item();
794 HBndSegType * pll = el.second;
799 if ( ! pll->isLeafEntity() ) this->next();
805 template <
class Gr
idImp>
806 ALU3dGridLeafIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
807 : ALU3dGridGhostIterator(grid,level,nlinks) {}
809 ALU3dGridLeafIteratorWrapper(
const ALU3dGridLeafIteratorWrapper & org)
810 : ALU3dGridGhostIterator(org) {}
816 :
public ALU3dGridGhostIterator
821 typedef LeafLevelIteratorTTProxy<1> IteratorType;
822 IteratorType * newIterator()
825 return new IteratorType ( this->gitter_, this->link_ , level_ );
829 void checkLeafEntity ()
833 if(! this->it_->done())
835 val_t & el = this->item();
838 HBndSegType & pll = *(el.second);
845 if( pll.ghostLevel() != level_ ) this->next();
852 template <
class Gr
idImp>
853 ALU3dGridLevelIteratorWrapper(
const GridImp & grid,
int level ,
const int nlinks )
854 : ALU3dGridGhostIterator(grid,level,nlinks)
855 , level_(level) , mxl_(grid.maxLevel()){}
857 ALU3dGridLevelIteratorWrapper(
const ALU3dGridLevelIteratorWrapper & org)
858 : ALU3dGridGhostIterator(org) , level_(org.level_) , mxl_(org.mxl_){}
866 template<
class Gr
idImp,
int cd >
869 template<
class Gr
idImp >
870 struct GetItem< GridImp, 1 >
873 enum { elType = GridImp::elementType };
875 typedef typename GridImp::MPICommunicatorType Comm;
877 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
878 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
879 typedef typename IteratorElType< 1, Comm >::ElType ItemType;
881 static ItemType *getItemFromEl (
typename Dune::ALU3dImplTraits< Dune::tetra, Comm >::GEOElementType &el,
int i )
883 return el.myhface3( i );
886 static ItemType *getItemFromEl (
typename Dune::ALU3dImplTraits< Dune::hexa, Comm >::GEOElementType &el,
int i )
888 return el.myhface4( i );
891 static ItemType *getItem ( HElementType &el,
int i )
893 return getItemFromEl(
static_cast< GEOElementType &
>( el ), i );
896 static int numItems ()
898 return Dune::EntityCount< elType >::numFaces;
902 template<
class Gr
idImp >
903 struct GetItem< GridImp, 2 >
906 enum { elType = GridImp::elementType };
908 typedef typename GridImp::MPICommunicatorType Comm;
910 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
911 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
912 typedef typename IteratorElType< 2, Comm >::ElType ItemType;
914 static ItemType *getItem ( HElementType &el,
int i )
916 return static_cast< GEOElementType &
>( el ).myhedge1( i );
919 static int numItems ()
921 return Dune::EntityCount<elType>::numEdges;
925 template<
class Gr
idImp >
926 struct GetItem< GridImp, 3 >
929 enum { elType = GridImp::elementType };
931 typedef typename GridImp::MPICommunicatorType Comm;
933 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HElementType HElementType;
934 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
935 typedef typename IteratorElType< 3, Comm >::ElType ItemType;
937 static ItemType *getItem ( HElementType &el,
int i )
939 return static_cast< GEOElementType &
>( el ).myvertex( i );
942 static int numItems ()
944 return Dune::EntityCount< elType >::numVertices;
950 template<
int codim >
951 class ALU3dGridGhostIteratorHigherCodim
952 :
public IteratorWrapperInterface< typename IteratorElType< codim, MPI_Comm >::val_t >
955 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::HElementType HElementType;
956 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::HBndSegType HBndSegType;
957 typedef typename Dune::ALU3dBasicImplTraits< MPI_Comm >::GhostPairType GhostPairType;
958 typedef typename IteratorElType< codim, MPI_Comm >::ElType ElType;
959 typedef typename IteratorElType< codim, MPI_Comm >::val_t val_t;
962 template< Dune::ALU3dGr
idElementType elType,
int cd >
965 template< Dune::ALU3dGr
idElementType elType >
966 struct SelectVector< elType, 1 >
968 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
970 static const vector< int > &getNotOnItemVector (
int face )
972 return GEOElementType::facesNotOnFace( face );
976 template< Dune::ALU3dGr
idElementType elType >
977 struct SelectVector< elType, 2 >
979 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
980 static const vector< int > &getNotOnItemVector(
int face )
982 return GEOElementType::edgesNotOnFace( face );
986 template< Dune::ALU3dGr
idElementType elType >
987 struct SelectVector< elType, 3 >
989 typedef typename Dune::ALU3dImplTraits< elType, MPI_Comm >::GEOElementType GEOElementType;
990 static const vector< int > &getNotOnItemVector (
int face )
992 return GEOElementType::verticesNotOnFace( face );
996 typedef ElType *getItemFunc_t ( HElementType &el,
int i );
999 typedef Dune :: ALU3dGridItemListType GhostItemListType;
1000 GhostItemListType &ghList_;
1001 typedef typename GhostItemListType :: IteratorType IteratorType;
1004 mutable val_t elem_;
1005 mutable size_t count_;
1006 const bool ghostCellsEnabled_ ;
1009 template<
class GhostElementIteratorImp,
class Gr
idImp >
1010 ALU3dGridGhostIteratorHigherCodim ( GhostElementIteratorImp *,
const GridImp &grid,
1011 int level,
const int nlinks, GhostItemListType &ghList )
1012 : ghList_( ghList ),
1013 elem_( (ElType *) 0, (HBndSegType *) 0 ),
1015 ghostCellsEnabled_( grid.ghostCellsEnabled() )
1017 if( ! ghostCellsEnabled_ )
1019 count_ = ghList_.getItemList().size() ;
1023 if( ! ghList_.up2Date() )
1025 GhostElementIteratorImp ghostIter(grid,level,nlinks);
1026 updateGhostList(grid,ghostIter,ghList_);
1030 ALU3dGridGhostIteratorHigherCodim(
const ALU3dGridGhostIteratorHigherCodim & org)
1031 : ghList_( org.ghList_ )
1033 , count_(org.count_)
1034 , ghostCellsEnabled_(org.ghostCellsEnabled_)
1037 int size () {
return ghList_.getItemList().size(); }
1038 void first() {
if( ghostCellsEnabled_ ) count_ = 0;}
1039 void next () { ++count_; }
1040 int done ()
const {
return (count_ >= ghList_.getItemList().size() ? 1 : 0); }
1041 val_t & item ()
const
1044 void * item = ghList_.getItemList()[count_];
1045 elem_.first = ((ElType * ) item);
1046 assert( elem_.first );
1051 template <
class Gr
idImp,
class GhostElementIteratorImp>
1052 void updateGhostList(
const GridImp & grid, GhostElementIteratorImp & ghostIter, GhostItemListType & ghList)
1055 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1060 const int numItems = SelectVector<GridImp::elementType,codim>::getNotOnItemVector(0).size();
1061 const int maxSize = numItems * count;
1063 ghList.getItemList().reserve(maxSize);
1064 ghList.getItemList().resize(0);
1065 map< int , int > visited;
1067 const map<int,int>::iterator visitedEnd = visited.end();
1068 for( ghostIter.first(); !ghostIter.done(); ghostIter.next() )
1070 GhostPairType ghPair = ghostIter.item().second->getGhost();
1071 const vector<int> & notOnFace = SelectVector<GridImp::elementType,codim>::
1072 getNotOnItemVector(ghPair.second);
1073 for(
int i=0; i<numItems; ++i)
1075 ElType * item = GetItem<GridImp,codim>::getItem( *(ghPair.first) , notOnFace[i] );
1076 int idx = item->getIndex();
1077 if( visited.find(idx) == visitedEnd )
1079 ghList.getItemList().push_back( (
void *) item );
1084 ghList.markAsUp2Date();
1091 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1094 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1097 template <
class Gr
idImp>
1098 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1099 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *) 0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1101 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1102 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1108 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1111 typedef ALU3dGridLeafIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1114 template <
class Gr
idImp>
1115 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1116 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *) 0,grid,level,nlinks,grid.getGhostLeafList(codim)) {}
1118 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1119 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1125 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
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) {}
1142 :
public ALU3dGridGhostIteratorHigherCodim< 1 >
1145 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1148 template <
class Gr
idImp>
1149 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1150 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *) 0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1152 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1153 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1159 :
public ALU3dGridGhostIteratorHigherCodim< 2 >
1162 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostElementIteratorType;
1165 template <
class Gr
idImp>
1166 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1167 : ALU3dGridGhostIteratorHigherCodim<codim>((GhostElementIteratorType *) 0,grid,level,nlinks,grid.getGhostLevelList(codim,level)) {}
1169 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1170 : ALU3dGridGhostIteratorHigherCodim<codim>(org) {}
1176 :
public ALU3dGridGhostIteratorHigherCodim< 3 >
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) {}
1193 :
public IteratorWrapperInterface< IteratorElType< 0, MPI_Comm >::val_t >
1196 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1197 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1200 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1202 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1207 template <
class Gr
idImp>
1208 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1209 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1210 GhostIteratorType ( grid, level, nlinks ) )
1213 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1214 : iter_ (org.iter_) {}
1216 int size () {
return iter_.size(); }
1217 void next () { iter_.next(); }
1218 void first() { iter_.first(); }
1219 int done ()
const {
return iter_.done(); }
1220 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1226 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1229 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1230 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1233 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1235 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1240 template <
class Gr
idImp>
1241 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1242 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1243 GhostIteratorType ( grid, level, nlinks ) )
1246 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1247 : iter_ (org.iter_) {}
1249 int size () {
return iter_.size(); }
1250 void next () { iter_.next(); }
1251 void first() { iter_.first(); }
1252 int done ()
const {
return iter_.done(); }
1253 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1259 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1262 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1263 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1266 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1268 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1273 template <
class Gr
idImp>
1274 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1275 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1276 GhostIteratorType ( grid, level, nlinks ) )
1279 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1280 : iter_ (org.iter_) {}
1282 int size () {
return iter_.size(); }
1283 void next () { iter_.next(); }
1284 void first() { iter_.first(); }
1285 int done ()
const {
return iter_.done(); }
1286 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1292 :
public IteratorWrapperInterface< IteratorElType< 3, MPI_Comm >::val_t >
1295 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1296 typedef ALU3dGridLeafIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1299 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1301 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1306 template <
class Gr
idImp>
1307 ALU3dGridLeafIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1308 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1309 GhostIteratorType ( grid, level, nlinks ) )
1312 ALU3dGridLeafIteratorWrapper (
const ALU3dGridLeafIteratorWrapper & org )
1313 : iter_ (org.iter_) {}
1315 int size () {
return iter_.size(); }
1316 void next () { iter_.next(); }
1317 void first() { iter_.first(); }
1318 int done ()
const {
return iter_.done(); }
1319 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1325 :
public IteratorWrapperInterface< LeafValType >
1327 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1328 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1331 typedef LeafValType val_t;
1333 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1338 template <
class Gr
idImp>
1339 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1340 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1341 GhostIteratorType ( grid, level, nlinks ) )
1344 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org)
1345 : iter_(org.iter_) {}
1347 int size () {
return iter_.size(); }
1348 void next () { iter_.next(); }
1349 void first() { iter_.first(); }
1350 int done ()
const {
return iter_.done(); }
1351 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1357 template< PartitionIteratorType pitype,
class Comm >
1358 class ALU3dGridLevelIteratorWrapper< 2, pitype, Comm >
1359 :
public IteratorWrapperInterface< typename IteratorElType< 2, Comm >::val_t >
1362 typedef typename ALUHElementType< 2, Comm >::ElementType ElType;
1363 typedef typename Dune::ALU3dBasicImplTraits< Comm >::HBndSegType HBndSegType;
1364 typedef typename Dune::ALU3dBasicImplTraits< Comm >::GEOEdgeType GEOEdgeType;
1366 typedef typename IteratorElType< 2, Comm >::val_t val_t;
1369 mutable val_t elem_;
1372 typedef Dune :: ALU3dGridItemListType ItemListType;
1373 ItemListType & edgeList_;
1380 template<
class Gr
idImp >
1381 ALU3dGridLevelIteratorWrapper (
const GridImp &grid,
int level,
const int nlinks )
1382 : elem_( (ElType *) 0, (HBndSegType *) 0 ),
1384 edgeList_( grid.getEdgeList( level ) ),
1387 if( ! edgeList_.up2Date() )
1388 updateEdgeList(grid,level,nlinks);
1392 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1394 , level_(org.level_)
1395 , edgeList_( org.edgeList_ )
1396 , count_(org.count_)
1399 int size () {
return edgeList_.getItemList().size(); }
1410 int done ()
const {
return ((count_ >= edgeList_.size()) ? 1 : 0); }
1412 val_t & item ()
const
1414 assert( ! done () );
1415 elem_.first = ( (ElType *) edgeList_.getItemList()[count_]);
1417 assert( elem_.first );
1422 template <
class Gr
idImp>
1423 void updateEdgeList(
const GridImp & grid,
int level,
int nlinks)
1425 typedef ALU3dGridLevelIteratorWrapper< 0, Dune::All_Partition, Comm > ElementLevelIterator;
1426 typedef typename ElementLevelIterator :: val_t el_val_t;
1427 ElementLevelIterator iter(grid,level,nlinks);
1429 edgeList_.getItemList().resize(0);
1430 map < int , int > visited;
1432 for( iter.first(); ! iter.done(); iter.next() )
1434 typedef typename Dune::ALU3dImplTraits< GridImp::elementType, Comm >::GEOElementType GEOElementType;
1435 enum { numEdges = Dune::EntityCount< GridImp::elementType >::numEdges };
1437 GEOElementType *elem = 0;
1438 el_val_t & item = iter.item();
1441 elem =
static_cast< GEOElementType *
> (item.first);
1442 else if( item.second )
1443 elem =
static_cast< GEOElementType *
> (item.second->getGhost().first);
1446 for(
int e=0; e<numEdges; ++e)
1448 ElType * edge = elem->myhedge1(e);
1449 if( edge->isGhost() )
continue;
1451 int idx = edge->getIndex();
1452 if( visited.find(idx) == visited.end() )
1454 edgeList_.getItemList().push_back( (
void *) edge );
1459 edgeList_.markAsUp2Date();
1463#if ALU3DGRID_PARALLEL
1467 :
public IteratorWrapperInterface< IteratorElType< 1, MPI_Comm >::val_t >
1470 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1471 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1474 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1476 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1481 template <
class Gr
idImp>
1482 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1483 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1484 GhostIteratorType ( grid, level, nlinks ) )
1487 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1488 : iter_ (org.iter_) {}
1490 int size () {
return iter_.size(); }
1491 void next () { iter_.next(); }
1492 void first() { iter_.first(); }
1493 int done ()
const {
return iter_.done(); }
1494 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1500 :
public IteratorWrapperInterface< IteratorElType< 2, MPI_Comm >::val_t >
1503 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1504 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1507 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1509 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1514 template <
class Gr
idImp>
1515 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1516 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1517 GhostIteratorType ( grid, level, nlinks ) )
1520 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1521 : iter_ (org.iter_) {}
1523 int size () {
return iter_.size(); }
1524 void next () { iter_.next(); }
1525 void first() { iter_.first(); }
1526 int done ()
const {
return iter_.done(); }
1527 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
1533 :
public IteratorWrapperInterface < IteratorElType< 3, MPI_Comm >::val_t >
1536 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::InteriorBorder_Partition, MPI_Comm > InteriorIteratorType;
1537 typedef ALU3dGridLevelIteratorWrapper< codim, Dune::Ghost_Partition, MPI_Comm > GhostIteratorType;
1540 typedef IteratorElType< codim, MPI_Comm >::val_t val_t;
1542 typedef AlignIterator< InteriorIteratorType, GhostIteratorType, val_t > IteratorType;
1547 template <
class Gr
idImp>
1548 ALU3dGridLevelIteratorWrapper (
const GridImp & grid,
int level ,
const int nlinks )
1549 : iter_ ( InteriorIteratorType ( grid, level, nlinks ) ,
1550 GhostIteratorType ( grid, level, nlinks ) )
1553 ALU3dGridLevelIteratorWrapper (
const ALU3dGridLevelIteratorWrapper & org )
1554 : iter_ (org.iter_) {}
1556 int size () {
return iter_.size(); }
1557 void next () { iter_.next(); }
1558 void first() { iter_.first(); }
1559 int done ()
const {
return iter_.done(); }
1560 val_t & item ()
const { assert( ! done() );
return iter_.item(); }
Different resources needed by all grid implementations.
Dune namespace.
Definition: alignment.hh:10
Definition: alu3dinclude.hh:330
Definition: alu3dinclude.hh:297