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