- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=4 sw=2 sts=2: 00003 00004 #ifndef DUNE_GRID_INTERSECTION_HH 00005 #define DUNE_GRID_INTERSECTION_HH 00006 00007 #include <dune/grid/common/grid.hh> 00008 00009 #include <dune/grid/genericgeometry/conversion.hh> 00010 00011 namespace Dune 00012 { 00013 00164 template<class GridImp, template<class> class IntersectionImp> 00165 class Intersection 00166 { 00167 IntersectionImp<const GridImp> real; 00168 00169 enum { dim=GridImp::dimension }; 00170 enum { dimworld=GridImp::dimensionworld }; 00171 00172 public: 00173 00174 // type of real implementation 00175 typedef IntersectionImp<const GridImp> ImplementationType; 00176 00178 typedef typename GridImp::template Codim<0>::Entity Entity; 00179 00181 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00182 00184 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00185 00187 typedef typename Geometry::LocalCoordinate LocalCoordinate; 00188 00190 typedef typename Geometry::GlobalCoordinate GlobalCoordinate; 00191 00193 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00194 00196 enum { codimension=1 }; 00197 00199 enum { dimension=dim }; 00200 00202 enum { mydimension=dim-1 }; 00203 00205 enum { dimensionworld=dimworld }; 00206 00208 typedef typename GridImp::ctype ctype; 00209 00211 bool boundary () const 00212 { 00213 return this->real.boundary(); 00214 } 00215 00231 int boundaryId () const 00232 { 00233 return this->real.boundaryId(); 00234 } 00235 00247 size_t boundarySegmentIndex () const 00248 { 00249 return this->real.boundarySegmentIndex(); 00250 } 00251 00253 bool neighbor () const 00254 { 00255 return this->real.neighbor(); 00256 } 00257 00261 EntityPointer inside() const 00262 { 00263 return this->real.inside(); 00264 } 00265 00272 EntityPointer outside() const 00273 { 00274 return this->real.outside(); 00275 } 00276 00287 bool conforming () const 00288 { 00289 return this->real.conforming(); 00290 } 00291 00299 const LocalGeometry &geometryInInside () const 00300 { 00301 return this->real.geometryInInside(); 00302 } 00303 00311 const LocalGeometry &geometryInOutside () const 00312 { 00313 return this->real.geometryInOutside(); 00314 } 00315 00321 const Geometry &geometry () const 00322 { 00323 return this->real.geometry(); 00324 } 00325 00327 GeometryType type () const 00328 { 00329 return this->real.type(); 00330 } 00331 00341 int indexInInside () const 00342 { 00343 return this->real.indexInInside(); 00344 } 00345 00355 int indexInOutside () const 00356 { 00357 return this->real.indexInOutside(); 00358 } 00359 00364 GlobalCoordinate outerNormal (const LocalCoordinate& local) const 00365 { 00366 return this->real.outerNormal(local); 00367 } 00368 00375 GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const 00376 { 00377 return this->real.integrationOuterNormal(local); 00378 } 00379 00385 GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const 00386 { 00387 return this->real.unitOuterNormal(local); 00388 } 00389 00396 GlobalCoordinate centerUnitOuterNormal () const 00397 { 00398 return this->real.centerUnitOuterNormal(); 00399 } 00400 00401 //=========================================================== 00405 //=========================================================== 00406 00408 Intersection(const IntersectionImp<const GridImp> & i) : 00409 real(i) {}; 00411 00412 typedef typename remove_const<GridImp>::type mutableGridImp; 00413 protected: 00415 friend class GridDefaultImplementation< 00416 GridImp::dimension, GridImp::dimensionworld, 00417 typename GridImp::ctype, 00418 typename GridImp::GridFamily> ; 00419 00422 friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>; 00423 00425 ImplementationType & getRealImp() { return real; } 00427 const ImplementationType & getRealImp() const { return real; } 00428 00429 /* hide copy constructor */ 00430 Intersection ( const Intersection &i ) 00431 : real( i.real ) 00432 {} 00433 00434 /* hide assignment operator */ 00435 const Intersection &operator= ( const Intersection &i ) 00436 { 00437 real = i.real; 00438 return *this; 00439 } 00440 }; 00441 00442 //********************************************************************** 00448 template<class GridImp, template<class> class IntersectionImp> 00449 class IntersectionDefaultNormalVectors 00450 { 00451 enum { dim=GridImp::dimension }; 00452 enum { dimworld=GridImp::dimensionworld }; 00453 typedef typename GridImp::ctype ct; 00454 public: 00455 00459 FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const 00460 { 00461 FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local); 00462 n *= asImp().intersectionGlobal().integrationElement(local); 00463 return n; 00464 } 00465 00467 FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const 00468 { 00469 FieldVector<ct, dimworld> n = asImp().outerNormal(local); 00470 n /= n.two_norm(); 00471 return n; 00472 } 00473 00475 FieldVector<ct, dimworld> centerUnitOuterNormal () const 00476 { 00477 // For now, we do this... 00478 GeometryType type = asImp().geometry().type(); 00479 const GenericReferenceElement<ct, dim-1> & refElement = 00480 GenericReferenceElements<ct, dim-1>::general(type); 00481 return asImp().unitOuterNormal(refElement.position(0,0)); 00482 // But later, if we change the meaning of center(), 00483 // we may have to change to this... 00484 // return asImp().unitOuterNormal(asImp().local(asImp().center())); 00485 } 00486 00487 private: 00489 IntersectionImp<GridImp>& asImp () 00490 {return static_cast<IntersectionImp<GridImp>&>(*this);} 00491 const IntersectionImp<GridImp>& asImp () const 00492 {return static_cast<const IntersectionImp<GridImp>&>(*this);} 00493 }; 00494 00495 } 00496 00497 #endif // DUNE_GRID_INTERSECTION_HH
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].