1 #ifndef DUNE_GRID_SPGRID_TREE_HH
2 #define DUNE_GRID_SPGRID_TREE_HH
6 #include <dune/grid/common/entity.hh>
7 #include <dune/grid/common/entityiterator.hh>
8 #include <dune/grid/common/intersection.hh>
9 #include <dune/grid/common/intersectioniterator.hh>
22 template<
int codim,
class Gr
id,
class IsLeaf >
25 template<
class Gr
id,
class IsLeaf >
36 template<
class,
class >
44 template<
int codim,
int dim,
class Gr
id,
template<
int,
int,
class >
class EImpl,
class IsLeaf >
50 typedef typename std::remove_const< Grid >::type::Traits
Traits;
52 static const int dimension = Traits::ReferenceCube::dimension;
53 static const int codimension = codim;
54 static const int mydimension = dimension - codimension;
56 typedef typename Traits::template Codim< codimension >::Entity
Entity;
59 typedef EImpl< codimension, dimension, Grid > EntityImpl;
67 explicit TreeIterator (
const IsLeaf &isLeaf ) : isLeaf_( isLeaf ) {}
70 : entityInfo_( entity.impl().entityInfo() ),
71 rootLevel_( &gridLevel() ),
81 if( isLeaf_( dereference() ) || (&gridLevel() == &leafLevel()) )
85 if( entityInfo().nextChild() )
101 const GridLevel &leafLevel ()
const {
return gridLevel().grid().leafLevel(); }
103 bool isDone ()
const {
return (&gridLevel() == rootLevel_); }
105 EntityInfo entityInfo_;
106 const GridLevel *rootLevel_;
115 template<
class Gr
id,
class IntersectionImpl,
class IsLeaf >
123 static const int dimension = Intersection::dimension;
124 static const int codimension = Intersection::codimension;
125 static const int mydimension = Intersection::mydimension;
134 : intersection_( IntersectionImpl(
ElementInfo(), face ) )
138 : intersection_( intersection ),
139 rootLevel_( &intersection.impl().gridLevel() ),
153 return intersection_.impl().equals( other.intersection_.impl() );
158 if( isLeaf_( intersection_ ) || (&gridLevel() == &leafLevel()) )
161 while( !isDone( info ) )
163 if( info.nextChild() )
165 intersection_.impl().setEntityInfo( info );
176 intersection_.impl().setEntityInfo( info );
181 EntityInfo entityInfo ()
const {
return intersection_.impl().entityInfo(); }
183 const GridLevel &gridLevel ()
const {
return entityInfo().
gridLevel(); }
184 const GridLevel &leafLevel ()
const {
return gridLevel().
grid().leafLevel(); }
186 bool isDone (
const EntityInfo &entityInfo )
const {
return (&entityInfo.gridLevel() == rootLevel_); }
188 Intersection intersection_;
189 const GridLevel *rootLevel_;
200 template<
int codim,
class ct,
int dim,
template<
int >
class Ref,
class Comm,
class IsLeaf >
206 typedef Dune::Entity< codim, dim, const Grid, SPEntity >
Entity;
207 typedef Dune::EntityIterator< codim, Grid, __SPGrid::TreeIterator< Entity, IsLeaf > >
Iterator;
210 : entity_( entity ), isLeaf_( isLeaf )
216 bool empty ()
const {
return false; }
228 template<
class ct,
int dim,
template<
int >
class Ref,
class Comm,
class IsLeaf >
234 typedef Dune::Intersection< const Grid, SPIntersection< const Grid > >
Intersection;
238 : intersection_( intersection ), isLeaf_( isLeaf )
244 bool empty ()
const {
return false; }
247 Intersection intersection_;
Definition: iostream.hh:7
structured, parallel DUNE grid
Definition: grid.hh:136
Definition: entityinfo.hh:24
const GridLevel & gridLevel() const
Definition: entityinfo.hh:66
const Grid & grid() const
Definition: gridlevel.hh:82
Definition: intersection.hh:37
bool equals(const This &other) const
Definition: tree.hh:77
void increment()
Definition: tree.hh:79
TreeIterator(const Entity &entity, const IsLeaf &isLeaf)
Definition: tree.hh:69
std::remove_const< Grid >::type::Traits Traits
Definition: tree.hh:50
Traits::template Codim< codimension >::Entity Entity
Definition: tree.hh:56
EntityImpl::GridLevel GridLevel
Definition: tree.hh:63
Entity dereference() const
Definition: tree.hh:75
const EntityInfo & entityInfo() const
Definition: tree.hh:95
EntityImpl::EntityInfo EntityInfo
Definition: tree.hh:62
const GridLevel & gridLevel() const
Definition: tree.hh:98
TreeIterator(const IsLeaf &isLeaf)
Definition: tree.hh:67
EntityInfo & entityInfo()
Definition: tree.hh:96
TreeIterator(const This &)=default
void increment()
Definition: tree.hh:156
bool equals(const This &other) const
Definition: tree.hh:151
const Intersection & dereference() const
Definition: tree.hh:149
TreeIterator(const Intersection &intersection, const IsLeaf &isLeaf)
Definition: tree.hh:137
IntersectionImpl::EntityInfo EntityInfo
Definition: tree.hh:127
IntersectionImpl::ElementInfo ElementInfo
Definition: tree.hh:128
Dune::Intersection< Grid, IntersectionImpl > Intersection
Definition: tree.hh:121
IntersectionImpl::GridLevel GridLevel
Definition: tree.hh:129
TreeIterator(int face, const IsLeaf &isLeaf)
Definition: tree.hh:133
TreeIterator(This &&)=default
bool empty() const
Definition: tree.hh:216
EntityTree(const Grid &grid, const Entity &entity, const IsLeaf &isLeaf)
Definition: tree.hh:209
Iterator begin() const
Definition: tree.hh:213
Dune::EntityIterator< codim, Grid, __SPGrid::TreeIterator< Entity, IsLeaf > > Iterator
Definition: tree.hh:207
SPGrid< ct, dim, Ref, Comm > Grid
Definition: tree.hh:204
Dune::Entity< codim, dim, const Grid, SPEntity > Entity
Definition: tree.hh:206
Iterator end() const
Definition: tree.hh:214
Iterator end() const
Definition: tree.hh:242
SPGrid< ct, dim, Ref, Comm > Grid
Definition: tree.hh:232
IntersectionTree(const Grid &grid, const Intersection &intersection, const IsLeaf &isLeaf)
Definition: tree.hh:237
bool empty() const
Definition: tree.hh:244
Dune::Intersection< const Grid, SPIntersection< const Grid > > Intersection
Definition: tree.hh:234
Dune::IntersectionIterator< const Grid, __SPGrid::TreeIterator< Intersection, IsLeaf >, SPIntersection< const Grid > > Iterator
Definition: tree.hh:235
Iterator begin() const
Definition: tree.hh:241