raviartthomas02dlocalinterpolation.hh
Go to the documentation of this file.00001 #ifndef DUNE_RT02DLOCALINTERPOLATION_HH
00002 #define DUNE_RT02DLOCALINTERPOLATION_HH
00003
00004 #include <cmath>
00005 #include <vector>
00006 #include <dune/common/exceptions.hh>
00007
00008 namespace Dune
00009 {
00010 template<class LB>
00011 class RT02DLocalInterpolation
00012 {
00013 public:
00014
00016 RT02DLocalInterpolation ()
00017 {
00018 }
00019
00021 RT02DLocalInterpolation (unsigned int s)
00022 {
00023 sign0 = sign1 = sign2 = 1.0;
00024 if (s&1) sign0 *= -1.0;
00025 if (s&2) sign1 *= -1.0;
00026 if (s&4) sign2 *= -1.0;
00027 m0[0] = 0.5; m0[1] = 0.0;
00028 m1[0] = 0.0; m1[1] = 0.5;
00029 m2[0] = 0.5; m2[1] = 0.5;
00030 n0[0] = 0.0; n0[1] = -1.0;
00031 n1[0] = -1.0; n1[1] = 0.0;
00032 n2[0] = 1.0/sqrt(2.0); n2[1] = 1.0/sqrt(2.0);
00033 c0 = ( 0.5*n0[0] - 1.0*n0[1]);
00034 c1 = (-1.0*n1[0] + 0.5*n1[1]);
00035 c2 = ( 0.5*n2[0] + 0.5*n2[1]);
00036 }
00037
00038 template<typename F, typename C>
00039 void interpolate (const F& f, std::vector<C>& out) const
00040 {
00041
00042 typename F::Traits::RangeType y;
00043
00044 out.resize(3);
00045
00046 f.evaluate(m0,y); out[0] = (y[0]*n0[0]+y[1]*n0[1])*sign0/c0;
00047 f.evaluate(m1,y); out[1] = (y[0]*n1[0]+y[1]*n1[1])*sign1/c1;
00048 f.evaluate(m2,y); out[2] = (y[0]*n2[0]+y[1]*n2[1])*sign2/c2;
00049 }
00050
00051 private:
00052 typename LB::Traits::RangeFieldType sign0,sign1,sign2;
00053 typename LB::Traits::DomainType m0,m1,m2;
00054 typename LB::Traits::DomainType n0,n1,n2;
00055 typename LB::Traits::RangeFieldType c0,c1,c2;
00056 };
00057 }
00058
00059 #endif