3#ifndef DUNE_ALBERTAGRID_GRIDVIEW_HH
4#define DUNE_ALBERTAGRID_GRIDVIEW_HH
12#include <dune/grid/common/gridview.hh>
19 template<
class Gr
idImp >
20 class AlbertaLevelGridView;
22 template<
class Gr
idImp >
23 class AlbertaLeafGridView;
26 template<
class Gr
idImp >
27 struct AlbertaLevelGridViewTraits
29 typedef AlbertaLevelGridView< GridImp > GridViewImp;
32 typedef typename std::remove_const<GridImp>::type Grid;
35 typedef typename Grid::Traits::LevelIndexSet IndexSet;
38 typedef typename Grid::Traits::LevelIntersection Intersection;
41 typedef typename Grid::Traits::LevelIntersectionIterator
45 typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
50 typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator Iterator;
52 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
54 typedef typename Grid::template Codim< cd >::Geometry Geometry;
55 typedef typename Grid::template Codim< cd >::LocalGeometry
59 template< PartitionIteratorType pit >
72 template<
class Gr
idImp >
73 class AlbertaLevelGridView
75 typedef AlbertaLevelGridView< GridImp > ThisType;
78 typedef AlbertaLevelGridViewTraits<GridImp> Traits;
81 typedef typename Traits::Grid Grid;
84 typedef typename Traits::IndexSet IndexSet;
87 typedef typename Traits::Intersection Intersection;
90 typedef typename Traits::IntersectionIterator IntersectionIterator;
93 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
99 enum { conforming = Traits::conforming };
102 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
104 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
107 AlbertaLevelGridView (
const Grid &grid,
int level )
109 indexSet_( &(grid.levelIndexSet( level )) ),
115 AlbertaLevelGridView (
const ThisType &other )
116 : grid_( other.grid_ ),
117 indexSet_( other.indexSet_ ),
118 level_( other.level_ )
122 ThisType &operator= (
const ThisType & other)
125 indexSet_ = other.indexSet_;
126 level_ = other.level_;
131 const Grid &grid ()
const
137 const IndexSet &indexSet ()
const
143 int size (
int codim )
const
145 return grid().size( level_, codim );
149 int size (
const GeometryType &type )
const
151 return grid().size( level_, type );
156 typename Codim< cd >::Iterator begin ()
const
158 return grid().template lbegin< cd, All_Partition >( level_ );
162 template<
int cd, PartitionIteratorType pit >
163 typename Codim< cd >::template Partition< pit >::Iterator begin ()
const
165 return grid().template lbegin< cd, pit >( level_ );
170 typename Codim< cd >::Iterator end ()
const
172 return grid().template lend< cd, All_Partition >( level_ );
176 template<
int cd, PartitionIteratorType pit >
177 typename Codim< cd >::template Partition< pit >::Iterator end ()
const
179 return grid().template lend< cd, pit >( level_ );
184 ibegin (
const typename Codim< 0 >::Entity &entity )
const
186 if( grid().maxLevel() == 0)
188 typename IntersectionIteratorImpl::Begin begin;
189 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
193 DUNE_THROW( NotImplemented,
"method ibegin not implemented on LevelGridView for AlbertaGrid." );
194 typename IntersectionIteratorImpl::End end;
195 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
201 iend (
const typename Codim< 0 >::Entity &entity )
const
203 typename IntersectionIteratorImpl::End end;
204 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
208 const CollectiveCommunication &comm ()
const
210 return grid().comm();
214 int overlapSize(
int codim)
const
216 return grid().overlapSize(level_, codim);
220 int ghostSize(
int codim)
const
222 return grid().ghostSize(level_, codim);
226 template<
class DataHandleImp,
class DataType >
227 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
234 const IndexSet *indexSet_;
239 template<
class Gr
idImp >
240 struct AlbertaLeafGridViewTraits
242 typedef AlbertaLeafGridView< GridImp > GridViewImp;
245 typedef typename std::remove_const<GridImp>::type Grid;
248 typedef typename Grid::Traits::LeafIndexSet IndexSet;
251 typedef typename Grid::Traits::LeafIntersection Intersection;
254 typedef typename Grid::Traits::LeafIntersectionIterator
255 IntersectionIterator;
258 typedef typename Grid::Traits::CollectiveCommunication CollectiveCommunication;
263 typedef typename Grid::Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator
266 typedef typename Grid::Traits::template Codim< cd >::Entity Entity;
268 typedef typename Grid::template Codim< cd >::Geometry Geometry;
269 typedef typename Grid::template Codim< cd >::LocalGeometry
273 template <PartitionIteratorType pit >
286 template<
class Gr
idImp >
287 class AlbertaLeafGridView
289 typedef AlbertaLeafGridView< GridImp > ThisType;
292 typedef AlbertaLeafGridViewTraits<GridImp> Traits;
295 typedef typename Traits::Grid Grid;
298 typedef typename Traits::IndexSet IndexSet;
301 typedef typename Traits::Intersection Intersection;
304 typedef typename Traits::IntersectionIterator IntersectionIterator;
307 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
313 enum { conforming = Traits::conforming };
316 typedef Alberta::ElementInfo< Grid::dimension > ElementInfo;
318 typedef Dune::AlbertaGridLeafIntersectionIterator< GridImp > IntersectionIteratorImpl;
321 AlbertaLeafGridView (
const Grid &grid )
323 indexSet_( &(grid.leafIndexSet()) )
328 AlbertaLeafGridView (
const ThisType &other )
329 : grid_( other.grid_ ),
330 indexSet_( other.indexSet_ )
334 ThisType &operator= (
const ThisType & other)
337 indexSet_ = other.indexSet_;
342 const Grid &grid ()
const
348 const IndexSet &indexSet ()
const
354 int size (
int codim )
const
356 return grid().size( codim );
360 int size (
const GeometryType &type )
const
362 return grid().size( type );
367 typename Codim< cd >::Iterator begin ()
const
369 return grid().template leafbegin< cd, All_Partition >();
373 template<
int cd, PartitionIteratorType pit >
374 typename Codim< cd >::template Partition< pit >::Iterator begin ()
const
376 return grid().template leafbegin< cd, pit >();
381 typename Codim< cd >::Iterator end ()
const
383 return grid().template leafend< cd, All_Partition >();
387 template<
int cd, PartitionIteratorType pit >
388 typename Codim< cd >::template Partition< pit >::Iterator end ()
const
390 return grid().template leafend< cd, pit >();
395 ibegin (
const typename Codim< 0 >::Entity &entity )
const
397 const ElementInfo elementInfo = Grid::getRealImplementation( entity ).elementInfo();
398 assert( !!elementInfo );
403 if( elementInfo.elInfo().opp_vertex[ i ] == 127 )
404 DUNE_THROW( NotImplemented,
"AlbertaGrid: Intersections on outside entities are not fully implemented, yet." );
408 typename IntersectionIteratorImpl::Begin begin;
409 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), begin );
414 iend (
const typename Codim< 0 >::Entity &entity )
const
416 assert( !!Grid::getRealImplementation( entity ).elementInfo() );
417 typename IntersectionIteratorImpl::End end;
418 return IntersectionIteratorImpl( Grid::getRealImplementation( entity ), end );
422 const CollectiveCommunication &comm ()
const
424 return grid().comm();
428 int overlapSize(
int codim)
const
430 return grid().overlapSize(codim);
434 int ghostSize(
int codim)
const
436 return grid().ghostSize(codim);
440 template<
class DataHandleImp,
class DataType >
441 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
448 const IndexSet *indexSet_;
Implementation of the IntersectionIterator for AlbertaGrid.
Grid abstract base class.
Definition: grid.hh:373
@ dimension
The dimension of the grid.
Definition: grid.hh:387
A set of traits classes to store static information about grid implementation.
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:275
Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:278
Codim Structure.
Definition: gridview.hh:311
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:61
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:64
Codim Structure.
Definition: gridview.hh:97
Traits for type conversions and type information.