dune-localfunctions 3.0-git
qklocalinterpolation.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
4#ifndef DUNE_LOCALFUNCTIONS_QKLOCALINTERPOLATION_HH
5#define DUNE_LOCALFUNCTIONS_QKLOCALINTERPOLATION_HH
6
7#include <dune/common/fvector.hh>
8#include <dune/common/power.hh>
9
10#include <dune/geometry/type.hh>
11
14
15
16namespace Dune
17{
19 template<int k, int d, class LB>
21 {
22
23 // Return i as a d-digit number in the (k+1)-nary system
24 static Dune::FieldVector<int,d> multiindex (int i)
25 {
26 Dune::FieldVector<int,d> alpha;
27 for (int j=0; j<d; j++)
28 {
29 alpha[j] = i % (k+1);
30 i = i/(k+1);
31 }
32 return alpha;
33 }
34
35 public:
36
38 template<typename F, typename C>
39 void interpolate (const F& f, std::vector<C>& out) const
40 {
41 typename LB::Traits::DomainType x;
42 typename LB::Traits::RangeType y;
43
44 out.resize(StaticPower<k+1,d>::power);
45
46 for (int i=0; i<StaticPower<k+1,d>::power; i++)
47 {
48 // convert index i to multiindex
49 Dune::FieldVector<int,d> alpha(multiindex(i));
50
51 // Generate coordinate of the i-th Lagrange point
52 for (int j=0; j<d; j++)
53 x[j] = (1.0*alpha[j])/k;
54
55 f.evaluate(x,y); out[i] = y;
56 }
57 }
58 };
59
61 template<int d, class LB>
63 {
64 public:
66 template<typename F, typename C>
67 void interpolate (const F& f, std::vector<C>& out) const
68 {
69 typename LB::Traits::DomainType x(0);
70 typename LB::Traits::RangeType y;
71 f.evaluate(x,y);
72 out.resize(1);
73 out[0] = y;
74 }
75 };
76
77}
78
79
80#endif
Definition brezzidouglasmarini1cube2d.hh:14
Definition qklocalinterpolation.hh:21
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition qklocalinterpolation.hh:39
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition qklocalinterpolation.hh:67