dune-grid  2.2.0
common/gridview.hh
Go to the documentation of this file.
00001 #ifndef DUNE_GRIDVIEW_HH
00002 #define DUNE_GRIDVIEW_HH
00003 
00004 #include <dune/geometry/type.hh>
00005 
00006 #include <dune/grid/common/datahandleif.hh>
00007 #include <dune/grid/common/gridenums.hh>
00008 
00009 namespace Dune
00010 {
00011 
00012   template< int, int, class, class >
00013   class GridDefaultImplementation;
00014 
00015 
00016 
00053   template< class ViewTraits >
00054   class GridView
00055   {
00056     typedef GridView< ViewTraits > ThisType;
00057 
00058   public:
00059     typedef typename ViewTraits :: GridViewImp GridViewImp;
00060 
00062     typedef ViewTraits Traits;
00063 
00065     typedef typename Traits :: Grid Grid;
00066 
00068     typedef typename Traits :: IndexSet IndexSet;
00069 
00071     typedef typename Traits :: Intersection Intersection;
00072 
00074     typedef typename Traits :: IntersectionIterator IntersectionIterator;
00075 
00077     typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
00078 
00082     template< int cd >
00083     struct Codim {
00085       typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
00086 
00088       typedef typename Traits :: template Codim<cd> :: EntityPointer EntityPointer;
00089 
00091       typedef typename Traits :: template Codim<cd> :: Entity Entity;
00092 
00094       typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
00095 
00097       typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
00098 
00100       template< PartitionIteratorType pit >
00101       struct Partition
00102       {
00104         typedef typename Traits :: template Codim< cd >
00105           :: template Partition< pit > :: Iterator Iterator;
00106       };
00107     }; //: public Traits :: template Codim<cd> {};
00108  
00109     enum { 
00111            conforming = Traits :: conforming };
00112 
00114     typedef typename Grid::ctype ctype;
00115 
00116     enum { 
00117            dimension = Grid :: dimension };
00118 
00119     enum { 
00120            dimensionworld = Grid :: dimensionworld };
00121 
00122   public:
00124     GridView ( const GridViewImp &imp )
00125     : impl_( imp )
00126     {}
00127 
00129     GridView ( const ThisType &other )
00130     : impl_( other.impl_ )
00131     {}
00132 
00134     ThisType &operator= ( const ThisType &other )
00135     {
00136       impl_ = other.impl_;
00137       return *this;
00138     }
00139 
00140   public:
00142     const Grid &grid () const
00143     {
00144       return asImp().grid();
00145     }
00146 
00148     const IndexSet &indexSet () const
00149     {
00150       return asImp().indexSet();
00151     }
00152 
00154     int size ( int codim ) const
00155     {
00156       return asImp().size( codim );
00157     }
00158 
00160     int size ( const GeometryType &type ) const
00161     {
00162       return asImp().size( type );
00163     }
00164     
00171     template<class EntityType>
00172     bool contains (const EntityType& e) const
00173     {
00174       return asImp().indexSet().contains(e);
00175     }
00176     
00178     template< int cd >
00179     typename Codim< cd > :: Iterator begin () const
00180     {
00181       return asImp().template begin<cd>();
00182     }
00183 
00185     template< int cd >
00186     typename Codim< cd > :: Iterator end () const
00187     {
00188       return asImp().template end<cd>();
00189     }
00190 
00192     template< int cd , PartitionIteratorType pitype >
00193     typename Codim< cd > :: template Partition< pitype > :: Iterator
00194     begin () const
00195     {
00196       return asImp().template begin<cd,pitype>();
00197     }
00198 
00200     template< int cd, PartitionIteratorType pitype >
00201     typename Codim< cd > :: template Partition< pitype > :: Iterator
00202     end () const
00203     {
00204       return asImp().template end<cd,pitype>();
00205     }
00206 
00208     IntersectionIterator
00209     ibegin ( const typename Codim< 0 > :: Entity &entity ) const
00210     {
00211       return asImp().ibegin(entity);
00212     }
00213 
00215     IntersectionIterator
00216     iend ( const typename Codim< 0 > :: Entity &entity ) const
00217     {
00218       return asImp().iend(entity);
00219     }
00220 
00222     const CollectiveCommunication &comm () const
00223     {
00224       return asImp().comm();
00225     }
00226 
00228     int overlapSize(int codim) const
00229     {
00230      return asImp().overlapSize(codim);
00231     }
00232 
00234     int ghostSize(int codim) const 
00235     {
00236      return asImp().ghostSize(codim);
00237     }
00238 
00240     template< class DataHandleImp, class DataType >
00241     void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
00242                        InterfaceType iftype,
00243                        CommunicationDirection dir ) const
00244     {
00245       asImp().communicate(data,iftype,dir);
00246     }
00247     
00248 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
00249   public:
00250 #else
00251   protected:
00252     // give the GridDefaultImplementation class access to the realImp 
00253     friend class GridDefaultImplementation< Grid::dimension, Grid::dimensionworld, typename Grid::ctype, typename Grid::GridFamily >;
00254 #endif
00255     // type of underlying implementation, for internal use only 
00256     typedef GridViewImp Implementation;
00257 
00259     Implementation &impl () { return impl_; }
00261     const Implementation &impl () const { return impl_; }
00262 
00263   protected:
00264     Implementation impl_;
00265 
00266     GridViewImp& asImp ()
00267     {
00268       return impl_;
00269     }
00270 
00271     const GridViewImp& asImp () const
00272     {
00273       return impl_;
00274     }
00275   };
00276 
00277 }
00278 
00279 #endif