dune-localfunctions  2.2.1
hierarchicalsimplexp2localinterpolation.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_HIERARCHICAL_SIMPLEX_P2_LOCALINTERPOLATION_HH
4 #define DUNE_HIERARCHICAL_SIMPLEX_P2_LOCALINTERPOLATION_HH
5 
6 #include <vector>
7 
8 namespace Dune
9 {
13  template<class LB>
15  {
16  public:
17 
18  template<typename F, typename C>
19  void interpolate (const F& f, std::vector<C>& out) const
20  {
21  typename LB::Traits::DomainType x;
22  typename LB::Traits::RangeType y;
23 
24  dune_static_assert(LB::Traits::dimDomain <=3, "LocalInterpolation for HierarchicalSimplexP2 finite elements"
25  " is only implemented for dimDomain <=3!");
26 
27  switch ( int(LB::Traits::dimDomain)) {
28 
29  case 1:
30 
31  out.resize(3);
32 
33  // First: the two vertex dofs
34  x[0] = 0.0; f.evaluate(x, y); out[0] = y;
35  x[0] = 1.0; f.evaluate(x, y); out[2] = y;
36 
37  // Then: the edge dof
38  x[0] = 0.5; f.evaluate(x, y);
39  out[1] = y - 0.5*(out[0] + out[2]);
40 
41  break;
42 
43 
44  case 2:
45 
46  out.resize(6);
47 
48  // First: the three vertex dofs
49  x[0] = 0.0; x[1] = 0.0; f.evaluate(x, y); out[0] = y;
50  x[0] = 1.0; x[1] = 0.0; f.evaluate(x, y); out[2] = y;
51  x[0] = 0.0; x[1] = 1.0; f.evaluate(x, y); out[5] = y;
52 
53  // Then: the three edge dofs
54  x[0] = 0.5; x[1] = 0.0; f.evaluate(x, y);
55  out[1] = y - 0.5*(out[0] + out[2]);
56 
57  x[0] = 0.0; x[1] = 0.5; f.evaluate(x, y);
58  out[3] = y - 0.5*(out[0] + out[5]);
59 
60  x[0] = 0.5; x[1] = 0.5; f.evaluate(x, y);
61  out[4] = y - 0.5*(out[2] + out[5]);
62 
63  break;
64 
65  case 3:
66 
67  out.resize(10);
68 
69  // First: the four vertex dofs
70  x[0] = 0.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[0] = y;
71  x[0] = 1.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[2] = y;
72  x[0] = 0.0; x[1] = 1.0; x[2] = 0.0; f.evaluate(x, y); out[5] = y;
73  x[0] = 0.0; x[1] = 0.0; x[2] = 1.0; f.evaluate(x, y); out[9] = y;
74 
75  // Then: the six edge dofs
76  x[0] = 0.5; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y);
77  out[1] = y - 0.5*(out[0] + out[2]);
78 
79  x[0] = 0.0; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
80  out[3] = y - 0.5*(out[0] + out[5]);
81 
82  x[0] = 0.5; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
83  out[4] = y - 0.5*(out[2] + out[5]);
84 
85  x[0] = 0.0; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
86  out[6] = y - 0.5*(out[0] + out[9]);
87 
88  x[0] = 0.5; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
89  out[7] = y - 0.5*(out[2] + out[9]);
90 
91  x[0] = 0.0; x[1] = 0.5; x[2] = 0.5; f.evaluate(x, y);
92  out[8] = y - 0.5*(out[5] + out[9]);
93 
94  break;
95 
96  }
97  }
98 
99  };
100 }
101 
102 #endif