common/intersection.hh

00001 #ifndef DUNE_GRID_INTERSECTION_HH
00002 #define DUNE_GRID_INTERSECTION_HH
00003 
00004 #include <dune/grid/common/grid.hh>
00005 
00006 namespace Dune
00007 {
00008 
00135 template<class GridImp, template<class> class IntersectionImp>
00136 class Intersection
00137 {
00138   IntersectionImp<const GridImp> real;
00139 
00140   enum { dim=GridImp::dimension };
00141   enum { dimworld=GridImp::dimensionworld };
00142 
00143 public:
00144   
00145   // type of real implementation 
00146   typedef IntersectionImp<const GridImp> ImplementationType;
00147   
00149   typedef typename GridImp::template Codim<0>::Entity Entity;
00150 
00152   typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00153 
00155   typedef typename GridImp::template Codim<1>::Geometry Geometry;
00156 
00159   typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00160 
00162   enum { dimension=dim  };
00163 
00165   enum { dimensionworld=dimworld  };
00166 
00168     typedef typename GridImp::ctype ctype;
00169 
00171     bool boundary () const
00172     {
00173       return this->real.boundary();
00174     }
00175 
00191   int boundaryId () const
00192   {
00193     return this->real.boundaryId();
00194   } 
00195 
00197   bool neighbor () const 
00198     {
00199       return this->real.neighbor();
00200     }
00201 
00205   EntityPointer inside() const
00206     {
00207       return this->real.inside();
00208     }
00209 
00216   EntityPointer outside() const
00217     {
00218       return this->real.outside();
00219     }
00220   
00231   bool conforming () const 
00232     {
00233       return this->real.conforming();
00234     }
00235 
00243   const LocalGeometry& intersectionSelfLocal () const
00244     {
00245       return this->real.intersectionSelfLocal();
00246     }
00254   const LocalGeometry& intersectionNeighborLocal () const
00255     {
00256       return this->real.intersectionNeighborLocal();
00257     }
00258 
00264   const Geometry& intersectionGlobal () const
00265     {
00266       return this->real.intersectionGlobal();
00267     }
00268 
00270     GeometryType type () const
00271     {
00272       return this->real.type();
00273     }
00274 
00276   int numberInSelf () const
00277     {
00278       return this->real.numberInSelf ();
00279     }
00280 
00282   int numberInNeighbor () const
00283     {
00284       return this->real.numberInNeighbor ();
00285     }
00286 
00291   FieldVector<ctype, dimworld> outerNormal (const FieldVector<ctype, dim-1>& local) const
00292     {
00293       return this->real.outerNormal(local);
00294     }
00295 
00302   FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const
00303     {
00304       return this->real.integrationOuterNormal(local);
00305     }
00306 
00312   FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const
00313     {
00314       return this->real.unitOuterNormal(local);
00315     }
00316 
00317   //===========================================================
00321   //===========================================================
00322 
00324   Intersection(const IntersectionImp<const GridImp> & i) :
00325     real(i) {};
00326 
00328   Intersection(const Intersection& i) :
00329     real(i.real) {}
00331 
00332   typedef typename remove_const<GridImp>::type mutableGridImp;
00333 protected:
00334   // give the GridDefaultImplementation class access to the realImp 
00335   friend class GridDefaultImplementation<
00336             GridImp::dimension, GridImp::dimensionworld,
00337             typename GridImp::ctype,
00338             typename GridImp::GridFamily> ;
00339 
00341   ImplementationType & getRealImp() { return real; }
00343   const ImplementationType & getRealImp() const { return real; }
00344 
00345 };
00346 
00347 //**********************************************************************
00353 template<class GridImp, template<class> class IntersectionImp>
00354 class IntersectionDefaultNormalVectors
00355 {
00356   enum { dim=GridImp::dimension };
00357   enum { dimworld=GridImp::dimensionworld };
00358   typedef typename GridImp::ctype ct;
00359 public:
00363   FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
00364     {
00365         FieldVector<ct, dimworld> n = unitOuterNormal(local);
00366         n *= asImp().intersectionGlobal().integrationElement(local);
00367         return n;
00368     }
00370   FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
00371     {
00372       FieldVector<ct, dimworld> n = asImp().outerNormal(local);
00373       n /= n.two_norm();
00374       return n;
00375     }
00376 
00377 private:
00379   IntersectionImp<GridImp>& asImp ()
00380     {return static_cast<IntersectionImp<GridImp>&>(*this);}
00381   const IntersectionImp<GridImp>& asImp () const
00382     {return static_cast<const IntersectionImp<GridImp>&>(*this);}
00383 };
00384 
00385 }
00386 
00387 #endif // DUNE_GRID_INTERSECTION_HH

Generated on Sun Nov 15 22:28:42 2009 for dune-grid by  doxygen 1.5.6