1 #ifndef DUNE_SPGRID_ITERATOR_HH
2 #define DUNE_SPGRID_ITERATOR_HH
17 template<
int codim,
class Gr
id >
23 typedef typename std::remove_const< Grid >::type::Traits
Traits;
25 static const int dimension = Traits::ReferenceCube::dimension;
29 typedef typename Traits::template Codim< codimension >::Entity
Entity;
56 const Begin &b,
const unsigned int sweepDir = 0 );
58 const End &e,
const unsigned int sweepDir = 0 );
60 operator bool ()
const {
return bool( partition_ ); }
88 typename PartitionList::Iterator partition_;
89 unsigned int sweepDirection_;
97 template<
int codim,
class Gr
id >
100 const Begin &b,
unsigned int sweepDir )
101 : entityInfo_( gridLevel ),
102 partition_( partitionList.begin() ),
103 sweepDirection_( sweepDir )
105 assert( sweepDir < numDirections );
110 template<
int codim,
class Gr
id >
113 const End &e,
unsigned int sweepDir )
114 : entityInfo_( gridLevel ),
115 partition_( partitionList.end() ),
116 sweepDirection_( sweepDir )
118 assert( sweepDir < numDirections );
123 template<
int codim,
class Gr
id >
127 for(
int i = 0; i < dimension; ++i )
129 const unsigned int sweep = (sweepDirection_ >> i) & 1;
130 id[ i ] += (2 - 4*sweep);
131 if(
id[ i ] != end( i, entityInfo().direction() ) )
132 return entityInfo().update();
133 id[ i ] = begin( i, entityInfo().direction() );
138 for( ; dirIt && partition_->empty( *dirIt ); ++dirIt )
142 for(
int i = 0; i < dimension; ++i )
143 id[ i ] = begin( i, *dirIt );
144 entityInfo().update();
154 template<
int codim,
class Gr
id >
157 const unsigned int s = (sweepDirection_ >> i) & 1;
158 return partition_->bound( s, i, dir[ i ] );
162 template<
int codim,
class Gr
id >
163 inline int SPPartitionIterator< codim, Grid >::end (
int i, Direction dir )
const
165 const unsigned int s = (sweepDirection_ >> i) & 1;
166 const int bnd = partition_->bound( 1-s, i, dir[ i ] );
167 return bnd + 2*(2*(1-s) - 1);
171 template<
int codim,
class Gr
id >
172 inline void SPPartitionIterator< codim, Grid >::init ()
174 MultiIndex &
id = entityInfo().id();
177 DirectionIterator dirIt;
178 for( ; dirIt && partition_->empty( *dirIt ); ++dirIt )
182 for(
int i = 0; i < dimension; ++i )
183 id[ i ] = begin( i, *dirIt );
184 entityInfo().update( partition_->number() );
193 std::fill(
id.begin(),
id.end(), std::numeric_limits< int >::max() );
miscellaneous helper functions
Definition: iostream.hh:7
Definition: direction.hh:18
Definition: direction.hh:157
Definition: entity.hh:146
Definition: entityinfo.hh:24
const GridLevel & gridLevel() const
Definition: entityinfo.hh:66
bool equals(const This &other) const
Definition: entityinfo.hh:77
Definition: gridlevel.hh:35
static const unsigned int numDirections
Definition: gridlevel.hh:46
Definition: iterator.hh:19
bool operator!=(const This &other) const
Definition: iterator.hh:65
EntityInfo::Direction Direction
Definition: iterator.hh:40
EntityImpl::EntityInfo EntityInfo
Definition: iterator.hh:35
static const int codimension
Definition: iterator.hh:26
Entity operator*() const
Definition: iterator.hh:62
const EntityInfo & entityInfo() const
Definition: iterator.hh:75
This & operator++()
Definition: iterator.hh:67
static const int mydimension
Definition: iterator.hh:27
bool operator==(const This &other) const
Definition: iterator.hh:64
EntityImpl::GridLevel GridLevel
Definition: iterator.hh:36
static const unsigned int numDirections
Definition: iterator.hh:42
static const int dimension
Definition: iterator.hh:25
const GridLevel & gridLevel() const
Definition: iterator.hh:78
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:29
EntityInfo & entityInfo()
Definition: iterator.hh:76
std::remove_const< Grid >::type::Traits Traits
Definition: iterator.hh:23
void increment()
Definition: iterator.hh:124
SPDirectionIterator< dimension, codimension > DirectionIterator
Definition: iterator.hh:50
SPPartitionIterator(const GridLevel &gridLevel, const PartitionList &partitionList, const End &e, const unsigned int sweepDir=0)
Definition: iterator.hh:112
Entity dereference() const
Definition: iterator.hh:69
SPPartitionIterator(const GridLevel &gridLevel, const PartitionList &partitionList, const Begin &b, const unsigned int sweepDir=0)
Definition: iterator.hh:99
SPPartitionList< dimension > PartitionList
Definition: iterator.hh:38
bool equals(const This &other) const
Definition: iterator.hh:71
EntityInfo::MultiIndex MultiIndex
Definition: iterator.hh:48
SPPartitionIterator()=default
Definition: iterator.hh:44
Definition: iterator.hh:45
Definition: partitionlist.hh:16