identitygridintersectioniterator.hh
Go to the documentation of this file.00001 #ifndef DUNE_IDENTITYGRID_INTERSECTIONITERATOR_HH
00002 #define DUNE_IDENTITYGRID_INTERSECTIONITERATOR_HH
00003
00008 namespace Dune {
00009
00018 template<class GridImp>
00019 class IdentityGridLeafIntersectionIterator
00020 {
00021
00022 enum {dim=GridImp::dimension};
00023
00024 enum {dimworld=GridImp::dimensionworld};
00025
00026
00027 typedef typename GridImp::ctype ctype;
00028
00029 typedef typename GridImp::HostGridType::template Codim<0>::Entity::LeafIntersectionIterator HostLeafIntersectionIterator;
00030
00031 public:
00032
00033 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00034 typedef typename GridImp::template Codim<1>::Geometry Geometry;
00035 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00036 typedef typename GridImp::template Codim<0>::Entity Entity;
00037 typedef Dune::Intersection<const GridImp, Dune::IdentityGridLeafIntersectionIterator> Intersection;
00038
00039 IdentityGridLeafIntersectionIterator(const GridImp* identityGrid,
00040 const HostLeafIntersectionIterator& hostIterator)
00041 : selfLocal_(NULL), neighborLocal_(NULL), intersectionGlobal_(NULL),
00042 identityGrid_(identityGrid),
00043 hostIterator_(hostIterator)
00044 {}
00045
00047 ~IdentityGridLeafIntersectionIterator() {};
00048
00050 bool equals(const IdentityGridLeafIntersectionIterator<GridImp>& other) const {
00051 return hostIterator_ == other.hostIterator_;
00052 }
00053
00054
00056 void increment() {
00057 ++hostIterator_;
00058
00059
00060 if (intersectionGlobal_ != NULL) {
00061 delete intersectionGlobal_;
00062 intersectionGlobal_ = NULL;
00063 }
00064
00065 if (selfLocal_ != NULL) {
00066 delete selfLocal_;
00067 selfLocal_ = NULL;
00068 }
00069
00070 if (neighborLocal_ != NULL) {
00071 delete neighborLocal_;
00072 neighborLocal_ = NULL;
00073 }
00074 }
00075
00077 const Intersection & dereference() const {
00078 return reinterpret_cast<const Intersection&>(*this);
00079 }
00080
00081
00084 EntityPointer inside() const {
00085 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->inside());
00086 }
00087
00088
00091 EntityPointer outside() const {
00092 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->outside());
00093 }
00094
00095
00097 bool boundary () const {
00098 return hostIterator_->boundary();
00099 }
00100
00101
00103 bool neighbor () const {
00104 return hostIterator_->neighbor();
00105 }
00106
00107
00109 int boundaryId () const {
00110 return hostIterator_->boundaryId();
00111 }
00112
00114 bool conforming () const {
00115 return hostIterator_->conforming();
00116 }
00117
00119 GeometryType type () const {
00120 return hostIterator_->type();
00121 }
00122
00123
00128 const LocalGeometry& intersectionSelfLocal () const {
00129 if (selfLocal_ == NULL)
00130 selfLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->intersectionSelfLocal());
00131
00132 return *selfLocal_;
00133 }
00134
00137 const LocalGeometry& intersectionNeighborLocal () const {
00138 if (neighborLocal_ == NULL)
00139 neighborLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->intersectionNeighborLocal());
00140
00141 return *neighborLocal_;
00142 }
00143
00146 const Geometry& intersectionGlobal () const {
00147 if (intersectionGlobal_ == NULL)
00148 intersectionGlobal_ = new MakeableInterfaceObject<Geometry>(hostIterator_->intersectionGlobal());
00149
00150 return *intersectionGlobal_;
00151 }
00152
00153
00155 int numberInSelf () const {
00156 return hostIterator_->numberInSelf();
00157 }
00158
00159
00161 int numberInNeighbor () const {
00162 return hostIterator_->numberInNeighbor();
00163 }
00164
00165
00167 FieldVector<ctype, GridImp::dimensionworld> outerNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
00168 return hostIterator_->outerNormal(local);
00169 }
00170
00172 FieldVector<ctype, GridImp::dimensionworld> integrationOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
00173 return hostIterator_->integrationOuterNormal(local);
00174 }
00175
00177 FieldVector<ctype, GridImp::dimensionworld> unitOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const {
00178 return hostIterator_->unitOuterNormal(local);
00179 }
00180
00181
00182 private:
00183
00184
00185
00186
00189 mutable MakeableInterfaceObject<LocalGeometry>* selfLocal_;
00190 mutable MakeableInterfaceObject<LocalGeometry>* neighborLocal_;
00191
00194 mutable MakeableInterfaceObject<Geometry>* intersectionGlobal_;
00195
00196 const GridImp* identityGrid_;
00197
00198 HostLeafIntersectionIterator hostIterator_;
00199 };
00200
00201
00202
00203
00205 template<class GridImp>
00206 class IdentityGridLevelIntersectionIterator
00207 {
00208
00209 enum {dim=GridImp::dimension};
00210
00211 enum {dimworld=GridImp::dimensionworld};
00212
00213
00214 typedef typename GridImp::ctype ctype;
00215
00216 typedef typename GridImp::HostGridType::template Codim<0>::Entity::LevelIntersectionIterator HostLevelIntersectionIterator;
00217
00218 public:
00219
00220 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00221 typedef typename GridImp::template Codim<1>::Geometry Geometry;
00222 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00223 typedef typename GridImp::template Codim<0>::Entity Entity;
00224 typedef Dune::Intersection<const GridImp, Dune::IdentityGridLevelIntersectionIterator> Intersection;
00225
00226 IdentityGridLevelIntersectionIterator(const GridImp* identityGrid,
00227 const HostLevelIntersectionIterator& hostIterator)
00228 : selfLocal_(NULL), neighborLocal_(NULL), intersectionGlobal_(NULL),
00229 identityGrid_(identityGrid), hostIterator_(hostIterator)
00230 {}
00231
00233 bool equals(const IdentityGridLevelIntersectionIterator<GridImp>& other) const {
00234 return hostIterator_ == other.hostIterator_;
00235 }
00236
00237
00239 void increment() {
00240 ++hostIterator_;
00241
00242
00243 if (intersectionGlobal_ != NULL) {
00244 delete intersectionGlobal_;
00245 intersectionGlobal_ = NULL;
00246 }
00247
00248 if (selfLocal_ != NULL) {
00249 delete selfLocal_;
00250 selfLocal_ = NULL;
00251 }
00252
00253 if (neighborLocal_ != NULL) {
00254 delete neighborLocal_;
00255 neighborLocal_ = NULL;
00256 }
00257
00258 }
00259
00261 const Intersection & dereference() const {
00262 return reinterpret_cast<const Intersection&>(*this);
00263 }
00264
00267 EntityPointer inside() const {
00268 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->inside());
00269 }
00270
00271
00274 EntityPointer outside() const {
00275 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->outside());
00276 }
00277
00278
00281 bool boundary () const {
00282 return hostIterator_->boundary();
00283 }
00284
00285
00287 bool neighbor () const {
00288 return hostIterator_->neighbor();
00289 }
00290
00291
00293 int boundaryId () const {
00294 return hostIterator_->boundaryId();
00295 }
00296
00298 bool conforming () const {
00299 return hostIterator_->conforming();
00300 }
00301
00303 GeometryType type () const {
00304 return hostIterator_->type();
00305 }
00306
00307
00312 const LocalGeometry& intersectionSelfLocal () const {
00313 if (selfLocal_ == NULL)
00314 selfLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->intersectionSelfLocal());
00315
00316 return *selfLocal_;
00317 }
00318
00321 const LocalGeometry& intersectionNeighborLocal () const {
00322 if (neighborLocal_ == NULL)
00323 neighborLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->intersectionNeighborLocal());
00324
00325 return *neighborLocal_;
00326 }
00327
00330 const Geometry& intersectionGlobal () const {
00331 if (intersectionGlobal_ == NULL)
00332 intersectionGlobal_ = new MakeableInterfaceObject<Geometry>(hostIterator_->intersectionGlobal());
00333
00334 return *intersectionGlobal_;
00335 }
00336
00337
00339 int numberInSelf () const {
00340 return hostIterator_->numberInSelf();
00341 }
00342
00343
00345 int numberInNeighbor () const {
00346 return hostIterator_->numberInNeighbor();
00347 }
00348
00349
00351 FieldVector<ctype, dimworld> outerNormal (const FieldVector<ctype, dim-1>& local) const {
00352 return hostIterator_->outerNormal(local);
00353 }
00354
00356 FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const {
00357 return hostIterator_->integrationOuterNormal(local);
00358 }
00359
00361 FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const {
00362 return hostIterator_->unitOuterNormal(local);
00363 }
00364
00365 private:
00366
00369 mutable MakeableInterfaceObject<LocalGeometry>* selfLocal_;
00370 mutable MakeableInterfaceObject<LocalGeometry>* neighborLocal_;
00371
00374 mutable MakeableInterfaceObject<Geometry>* intersectionGlobal_;
00375
00376 const GridImp* identityGrid_;
00377
00378 HostLevelIntersectionIterator hostIterator_;
00379
00380 };
00381
00382
00383 }
00384
00385 #endif