Dune Core Modules (2.9.1)

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