Dune Core Modules (2.8.0)

refinedp0localinterpolation.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_REFINED_P0_LOCALINTERPOLATION_HH
4#define DUNE_REFINED_P0_LOCALINTERPOLATION_HH
5
6#include <dune/localfunctions/refined/refinedp0/refinedp0localbasis.hh>
7#include <dune/localfunctions/common/localinterpolation.hh>
8
9namespace Dune
10{
11 template<class LB>
12 class RefinedP0LocalInterpolation
13 {};
14
15 template<class D, class R>
16 class RefinedP0LocalInterpolation<RefinedP0LocalBasis<D,R,1> >
17 {
18 typedef RefinedP0LocalBasis<D,R,1> LB;
19 typedef typename LB::Traits::DomainType DT;
20
21 public:
22 RefinedP0LocalInterpolation() :
23 interpolationPoints_(2)
24 {
25 // Interpolation is done by evaluating at the halved segments centers
26 interpolationPoints_[0][0] = 1.0/4.0;
27
28 interpolationPoints_[1][0] = 3.0/4.0;
29 }
30
31
32 template<typename F, typename C>
33 void interpolate (const F& ff, std::vector<C>& out) const
34 {
35 auto&& f = Impl::makeFunctionWithCallOperator<DT>(ff);
36
37 out.resize(interpolationPoints_.size());
38 for (size_t i = 0; i < out.size(); ++i)
39 {
40 out[i] = f(interpolationPoints_[i]);
41 }
42 }
43
44 private:
45 std::vector<DT> interpolationPoints_;
46 };
47
48 template<class D, class R>
49 class RefinedP0LocalInterpolation<RefinedP0LocalBasis<D,R,2> >
50 {
51 typedef RefinedP0LocalBasis<D,R,2> LB;
52 typedef typename LB::Traits::DomainType DT;
53
54 public:
55 RefinedP0LocalInterpolation() :
56 interpolationPoints_(4)
57 {
58 // Interpolation is done by evaluating at the subtriangle centers
59 interpolationPoints_[0][0] = 1.0/6;
60 interpolationPoints_[0][1] = 1.0/6;
61
62 interpolationPoints_[1][0] = 4.0/6;
63 interpolationPoints_[1][1] = 1.0/6;
64
65 interpolationPoints_[2][0] = 1.0/6;
66 interpolationPoints_[2][1] = 4.0/6;
67
68 interpolationPoints_[3][0] = 2.0/6;
69 interpolationPoints_[3][1] = 2.0/6;
70 }
71
72
73 template<typename F, typename C>
74 void interpolate (const F& ff, std::vector<C>& out) const
75 {
76 auto&& f = Impl::makeFunctionWithCallOperator<DT>(ff);
77
78 out.resize(interpolationPoints_.size());
79 for (size_t i = 0; i < out.size(); ++i)
80 {
81 out[i] = f(interpolationPoints_[i]);
82 }
83 }
84
85 private:
86 std::vector<DT> interpolationPoints_;
87 };
88
89 template<class D, class R>
90 class RefinedP0LocalInterpolation<RefinedP0LocalBasis<D,R,3> >
91 {
92 typedef RefinedP0LocalBasis<D,R,3> LB;
93 typedef typename LB::Traits::DomainType DT;
94
95 public:
96 RefinedP0LocalInterpolation() :
97 interpolationPoints_(8)
98 {
99 // Interpolation is done by evaluating at the subtriangle centers
100 interpolationPoints_[0][0] = 1.0/8;
101 interpolationPoints_[0][1] = 1.0/8;
102 interpolationPoints_[0][2] = 1.0/8;
103
104 interpolationPoints_[1][0] = 5.0/8;
105 interpolationPoints_[1][1] = 1.0/8;
106 interpolationPoints_[1][2] = 1.0/8;
107
108 interpolationPoints_[2][0] = 1.0/8;
109 interpolationPoints_[2][1] = 5.0/8;
110 interpolationPoints_[2][2] = 1.0/8;
111
112 interpolationPoints_[3][0] = 1.0/8;
113 interpolationPoints_[3][1] = 1.0/8;
114 interpolationPoints_[3][2] = 5.0/8;
115
116 interpolationPoints_[4][0] = 1.0/4;
117 interpolationPoints_[4][1] = 1.0/8;
118 interpolationPoints_[4][2] = 1.0/4;
119
120 interpolationPoints_[5][0] = 3.0/8;
121 interpolationPoints_[5][1] = 1.0/4;
122 interpolationPoints_[5][2] = 1.0/8;
123
124 interpolationPoints_[6][0] = 1.0/8;
125 interpolationPoints_[6][1] = 1.0/4;
126 interpolationPoints_[6][2] = 3.0/8;
127
128 interpolationPoints_[7][0] = 1.0/4;
129 interpolationPoints_[7][1] = 3.0/8;
130 interpolationPoints_[7][2] = 1.0/4;
131 }
132
133
134 template<typename F, typename C>
135 void interpolate (const F& ff, std::vector<C>& out) const
136 {
137 auto&& f = Impl::makeFunctionWithCallOperator<DT>(ff);
138
139 out.resize(interpolationPoints_.size());
140 for (size_t i = 0; i < out.size(); ++i)
141 {
142 out[i] = f(interpolationPoints_[i]);
143 }
144 }
145
146 private:
147 std::vector<DT> interpolationPoints_;
148 };
149}
150
151#endif
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)