dune-localfunctions 3.0-git
raviartthomas02dlocalinterpolation.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_RT02DLOCALINTERPOLATION_HH
4#define DUNE_RT02DLOCALINTERPOLATION_HH
5
6#include <cmath>
7#include <vector>
8#include <dune/common/exceptions.hh>
9
10namespace Dune
11{
12 template<class LB>
14 {
15 public:
16
19 {
20 sign0 = sign1 = sign2 = 1.0;
21 }
22
24 RT02DLocalInterpolation (unsigned int s)
25 {
26 sign0 = sign1 = sign2 = 1.0;
27 if (s&1) sign0 *= -1.0;
28 if (s&2) sign1 *= -1.0;
29 if (s&4) sign2 *= -1.0;
30 m0[0] = 0.5; m0[1] = 0.0;
31 m1[0] = 0.0; m1[1] = 0.5;
32 m2[0] = 0.5; m2[1] = 0.5;
33 n0[0] = 0.0; n0[1] = -1.0;
34 n1[0] = -1.0; n1[1] = 0.0;
35 n2[0] = 1.0/sqrt(2.0); n2[1] = 1.0/sqrt(2.0);
36 c0 = ( 0.5*n0[0] - 1.0*n0[1]);
37 c1 = (-1.0*n1[0] + 0.5*n1[1]);
38 c2 = ( 0.5*n2[0] + 0.5*n2[1]);
39 }
40
41 template<typename F, typename C>
42 void interpolate (const F& f, std::vector<C>& out) const
43 {
44 // f gives v*outer normal at a point on the edge!
45 typename F::Traits::RangeType y;
46
47 out.resize(3);
48
49 f.evaluate(m0,y); out[0] = (y[0]*n0[0]+y[1]*n0[1])*sign0/c0;
50 f.evaluate(m1,y); out[1] = (y[0]*n1[0]+y[1]*n1[1])*sign1/c1;
51 f.evaluate(m2,y); out[2] = (y[0]*n2[0]+y[1]*n2[1])*sign2/c2;
52 }
53
54 private:
55 typename LB::Traits::RangeFieldType sign0,sign1,sign2;
56 typename LB::Traits::DomainType m0,m1,m2;
57 typename LB::Traits::DomainType n0,n1,n2;
58 typename LB::Traits::RangeFieldType c0,c1,c2;
59 };
60}
61
62#endif
Definition brezzidouglasmarini1cube2d.hh:14
Definition raviartthomas02dlocalinterpolation.hh:14
RT02DLocalInterpolation()
Standard constructor.
Definition raviartthomas02dlocalinterpolation.hh:18
RT02DLocalInterpolation(unsigned int s)
Make set numer s, where 0<=s<8.
Definition raviartthomas02dlocalinterpolation.hh:24
void interpolate(const F &f, std::vector< C > &out) const
Definition raviartthomas02dlocalinterpolation.hh:42