DUNE PDELab (git)

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