dune-grid
2.2.0
|
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 namespace Dune 00010 { 00011 00162 template<class GridImp, template<class> class IntersectionImp> 00163 class Intersection 00164 { 00165 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS 00166 public: 00167 #else 00168 protected: 00169 // give the GridDefaultImplementation class access to the realImp 00170 friend class GridDefaultImplementation< 00171 GridImp::dimension, GridImp::dimensionworld, 00172 typename GridImp::ctype, 00173 typename GridImp::GridFamily> ; 00174 #endif 00175 // type of underlying implementation, for internal use only 00176 typedef IntersectionImp< const GridImp > Implementation; 00177 00179 Implementation &impl () { return real; } 00181 const Implementation &impl () const { return real; } 00182 00183 protected: 00184 Implementation real; 00185 00186 enum { dim=GridImp::dimension }; 00187 enum { dimworld=GridImp::dimensionworld }; 00188 00189 public: 00191 typedef typename GridImp::template Codim<0>::Entity Entity; 00192 00194 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer; 00195 00197 typedef typename GridImp::template Codim<1>::Geometry Geometry; 00198 00200 typedef typename Geometry::LocalCoordinate LocalCoordinate; 00201 00203 typedef typename Geometry::GlobalCoordinate GlobalCoordinate; 00204 00206 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; 00207 00209 enum { codimension=1 }; 00210 00212 enum { dimension=dim }; 00213 00215 enum { mydimension=dim-1 }; 00216 00218 enum { dimensionworld=dimworld }; 00219 00221 typedef typename GridImp::ctype ctype; 00222 00224 bool boundary () const 00225 { 00226 return this->real.boundary(); 00227 } 00228 00244 int boundaryId () const 00245 // allow to use boundary id without warning when experimental is enabled 00246 #if ! DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS 00247 DUNE_DEPRECATED 00248 #endif 00249 { 00250 return this->real.boundaryId(); 00251 } 00252 00264 size_t boundarySegmentIndex () const 00265 { 00266 return this->real.boundarySegmentIndex(); 00267 } 00268 00270 bool neighbor () const 00271 { 00272 return this->real.neighbor(); 00273 } 00274 00278 EntityPointer inside() const 00279 { 00280 return this->real.inside(); 00281 } 00282 00289 EntityPointer outside() const 00290 { 00291 return this->real.outside(); 00292 } 00293 00304 bool conforming () const 00305 { 00306 return this->real.conforming(); 00307 } 00308 00322 LocalGeometry geometryInInside () const 00323 { 00324 return this->real.geometryInInside(); 00325 } 00326 00340 LocalGeometry geometryInOutside () const 00341 { 00342 return this->real.geometryInOutside(); 00343 } 00344 00356 Geometry geometry () const 00357 { 00358 return this->real.geometry(); 00359 } 00360 00362 GeometryType type () const 00363 { 00364 return this->real.type(); 00365 } 00366 00376 int indexInInside () const 00377 { 00378 return this->real.indexInInside(); 00379 } 00380 00390 int indexInOutside () const 00391 { 00392 return this->real.indexInOutside(); 00393 } 00394 00399 GlobalCoordinate outerNormal (const LocalCoordinate& local) const 00400 { 00401 return this->real.outerNormal(local); 00402 } 00403 00410 GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const 00411 { 00412 return this->real.integrationOuterNormal(local); 00413 } 00414 00420 GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const 00421 { 00422 return this->real.unitOuterNormal(local); 00423 } 00424 00431 GlobalCoordinate centerUnitOuterNormal () const 00432 { 00433 return this->real.centerUnitOuterNormal(); 00434 } 00435 00436 //=========================================================== 00440 //=========================================================== 00441 00443 Intersection(const IntersectionImp<const GridImp> & i) : 00444 real(i) {}; 00446 00447 typedef typename remove_const<GridImp>::type mutableGridImp; 00448 protected: 00451 friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>; 00452 00453 /* hide copy constructor */ 00454 Intersection ( const Intersection &i ) 00455 : real( i.real ) 00456 {} 00457 00458 /* hide assignment operator */ 00459 const Intersection &operator= ( const Intersection &i ) 00460 { 00461 real = i.real; 00462 return *this; 00463 } 00464 }; 00465 00466 //********************************************************************** 00472 template<class GridImp, template<class> class IntersectionImp> 00473 class IntersectionDefaultNormalVectors 00474 { 00475 enum { dim=GridImp::dimension }; 00476 enum { dimworld=GridImp::dimensionworld }; 00477 typedef typename GridImp::ctype ct; 00478 public: 00479 00483 FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const 00484 { 00485 FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local); 00486 n *= asImp().intersectionGlobal().integrationElement(local); 00487 return n; 00488 } 00489 00491 FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const 00492 { 00493 FieldVector<ct, dimworld> n = asImp().outerNormal(local); 00494 n /= n.two_norm(); 00495 return n; 00496 } 00497 00499 FieldVector<ct, dimworld> centerUnitOuterNormal () const 00500 { 00501 // For now, we do this... 00502 GeometryType type = asImp().geometry().type(); 00503 const GenericReferenceElement<ct, dim-1> & refElement = 00504 GenericReferenceElements<ct, dim-1>::general(type); 00505 return asImp().unitOuterNormal(refElement.position(0,0)); 00506 // But later, if we change the meaning of center(), 00507 // we may have to change to this... 00508 // return asImp().unitOuterNormal(asImp().local(asImp().center())); 00509 } 00510 00511 private: 00513 IntersectionImp<GridImp>& asImp () 00514 {return static_cast<IntersectionImp<GridImp>&>(*this);} 00515 const IntersectionImp<GridImp>& asImp () const 00516 {return static_cast<const IntersectionImp<GridImp>&>(*this);} 00517 }; 00518 00519 } // namespace Dune 00520 00521 #endif // DUNE_GRID_INTERSECTION_HH