edges03dlocalinterpolation.hh
Go to the documentation of this file.00001
00002 #ifndef DUNE_EDGES03DLOCALINTERPOLATION_HH
00003 #define DUNE_EDGES03DLOCALINTERPOLATION_HH
00004
00005 #include <cmath>
00006 #include <vector>
00007
00008 #include <dune/grid/common/genericreferenceelements.hh>
00009
00010 namespace Dune
00011 {
00026 template<class LB>
00027 class EdgeS03DLocalInterpolation
00028 {
00029 public:
00031 EdgeS03DLocalInterpolation()
00032 {
00033 for(int i = 0; i < 6; ++i) s[i] = 1;
00034 }
00035
00040 EdgeS03DLocalInterpolation(unsigned int orientations)
00041 {
00042 for(int i = 0; i < 6; ++i) s[i] = 1;
00043 for(int i = 0; i < 6; ++i)
00044 if(orientations & (1<<i)) s[i] *= -1;
00045 }
00046
00048
00063 template<typename F, typename C, typename Geometry>
00064 void interpolateGlobal (const F& f, std::vector<C>& out,
00065 const Geometry &geometry) const
00066 {
00067 static const GenericReferenceElement<typename LB::Traits::DomainFieldType, 3> &refElem
00068 = GenericReferenceElements<typename LB::Traits::DomainFieldType, 3>::simplex();
00069
00070 typename LB::Traits::DomainType vertex[4];
00071 for(int i = 0; i < 4; ++i)
00072 vertex[i] = geometry.corner(i);
00073
00074 typename LB::Traits::DomainType tangent;
00075 typename LB::Traits::RangeType y;
00076
00077 out.resize(6);
00078 for(int j = 0; j < 6; ++j) {
00079 int v0 = refElem.subEntity(j, 2, 0, 3);
00080 int v1 = refElem.subEntity(j, 2, 1, 3);
00081 if(v0 > v1) std::swap(v0, v1);
00082
00083 tangent = vertex[v1]; tangent -= vertex[v0];
00084
00085 f.evaluate(refElem.position(j,2),y);
00086
00087 out[j] = s[j] * (tangent * y) / tangent.two_norm();
00088 }
00089 }
00090
00091 private:
00092
00093 typename LB::Traits::RangeFieldType s[6];
00094 };
00095
00096 }
00097
00098 #endif // DUNE_EDGES03DLOCALINTERPOLATION_HH