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