Dune Core Modules (unstable)

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