identitygridindexsets.hh
Go to the documentation of this file.00001 #ifndef DUNE_IDENTITYGRID_INDEXSETS_HH
00002 #define DUNE_IDENTITYGRID_INDEXSETS_HH
00003
00008 #include <vector>
00009
00010 namespace Dune {
00011
00012
00013 template <class GridImp>
00014 struct IdentityGridLevelIndexSetTypes
00015 {
00017 template<int cd>
00018 struct Codim
00019 {
00020 template<PartitionIteratorType pitype>
00021 struct Partition
00022 {
00023 typedef typename GridImp::template Codim<cd>::template Partition<pitype>::LevelIterator Iterator;
00024 };
00025 };
00026 };
00027
00028
00029
00030
00032 template<class GridImp>
00033 class IdentityGridLevelIndexSet :
00034 public IndexSetDefaultImplementation<GridImp,IdentityGridLevelIndexSet<GridImp>,IdentityGridLevelIndexSetTypes<GridImp> >
00035 {
00036 public:
00037
00038 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00039
00040 enum {dim = GridImp::dimension};
00041
00042 typedef IndexSetDefaultImplementation<GridImp,IdentityGridLevelIndexSet<GridImp>,IdentityGridLevelIndexSetTypes<GridImp> > Base;
00043
00045 template<int codim>
00046 int index (const typename GridImp::Traits::template Codim<codim>::Entity& e) const
00047 {
00048 return grid_->hostgrid_->levelIndexSet(level_).template index<codim>(*grid_->template getHostEntity<codim>(e));
00049 }
00050
00051
00053 template<int codim>
00054 int subIndex (const typename GridImp::Traits::template Codim<0>::Entity& e, int i) const
00055 {
00056 return grid_->hostgrid_->levelIndexSet(level_).template subIndex<codim>(*grid_->template getHostEntity<0>(e), i);
00057 }
00058
00059
00061 int size (int codim) const {
00062 return grid_->hostgrid_->levelIndexSet(level_).size(codim);
00063 }
00064
00065
00067 int size (GeometryType type) const
00068 {
00069 return grid_->hostgrid_->levelIndexSet(level_).size(type);
00070 }
00071
00072
00074 const std::vector<GeometryType>& geomTypes (int codim) const
00075 {
00076 return grid_->hostgrid_->levelIndexSet(level_).geomTypes(codim);
00077 }
00078
00079
00081 template<int cd, PartitionIteratorType pitype>
00082 typename Base::template Codim<cd>::template Partition<pitype>::Iterator begin () const
00083 {
00084 return grid_->template lbegin<cd,pitype>(level_);
00085 }
00086
00087
00089 template<int cd, PartitionIteratorType pitype>
00090 typename Base::template Codim<cd>::template Partition<pitype>::Iterator end () const
00091 {
00092 return grid_->template lend<cd,pitype>(level_);
00093 }
00094
00095
00097 void update(const GridImp& grid, int level)
00098 {
00099 grid_ = &grid;
00100 level_ = level;
00101 }
00102
00103
00104 GridImp* grid_;
00105
00106 int level_;
00107 };
00108
00109
00110
00111
00112 template <class GridImp>
00113 struct IdentityGridLeafIndexSetTypes
00114 {
00116 template<int cd>
00117 struct Codim
00118 {
00119 template<PartitionIteratorType pitype>
00120 struct Partition
00121 {
00122 typedef typename GridImp::template Codim<cd>::template Partition<pitype>::LeafIterator Iterator;
00123 };
00124 };
00125 };
00126
00127
00128
00129
00130 template<class GridImp>
00131 class IdentityGridLeafIndexSet :
00132 public IndexSetDefaultImplementation<GridImp,IdentityGridLeafIndexSet<GridImp>,IdentityGridLeafIndexSetTypes<GridImp> >
00133 {
00134 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00135
00136 public:
00137
00138
00139
00140
00141
00142
00143 enum {dim = remove_const<GridImp>::type::dimension};
00144
00145 typedef IndexSetDefaultImplementation<GridImp,IdentityGridLeafIndexSet<GridImp>,IdentityGridLeafIndexSetTypes<GridImp> > Base;
00146
00147
00149 IdentityGridLeafIndexSet (const GridImp& grid)
00150 : grid_(&grid)
00151 {}
00152
00153
00155
00156
00157
00158
00159 template<int codim>
00160 int index (const typename remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
00161 {
00162 return grid_->hostgrid_->leafIndexSet().template index<codim>(*grid_->template getHostEntity<codim>(e));
00163 }
00164
00165
00167
00168
00169
00170
00171 template<int codim>
00172 int subIndex (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i) const
00173 {
00174 return grid_->hostgrid_->leafIndexSet().template subIndex<codim>(*grid_->template getHostEntity<0>(e),i);
00175 }
00176
00177
00179 int size (GeometryType type) const
00180 {
00181 return grid_->hostgrid_->leafIndexSet().size(type);
00182 }
00183
00184
00186 int size (int codim) const
00187 {
00188 return grid_->hostgrid_->leafIndexSet().size(codim);
00189 }
00190
00191
00193 const std::vector<GeometryType>& geomTypes (int codim) const
00194 {
00195 return grid_->hostgrid_->leafIndexSet().geomTypes(codim);
00196 }
00197
00198
00200 template<int codim, PartitionIteratorType pitype>
00201 typename Base::template Codim<codim>::template Partition<pitype>::Iterator begin () const
00202 {
00203 return grid_->template leafbegin<codim,pitype>();
00204 }
00205
00206
00208 template<int codim, PartitionIteratorType pitype>
00209 typename Base::template Codim<codim>::template Partition<pitype>::Iterator end () const
00210 {
00211 return grid_->template leafend<codim,pitype>();
00212 }
00213
00214
00216 void update(const GridImp& grid)
00217 {
00218 grid_ = &grid;
00219 }
00220
00221
00222 GridImp* grid_;
00223 };
00224
00225
00226
00227
00228 template <class GridImp>
00229 class IdentityGridGlobalIdSet :
00230 public IdSet<GridImp,IdentityGridGlobalIdSet<GridImp>,
00231 typename remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
00232 {
00233
00234 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00235
00236
00237 public:
00239 IdentityGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
00240
00242 typedef typename HostGrid::Traits::GlobalIdSet::IdType GlobalIdType;
00243
00244
00246
00247
00248
00249
00250 template<int cd>
00251 GlobalIdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
00252 {
00253
00254 return grid_->hostgrid_->globalIdSet().id(*grid_->getRealImplementation(e).hostEntity_);
00255 }
00256
00257
00259
00260
00261
00262
00263 template<int cc>
00264 GlobalIdType subId (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i) const
00265 {
00266
00267 return grid_->hostgrid_->globalIdSet().template subId<cc>(*grid_->getRealImplementation(e).hostEntity_,i);
00268 }
00269
00270
00272 void update() {}
00273
00274
00275 const GridImp* grid_;
00276 };
00277
00278
00279
00280
00281 template<class GridImp>
00282 class IdentityGridLocalIdSet :
00283 public IdSet<GridImp,IdentityGridLocalIdSet<GridImp>,
00284 typename remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
00285 {
00286 private:
00287
00288 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00289
00290
00291 public:
00293 typedef typename HostGrid::Traits::LocalIdSet::IdType LocalIdType;
00294
00295
00297 IdentityGridLocalIdSet (const GridImp& g) : grid_(&g) {}
00298
00299
00301
00302
00303
00304
00305 template<int cd>
00306 LocalIdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
00307 {
00308
00309 return grid_->hostgrid_->localIdSet().id(*grid_->getRealImplementation(e).hostEntity_);
00310 }
00311
00312
00314
00315
00316
00317
00318 template<int cc>
00319 LocalIdType subId (const typename remove_const<GridImp>::type::template Codim<0>::Entity& e, int i) const
00320 {
00321
00322 return grid_->hostgrid_->localIdSet().template subId<cc>(*grid_->getRealImplementation(e).hostEntity_,i);
00323 }
00324
00325
00327 void update() {}
00328
00329
00330 const GridImp* grid_;
00331 };
00332
00333
00334 }
00335
00336
00337 #endif