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