dune-localfunctions  2.6-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 <array>
8 #include <bitset>
9 #include <vector>
10 
11 namespace Dune
12 {
13  template<class LB>
15  {
16  public:
17 
19  RT02DLocalInterpolation (std::bitset<3> s = 0)
20  {
21  for (std::size_t i=0; i<sign_.size(); i++)
22  sign_[i] = (s[i]) ? -1.0 : 1.0;
23 
24  m_[0] = {0.5, 0.0};
25  m_[1] = {0.0, 0.5};
26  m_[2] = {0.5, 0.5};
27  n_[0] = {0.0, -1.0};
28  n_[1] = {-1.0, 0.0};
29  n_[2] = {1.0/sqrt(2.0), 1.0/sqrt(2.0)};
30  c_[0] = ( 0.5*n_[0][0] - 1.0*n_[0][1]);
31  c_[1] = (-1.0*n_[1][0] + 0.5*n_[1][1]);
32  c_[2] = ( 0.5*n_[2][0] + 0.5*n_[2][1]);
33  }
34 
35  template<typename F, typename C>
36  void interpolate (const F& f, std::vector<C>& out) const
37  {
38  // f gives v*outer normal at a point on the edge!
39  typename F::Traits::RangeType y;
40 
41  out.resize(3);
42 
43  for (int i=0; i<3; i++)
44  {
45  f.evaluate(m_[i],y);
46  out[i] = (y[0]*n_[i][0]+y[1]*n_[i][1])*sign_[i]/c_[i];
47  }
48  }
49 
50  private:
51  // Edge orientations
52  std::array<typename LB::Traits::RangeFieldType,3> sign_;
53  // Edge midpoints of the reference triangle
54  std::array<typename LB::Traits::DomainType,3> m_;
55  // Unit outer normals of the reference triangle
56  std::array<typename LB::Traits::DomainType,3> n_;
57  // Inverse triangle edge length
58  std::array<typename LB::Traits::RangeFieldType,3> c_;
59  };
60 }
61 
62 #endif
RT02DLocalInterpolation(std::bitset< 3 > s=0)
Constructor with given set of edge orientations.
Definition: raviartthomas02dlocalinterpolation.hh:19
void interpolate(const F &f, std::vector< C > &out) const
Definition: raviartthomas02dlocalinterpolation.hh:36
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:15
Definition: raviartthomas02dlocalinterpolation.hh:14