dune-localfunctions  2.2.1
refinedp0localinterpolation.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil -*-
2 // vi: set ts=8 sw=2 et sts=2:
3 #ifndef DUNE_REFINED_P0_LOCALINTERPOLATION_HH
4 #define DUNE_REFINED_P0_LOCALINTERPOLATION_HH
5 
7 
8 namespace Dune
9 {
10  template<class LB>
12  {};
13 
14  template<class D, class R>
16  {
18  typedef typename LB::Traits::DomainType DT;
19 
20  public:
22  interpolationPoints_(4)
23  {
24  // Interpolation is done by evaluating at the subtriangle centers
25  interpolationPoints_[0][0] = 1.0/6;
26  interpolationPoints_[0][1] = 1.0/6;
27 
28  interpolationPoints_[1][0] = 4.0/6;
29  interpolationPoints_[1][1] = 1.0/6;
30 
31  interpolationPoints_[2][0] = 1.0/6;
32  interpolationPoints_[2][1] = 4.0/6;
33 
34  interpolationPoints_[3][0] = 2.0/6;
35  interpolationPoints_[3][1] = 2.0/6;
36  }
37 
38 
39  template<typename F, typename C>
40  void interpolate (const F& f, std::vector<C>& out) const
41  {
42  typename LB::Traits::RangeType y;
43  out.resize(interpolationPoints_.size());
44  for (size_t i = 0; i < out.size(); ++i)
45  {
46  f.evaluate(interpolationPoints_[i], y);
47  out[i] = y;
48  }
49  }
50 
51  private:
52  std::vector<DT> interpolationPoints_;
53  };
54 
55  template<class D, class R>
57  {
59  typedef typename LB::Traits::DomainType DT;
60 
61  public:
63  interpolationPoints_(8)
64  {
65  // Interpolation is done by evaluating at the subtriangle centers
66  interpolationPoints_[0][0] = 1.0/8;
67  interpolationPoints_[0][1] = 1.0/8;
68  interpolationPoints_[0][2] = 1.0/8;
69 
70  interpolationPoints_[1][0] = 5.0/8;
71  interpolationPoints_[1][1] = 1.0/8;
72  interpolationPoints_[1][2] = 1.0/8;
73 
74  interpolationPoints_[2][0] = 1.0/8;
75  interpolationPoints_[2][1] = 5.0/8;
76  interpolationPoints_[2][2] = 1.0/8;
77 
78  interpolationPoints_[3][0] = 1.0/8;
79  interpolationPoints_[3][1] = 1.0/8;
80  interpolationPoints_[3][2] = 5.0/8;
81 
82  interpolationPoints_[4][0] = 1.0/4;
83  interpolationPoints_[4][1] = 1.0/8;
84  interpolationPoints_[4][2] = 1.0/4;
85 
86  interpolationPoints_[5][0] = 3.0/8;
87  interpolationPoints_[5][1] = 1.0/4;
88  interpolationPoints_[5][2] = 1.0/8;
89 
90  interpolationPoints_[6][0] = 1.0/8;
91  interpolationPoints_[6][1] = 1.0/4;
92  interpolationPoints_[6][2] = 3.0/8;
93 
94  interpolationPoints_[7][0] = 1.0/4;
95  interpolationPoints_[7][1] = 3.0/8;
96  interpolationPoints_[7][2] = 1.0/4;
97  }
98 
99 
100  template<typename F, typename C>
101  void interpolate (const F& f, std::vector<C>& out) const
102  {
103  typename LB::Traits::RangeType y;
104  out.resize(interpolationPoints_.size());
105  for (size_t i = 0; i < out.size(); ++i)
106  {
107  f.evaluate(interpolationPoints_[i], y);
108  out[i] = y;
109  }
110  }
111 
112  private:
113  std::vector<DT> interpolationPoints_;
114  };
115 }
116 
117 #endif