dune-localfunctions  2.2.1
pk3dlocalinterpolation.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set ts=8 sw=4 et sts=4:
3 #ifndef DUNE_Pk3DLOCALINTERPOLATION_HH
4 #define DUNE_Pk3DLOCALINTERPOLATION_HH
5 
6 #include <vector>
7 
8 namespace Dune
9 {
10  template<class LB>
12  {
13  enum {N = LB::N};
14  enum {k = LB::O};
15 
16  private:
17  static const int kdiv = (k == 0 ? 1 : k);
18  public:
19 
20  template<typename F, typename C>
21  void interpolate (const F& f, std::vector<C>& out) const
22  {
23  typename LB::Traits::DomainType x;
24  typename LB::Traits::RangeType y;
25  typedef typename LB::Traits::DomainFieldType D;
26  out.resize(N);
27  int n=0;
28  for (int i2 = 0; i2 <= k; i2++)
29  for (int i1 = 0; i1 <= k-i2; i1++)
30  for (int i0 = 0; i0 <= k-i1-i2; i0++)
31  {
32  x[0] = ((D)i0)/((D)kdiv);
33  x[1] = ((D)i1)/((D)kdiv);
34  x[2] = ((D)i2)/((D)kdiv);
35  f.evaluate(x,y);
36  out[n] = y;
37  n++;
38  }
39  }
40 
41  };
42 }
43 
44 #endif