dune-grid-dev-howto
2.1.1
|
00001 #ifndef DUNE_IDENTITYGRID_INTERSECTIONS_HH 00002 #define DUNE_IDENTITYGRID_INTERSECTIONS_HH 00003 00004 #include "identitygridleafiterator.hh" 00005 00010 namespace Dune { 00011 00012 00013 // External forward declarations 00014 template< class Grid > 00015 class HostGridAccess; 00016 00017 00026 template<class GridImp> 00027 class IdentityGridLeafIntersection 00028 { 00029 00030 friend class IdentityGridLeafIntersectionIterator<GridImp>; 00031 00032 friend class HostGridAccess< typename remove_const< GridImp >::type >; 00033 00034 enum {dim=GridImp::dimension}; 00035 00036 enum {dimworld=GridImp::dimensionworld}; 00037 00038 // The type used to store coordinates 00039 typedef typename GridImp::ctype ctype; 00040 00041 typedef typename GridImp::HostGridType::template Codim<0>::Entity::LeafIntersectionIterator HostLeafIntersectionIterator; 00042 00043 public: 00044 00045 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00046 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00047 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00048 typedef typename GridImp::template Codim<0>::Entity Entity; 00049 typedef FieldVector<ctype, dimworld> NormalVector; 00050 00051 IdentityGridLeafIntersection(const GridImp* identityGrid, 00052 const HostLeafIntersectionIterator& hostIterator) 00053 : selfLocal_(NULL), neighborLocal_(NULL), intersectionGlobal_(NULL), 00054 identityGrid_(identityGrid), 00055 hostIterator_(hostIterator) 00056 {} 00057 00060 EntityPointer inside() const { 00061 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->inside()); 00062 } 00063 00064 00067 EntityPointer outside() const { 00068 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->outside()); 00069 } 00070 00071 00073 bool boundary () const { 00074 return hostIterator_->boundary(); 00075 } 00076 00082 NormalVector centerUnitOuterNormal () const { 00083 return hostIterator_->centerUnitOuterNormal(); 00084 } 00085 00087 bool neighbor () const { 00088 return hostIterator_->neighbor(); 00089 } 00090 00091 00093 int boundaryId () const { 00094 return hostIterator_->boundaryId(); 00095 } 00096 00098 size_t boundarySegmentIndex() const { 00099 return hostIterator_->boundarySegmentIndex(); 00100 } 00101 00103 bool conforming () const { 00104 return hostIterator_->conforming(); 00105 } 00106 00108 GeometryType type () const { 00109 return hostIterator_->type(); 00110 } 00111 00112 00117 const LocalGeometry& geometryInInside () const { 00118 if (selfLocal_ == NULL) 00119 selfLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->geometryInInside()); 00120 00121 return *selfLocal_; 00122 } 00123 00126 const LocalGeometry& geometryInOutside () const { 00127 if (neighborLocal_ == NULL) 00128 neighborLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->geometryInOutside()); 00129 00130 return *neighborLocal_; 00131 } 00132 00135 const Geometry& geometry () const { 00136 if (intersectionGlobal_ == NULL) 00137 intersectionGlobal_ = new MakeableInterfaceObject<Geometry>(hostIterator_->geometry()); 00138 00139 return *intersectionGlobal_; 00140 } 00141 00142 00144 int indexInInside () const { 00145 return hostIterator_->indexInInside(); 00146 } 00147 00148 00150 int indexInOutside () const { 00151 return hostIterator_->indexInOutside(); 00152 } 00153 00154 00156 FieldVector<ctype, GridImp::dimensionworld> outerNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const { 00157 return hostIterator_->outerNormal(local); 00158 } 00159 00161 FieldVector<ctype, GridImp::dimensionworld> integrationOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const { 00162 return hostIterator_->integrationOuterNormal(local); 00163 } 00164 00166 FieldVector<ctype, GridImp::dimensionworld> unitOuterNormal (const FieldVector<ctype, GridImp::dimension-1>& local) const { 00167 return hostIterator_->unitOuterNormal(local); 00168 } 00169 00170 00171 private: 00172 //********************************************************** 00173 // private methods 00174 //********************************************************** 00175 00178 mutable MakeableInterfaceObject<LocalGeometry>* selfLocal_; 00179 mutable MakeableInterfaceObject<LocalGeometry>* neighborLocal_; 00180 00183 mutable MakeableInterfaceObject<Geometry>* intersectionGlobal_; 00184 00185 const GridImp* identityGrid_; 00186 00187 HostLeafIntersectionIterator hostIterator_; 00188 }; 00189 00190 00191 00192 00194 template<class GridImp> 00195 class IdentityGridLevelIntersection 00196 { 00197 00198 friend class IdentityGridLevelIntersectionIterator<GridImp>; 00199 00200 friend class HostGridAccess< typename remove_const< GridImp >::type >; 00201 00202 enum {dim=GridImp::dimension}; 00203 00204 enum {dimworld=GridImp::dimensionworld}; 00205 00206 // The type used to store coordinates 00207 typedef typename GridImp::ctype ctype; 00208 00209 typedef typename GridImp::HostGridType::template Codim<0>::Entity::LevelIntersectionIterator HostLevelIntersectionIterator; 00210 00211 public: 00212 00213 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00214 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00215 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00216 typedef typename GridImp::template Codim<0>::Entity Entity; 00217 typedef FieldVector<ctype, dimworld> NormalVector; 00218 00219 IdentityGridLevelIntersection(const GridImp* identityGrid, 00220 const HostLevelIntersectionIterator& hostIterator) 00221 : selfLocal_(NULL), neighborLocal_(NULL), intersectionGlobal_(NULL), 00222 identityGrid_(identityGrid), hostIterator_(hostIterator) 00223 {} 00224 00227 EntityPointer inside() const { 00228 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->inside()); 00229 } 00230 00231 00234 EntityPointer outside() const { 00235 return IdentityGridEntityPointer<0,GridImp> (identityGrid_, hostIterator_->outside()); 00236 } 00237 00238 00241 bool boundary () const { 00242 return hostIterator_->boundary(); 00243 } 00244 00250 NormalVector centerUnitOuterNormal () const { 00251 return hostIterator_->centerUnitOuterNormal(); 00252 } 00253 00255 bool neighbor () const { 00256 return hostIterator_->neighbor(); 00257 } 00258 00259 00261 int boundaryId () const { 00262 return hostIterator_->boundaryId(); 00263 } 00264 00266 size_t boundarySegmentIndex() const { 00267 return hostIterator_->boundarySegmentIndex(); 00268 } 00269 00271 bool conforming () const { 00272 return hostIterator_->conforming(); 00273 } 00274 00276 GeometryType type () const { 00277 return hostIterator_->type(); 00278 } 00279 00280 00285 const LocalGeometry& geometryInInside () const { 00286 if (selfLocal_ == NULL) 00287 selfLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->geometryInInside()); 00288 00289 return *selfLocal_; 00290 } 00291 00294 const LocalGeometry& geometryInOutside () const { 00295 if (neighborLocal_ == NULL) 00296 neighborLocal_ = new MakeableInterfaceObject<LocalGeometry>(hostIterator_->geometryInOutside()); 00297 00298 return *neighborLocal_; 00299 } 00300 00303 const Geometry& geometry () const { 00304 if (intersectionGlobal_ == NULL) 00305 intersectionGlobal_ = new MakeableInterfaceObject<Geometry>(hostIterator_->geometry()); 00306 00307 return *intersectionGlobal_; 00308 } 00309 00310 00312 int indexInInside () const { 00313 return hostIterator_->indexInInside(); 00314 } 00315 00316 00318 int indexInOutside () const { 00319 return hostIterator_->indexInOutside(); 00320 } 00321 00322 00324 FieldVector<ctype, dimworld> outerNormal (const FieldVector<ctype, dim-1>& local) const { 00325 return hostIterator_->outerNormal(local); 00326 } 00327 00329 FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const { 00330 return hostIterator_->integrationOuterNormal(local); 00331 } 00332 00334 FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const { 00335 return hostIterator_->unitOuterNormal(local); 00336 } 00337 00338 private: 00339 00342 mutable MakeableInterfaceObject<LocalGeometry>* selfLocal_; 00343 mutable MakeableInterfaceObject<LocalGeometry>* neighborLocal_; 00344 00347 mutable MakeableInterfaceObject<Geometry>* intersectionGlobal_; 00348 00349 const GridImp* identityGrid_; 00350 00351 HostLevelIntersectionIterator hostIterator_; 00352 00353 }; 00354 00355 00356 } // namespace Dune 00357 00358 #endif