Dune Core Modules (2.6.0)

hierarchicalsimplexp2localinterpolation.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 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  static_assert(LB::Traits::dimDomain <= 3,
25  "LocalInterpolation for HierarchicalSimplexP2 finite elements"
26  " is only implemented for dimDomain <=3!");
27 
28  switch ( int(LB::Traits::dimDomain)) {
29 
30  case 1 :
31 
32  out.resize(3);
33 
34  // First: the two vertex dofs
35  x[0] = 0.0; f.evaluate(x, y); out[0] = y;
36  x[0] = 1.0; f.evaluate(x, y); out[2] = y;
37 
38  // Then: the edge dof
39  x[0] = 0.5; f.evaluate(x, y);
40  out[1] = y - 0.5*(out[0] + out[2]);
41 
42  break;
43 
44 
45  case 2 :
46 
47  out.resize(6);
48 
49  // First: the three vertex dofs
50  x[0] = 0.0; x[1] = 0.0; f.evaluate(x, y); out[0] = y;
51  x[0] = 1.0; x[1] = 0.0; f.evaluate(x, y); out[2] = y;
52  x[0] = 0.0; x[1] = 1.0; f.evaluate(x, y); out[5] = y;
53 
54  // Then: the three edge dofs
55  x[0] = 0.5; x[1] = 0.0; f.evaluate(x, y);
56  out[1] = y - 0.5*(out[0] + out[2]);
57 
58  x[0] = 0.0; x[1] = 0.5; f.evaluate(x, y);
59  out[3] = y - 0.5*(out[0] + out[5]);
60 
61  x[0] = 0.5; x[1] = 0.5; f.evaluate(x, y);
62  out[4] = y - 0.5*(out[2] + out[5]);
63 
64  break;
65 
66  case 3 :
67 
68  out.resize(10);
69 
70  // First: the four vertex dofs
71  x[0] = 0.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[0] = y;
72  x[0] = 1.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[2] = y;
73  x[0] = 0.0; x[1] = 1.0; x[2] = 0.0; f.evaluate(x, y); out[5] = y;
74  x[0] = 0.0; x[1] = 0.0; x[2] = 1.0; f.evaluate(x, y); out[9] = y;
75 
76  // Then: the six edge dofs
77  x[0] = 0.5; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y);
78  out[1] = y - 0.5*(out[0] + out[2]);
79 
80  x[0] = 0.0; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
81  out[3] = y - 0.5*(out[0] + out[5]);
82 
83  x[0] = 0.5; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
84  out[4] = y - 0.5*(out[2] + out[5]);
85 
86  x[0] = 0.0; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
87  out[6] = y - 0.5*(out[0] + out[9]);
88 
89  x[0] = 0.5; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
90  out[7] = y - 0.5*(out[2] + out[9]);
91 
92  x[0] = 0.0; x[1] = 0.5; x[2] = 0.5; f.evaluate(x, y);
93  out[8] = y - 0.5*(out[5] + out[9]);
94 
95  break;
96 
97  }
98  }
99 
100  };
101 }
102 
103 #endif
Definition: hierarchicalsimplexp2localinterpolation.hh:15
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (Apr 27, 22:29, 2024)