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