Dune Core Modules (2.8.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#include <dune/localfunctions/common/localinterpolation.hh>
8
9namespace Dune
10{
14 template<class LB>
16 {
17 public:
18
19 template<typename F, typename C>
20 void interpolate (const F& ff, std::vector<C>& out) const
21 {
22 typename LB::Traits::DomainType x;
23 typename LB::Traits::RangeType y;
24
25 auto&& f = Impl::makeFunctionWithCallOperator<decltype(x)>(ff);
26
27 static_assert(LB::Traits::dimDomain <= 3,
28 "LocalInterpolation for HierarchicalSimplexP2 finite elements"
29 " is only implemented for dimDomain <=3!");
30
31 switch ( int(LB::Traits::dimDomain)) {
32
33 case 1 :
34
35 out.resize(3);
36
37 // First: the two vertex dofs
38 x[0] = 0.0; out[0] = f(x);
39 x[0] = 1.0; out[2] = f(x);
40
41 // Then: the edge dof
42 x[0] = 0.5; y = f(x);
43 out[1] = y - 0.5*(out[0] + out[2]);
44
45 break;
46
47
48 case 2 :
49
50 out.resize(6);
51
52 // First: the three vertex dofs
53 x[0] = 0.0; x[1] = 0.0; out[0] = f(x);
54 x[0] = 1.0; x[1] = 0.0; out[2] = f(x);
55 x[0] = 0.0; x[1] = 1.0; out[5] = f(x);
56
57 // Then: the three edge dofs
58 x[0] = 0.5; x[1] = 0.0; y = f(x);
59 out[1] = y - 0.5*(out[0] + out[2]);
60
61 x[0] = 0.0; x[1] = 0.5; y = f(x);
62 out[3] = y - 0.5*(out[0] + out[5]);
63
64 x[0] = 0.5; x[1] = 0.5; y = f(x);
65 out[4] = y - 0.5*(out[2] + out[5]);
66
67 break;
68
69 case 3 :
70
71 out.resize(10);
72
73 // First: the four vertex dofs
74 x[0] = 0.0; x[1] = 0.0; x[2] = 0.0; out[0] = f(x);
75 x[0] = 1.0; x[1] = 0.0; x[2] = 0.0; out[2] = f(x);
76 x[0] = 0.0; x[1] = 1.0; x[2] = 0.0; out[5] = f(x);
77 x[0] = 0.0; x[1] = 0.0; x[2] = 1.0; out[9] = f(x);
78
79 // Then: the six edge dofs
80 x[0] = 0.5; x[1] = 0.0; x[2] = 0.0; y = f(x);
81 out[1] = y - 0.5*(out[0] + out[2]);
82
83 x[0] = 0.0; x[1] = 0.5; x[2] = 0.0; y = f(x);
84 out[3] = y - 0.5*(out[0] + out[5]);
85
86 x[0] = 0.5; x[1] = 0.5; x[2] = 0.0; y = f(x);
87 out[4] = y - 0.5*(out[2] + out[5]);
88
89 x[0] = 0.0; x[1] = 0.0; x[2] = 0.5; y = f(x);
90 out[6] = y - 0.5*(out[0] + out[9]);
91
92 x[0] = 0.5; x[1] = 0.0; x[2] = 0.5; y = f(x);
93 out[7] = y - 0.5*(out[2] + out[9]);
94
95 x[0] = 0.0; x[1] = 0.5; x[2] = 0.5; y = f(x);
96 out[8] = y - 0.5*(out[5] + out[9]);
97
98 break;
99
100 }
101 }
102
103 };
104}
105
106#endif
Definition: hierarchicalsimplexp2localinterpolation.hh:16
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)