edges02dlocalinterpolation.hh

Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil -*-
00002 #ifndef DUNE_EDGES02DLOCALINTERPOLATION_HH
00003 #define DUNE_EDGES02DLOCALINTERPOLATION_HH
00004 
00005 #include <cmath>
00006 
00007 #include <dune/grid/common/genericreferenceelements.hh>
00008 
00009 namespace Dune 
00010 {
00025   template<class LB>
00026   class EdgeS02DLocalInterpolation 
00027   {
00028   public:
00030     EdgeS02DLocalInterpolation()
00031     {
00032       s[0] = 1; s[1] = 1; s[2] = 1;
00033     }
00034 
00039     EdgeS02DLocalInterpolation(unsigned int orientations)
00040     {
00041       s[0] = 1; s[1] = 1; s[2] = 1;
00042       for(int i = 0; i < 3; ++i)
00043         if(orientations & (1<<i)) s[i] *= -1;
00044     }
00045 
00047 
00062     template<typename F, typename C, typename Geometry>
00063     void interpolateGlobal (const F& f, std::vector<C>& out,
00064                             const Geometry &geometry) const
00065     {
00066       static const GenericReferenceElement<typename LB::Traits::DomainFieldType, 2> &refElem
00067         = GenericReferenceElements<typename LB::Traits::DomainFieldType, 2>::simplex();
00068 
00069       typename LB::Traits::DomainType vertex[3];
00070       for(int i = 0; i < 3; ++i)
00071         vertex[i] = geometry.corner(i);
00072 
00073       typename LB::Traits::DomainType tangent;
00074       typename LB::Traits::DomainType x;
00075       typename LB::Traits::RangeType y;
00076 
00077       out.resize(3);
00078       for(int j = 0; j < 3; ++j) {
00079         int v0 = refElem.subEntity(j, 1, 0, 2);
00080         int v1 = refElem.subEntity(j, 1, 1, 2);
00081         if(v0 > v1) std::swap(v0, v1);
00082 
00083         tangent = vertex[v1]; tangent -= vertex[v0];
00084         x = vertex[v1]; x += vertex[v0]; x /= 2;
00085 
00086         f.evaluate(x,y);
00087 
00088         out[j] = s[j] * (tangent * y) / tangent.two_norm();
00089       }
00090     }
00091 
00092   private:
00094     typename LB::Traits::RangeFieldType s[3];
00095   };
00096 }
00097 
00098 #endif // DUNE_EDGES02DLOCALINTERPOLATION_HH
Generated on Sat Apr 24 11:15:33 2010 for dune-localfunctions by  doxygen 1.6.3