identitygridindexsets.hh
Go to the documentation of this file.00001 #ifndef DUNE_IDENTITYGRID_INDEXSETS_HH
00002 #define DUNE_IDENTITYGRID_INDEXSETS_HH
00003
00008 #include <dune/grid/common/indexidset.hh>
00009
00010 #include <vector>
00011
00012 namespace Dune {
00013
00015 template<class GridImp>
00016 class IdentityGridLevelIndexSet :
00017 public IndexSet<GridImp,IdentityGridLevelIndexSet<GridImp> >
00018 {
00019 public:
00020
00021 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00022
00023 enum {dim = GridImp::dimension};
00024
00026 template<int codim>
00027 int index (const typename GridImp::Traits::template Codim<codim>::Entity& e) const
00028 {
00029 return grid_->hostgrid_->levelIndexSet(level_).template index<codim>(*grid_->template getHostEntityPointer<codim>(e));
00030 }
00031
00032
00034 int subIndex (const typename GridImp::Traits::template Codim<0>::Entity& e, int i, int codim) const
00035 {
00036 return grid_->hostgrid_->levelIndexSet(level_).subIndex(*grid_->template getHostEntityPointer<0>(e), i, codim);
00037 }
00038
00039
00041 int size (int codim) const {
00042 return grid_->hostgrid_->levelIndexSet(level_).size(codim);
00043 }
00044
00045
00047 int size (GeometryType type) const
00048 {
00049 return grid_->hostgrid_->levelIndexSet(level_).size(type);
00050 }
00051
00052
00054 const std::vector<GeometryType>& geomTypes (int codim) const
00055 {
00056 return grid_->hostgrid_->levelIndexSet(level_).geomTypes(codim);
00057 }
00058
00060 template<class EntityType>
00061 bool contains (const EntityType& e) const
00062 {
00063 return grid_->hostgrid_->levelIndexSet(level_).contains(*grid_->template getHostEntityPointer<EntityType::codimension>(e));
00064 }
00065
00067 void update(const GridImp& grid, int level)
00068 {
00069 grid_ = &grid;
00070 level_ = level;
00071 }
00072
00073
00074 GridImp* grid_;
00075
00076 int level_;
00077 };
00078
00079
00080 template<class GridImp>
00081 class IdentityGridLeafIndexSet :
00082 public IndexSet<GridImp,IdentityGridLeafIndexSet<GridImp> >
00083 {
00084 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00085
00086 public:
00087
00088
00089
00090
00091
00092
00093 enum {dim = remove_const<GridImp>::type::dimension};
00094
00095
00097 IdentityGridLeafIndexSet (const GridImp& grid)
00098 : grid_(&grid)
00099 {}
00100
00101
00103
00104
00105
00106
00107 template<int codim>
00108 int index (const typename remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
00109 {
00110 return grid_->hostgrid_->leafIndexSet().template index<codim>(*grid_->template getHostEntityPointer<codim>(e));
00111 }
00112
00113
00115
00116
00117
00118
00119 int subIndex (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
00120 {
00121 return grid_->hostgrid_->leafIndexSet().subIndex(*grid_->template getHostEntityPointer<0>(e),i, codim);
00122 }
00123
00124
00126 int size (GeometryType type) const
00127 {
00128 return grid_->hostgrid_->leafIndexSet().size(type);
00129 }
00130
00131
00133 int size (int codim) const
00134 {
00135 return grid_->hostgrid_->leafIndexSet().size(codim);
00136 }
00137
00138
00140 const std::vector<GeometryType>& geomTypes (int codim) const
00141 {
00142 return grid_->hostgrid_->leafIndexSet().geomTypes(codim);
00143 }
00144
00146 template<class EntityType>
00147 bool contains (const EntityType& e) const
00148 {
00149 return grid_->hostgrid_->leafIndexSet().contains(*grid_->template getHostEntityPointer<EntityType::codimension>(e));
00150 }
00151
00152
00153
00155 void update(const GridImp& grid)
00156 {
00157 grid_ = &grid;
00158 }
00159
00160
00161 GridImp* grid_;
00162 };
00163
00164
00165
00166
00167 template <class GridImp>
00168 class IdentityGridGlobalIdSet :
00169 public IdSet<GridImp,IdentityGridGlobalIdSet<GridImp>,
00170 typename remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
00171 {
00172
00173 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00174
00175
00176 public:
00178 IdentityGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
00179
00181 typedef typename HostGrid::Traits::GlobalIdSet::IdType IdType;
00182
00183
00185
00186
00187
00188
00189 template<int cd>
00190 IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
00191 {
00192
00193 return grid_->hostgrid_->globalIdSet().id(*grid_->getRealImplementation(e).hostEntity_);
00194 }
00195
00196
00198
00199
00200
00201
00202 IdType subId (const typename remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
00203 {
00204
00205 return grid_->hostgrid_->globalIdSet().subId(*grid_->getRealImplementation(e).hostEntity_,i, codim);
00206 }
00207
00208
00210 void update() {}
00211
00212
00213 const GridImp* grid_;
00214 };
00215
00216
00217
00218
00219 template<class GridImp>
00220 class IdentityGridLocalIdSet :
00221 public IdSet<GridImp,IdentityGridLocalIdSet<GridImp>,
00222 typename remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
00223 {
00224 private:
00225
00226 typedef typename remove_const<GridImp>::type::HostGridType HostGrid;
00227
00228
00229 public:
00231 typedef typename HostGrid::Traits::LocalIdSet::IdType IdType;
00232
00233
00235 IdentityGridLocalIdSet (const GridImp& g) : grid_(&g) {}
00236
00237
00239
00240
00241
00242
00243 template<int cd>
00244 IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
00245 {
00246
00247 return grid_->hostgrid_->localIdSet().id(*grid_->getRealImplementation(e).hostEntity_);
00248 }
00249
00250
00252
00253
00254
00255
00256 IdType subId (const typename remove_const<GridImp>::type::template Codim<0>::Entity& e, int i, int codim) const
00257 {
00258
00259 return grid_->hostgrid_->localIdSet().subId(*grid_->getRealImplementation(e).hostEntity_,i,codim);
00260 }
00261
00262
00264 void update() {}
00265
00266
00267 const GridImp* grid_;
00268 };
00269
00270
00271 }
00272
00273
00274 #endif