Dune Core Modules (2.6.0)

raviartthomas1cube3dlocalinterpolation.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_LOCALFUNCTIONS_RAVIARTTHOMAS1_CUBE3D_LOCALINTERPOLATION_HH
4#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS1_CUBE3D_LOCALINTERPOLATION_HH
5
6#include <vector>
7
9
10namespace Dune
11{
20 template<class LB>
22 {
23
24 public:
27 {
28 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
29 }
30
37 {
38 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
39 if (s & 1)
40 {
41 sign0 = -1.0;
42 }
43 if (s & 2)
44 {
45 sign1 = -1.0;
46 }
47 if (s & 4)
48 {
49 sign2 = -1.0;
50 }
51 if (s & 8)
52 {
53 sign3 = -1.0;
54 }
55 if (s & 16)
56 {
57 sign4 = -1.0;
58 }
59 if (s & 32)
60 {
61 sign5 = -1.0;
62 }
63
64 n0[0] = -1.0;
65 n0[1] = 0.0;
66 n0[2] = 0.0;
67 n1[0] = 1.0;
68 n1[1] = 0.0;
69 n1[2] = 0.0;
70 n2[0] = 0.0;
71 n2[1] = -1.0;
72 n2[2] = 0.0;
73 n3[0] = 0.0;
74 n3[1] = 1.0;
75 n3[2] = 0.0;
76 n4[0] = 0.0;
77 n4[1] = 0.0;
78 n4[2] = -1.0;
79 n5[0] = 0.0;
80 n5[1] = 0.0;
81 n5[2] = 1.0;
82 }
83
92 template<class F, class C>
93 void interpolate (const F& f, std::vector<C>& out) const
94 {
95 // f gives v*outer normal at a point on the edge!
96 typedef typename LB::Traits::RangeFieldType Scalar;
97 typedef typename LB::Traits::DomainFieldType Vector;
98 typename F::Traits::RangeType y;
99
100 out.resize(36);
101 fill(out.begin(), out.end(), 0.0);
102
103 const int qOrder = 3;
105
106 for (typename QuadratureRule<Scalar,2>::const_iterator it = rule1.begin();
107 it != rule1.end(); ++it)
108 {
109 Dune::FieldVector<Scalar,2> qPos = it->position();
110 typename LB::Traits::DomainType localPos;
111
112 localPos[0] = 0.0;
113 localPos[1] = qPos[0];
114 localPos[2] = qPos[1];
115 f.evaluate(localPos, y);
116 out[0] += (y[0]*n0[0] + y[1]*n0[1] + y[2]*n0[2])*it->weight()*sign0;
117 out[6] += (y[0]*n0[0] + y[1]*n0[1] + y[2]*n0[2])*(2.0*qPos[0] - 1.0)*it->weight();
118 out[12] += (y[0]*n0[0] + y[1]*n0[1] + y[2]*n0[2])*(2.0*qPos[1] - 1.0)*it->weight();
119 out[18] += (y[0]*n0[0] + y[1]*n0[1] + y[2]*n0[2])*(2.0*qPos[0] - 1.0)*(2.0*qPos[1] - 1.0)*it->weight();
120
121 localPos[0] = 1.0;
122 localPos[1] = qPos[0];
123 localPos[2] = qPos[1];
124 f.evaluate(localPos, y);
125 out[1] += (y[0]*n1[0] + y[1]*n1[1] + y[2]*n1[2])*it->weight()*sign1;
126 out[7] += (y[0]*n1[0] + y[1]*n1[1] + y[2]*n1[2])*(1.0 - 2.0*qPos[0])*it->weight();
127 out[13] += (y[0]*n1[0] + y[1]*n1[1] + y[2]*n1[2])*(1.0 - 2.0*qPos[1])*it->weight();
128 out[19] += (y[0]*n1[0] + y[1]*n1[1] + y[2]*n1[2])*(1.0 - 2.0*qPos[0])*(2.0*qPos[1] - 1.0)*it->weight();
129
130 localPos[0] = qPos[0];
131 localPos[1] = 0.0;
132 localPos[2] = qPos[1];
133 f.evaluate(localPos, y);
134 out[2] += (y[0]*n2[0] + y[1]*n2[1] + y[2]*n2[2])*it->weight()*sign2;
135 out[8] += (y[0]*n2[0] + y[1]*n2[1] + y[2]*n2[2])*(1.0 - 2.0*qPos[0])*it->weight();
136 out[14] += (y[0]*n2[0] + y[1]*n2[1] + y[2]*n2[2])*(2.0*qPos[1] - 1.0)*it->weight();
137 out[20] += (y[0]*n2[0] + y[1]*n2[1] + y[2]*n2[2])*(1.0 - 2.0*qPos[0])*(2.0*qPos[1] - 1.0)*it->weight();
138
139 localPos[0] = qPos[0];
140 localPos[1] = 1.0;
141 localPos[2] = qPos[1];
142 f.evaluate(localPos, y);
143 out[3] += (y[0]*n3[0] + y[1]*n3[1] + y[2]*n3[2])*it->weight()*sign3;
144 out[9] += (y[0]*n3[0] + y[1]*n3[1] + y[2]*n3[2])*(2.0*qPos[0] - 1.0)*it->weight();
145 out[15] += (y[0]*n3[0] + y[1]*n3[1] + y[2]*n3[2])*(1.0 - 2.0*qPos[1])*it->weight();
146 out[21] += (y[0]*n3[0] + y[1]*n3[1] + y[2]*n3[2])*(2.0*qPos[0] - 1.0)*(2.0*qPos[1] - 1.0)*it->weight();
147
148 localPos[0] = qPos[0];
149 localPos[1] = qPos[1];
150 localPos[2] = 0.0;
151 f.evaluate(localPos, y);
152 out[4] += (y[0]*n4[0] + y[1]*n4[1] + y[2]*n4[2])*it->weight()*sign4;
153 out[10] += (y[0]*n4[0] + y[1]*n4[1] + y[2]*n4[2])*(1.0 - 2.0*qPos[0])*it->weight();
154 out[16] += (y[0]*n4[0] + y[1]*n4[1] + y[2]*n4[2])*(1.0 - 2.0*qPos[1])*it->weight();
155 out[22] += (y[0]*n4[0] + y[1]*n4[1] + y[2]*n4[2])*(1.0 - 2.0*qPos[0])*(2.0*qPos[1] - 1.0)*it->weight();
156
157 localPos[0] = qPos[0];
158 localPos[1] = qPos[1];
159 localPos[2] = 1.0;
160 f.evaluate(localPos, y);
161 out[5] += (y[0]*n5[0] + y[1]*n5[1] + y[2]*n5[2])*it->weight()*sign5;
162 out[11] += (y[0]*n5[0] + y[1]*n5[1] + y[2]*n5[2])*(2.0*qPos[0] - 1.0)*it->weight();
163 out[17] += (y[0]*n5[0] + y[1]*n5[1] + y[2]*n5[2])*(2.0*qPos[1] - 1.0)*it->weight();
164 out[23] += (y[0]*n5[0] + y[1]*n5[1] + y[2]*n5[2])*(2.0*qPos[0] - 1.0)*(2.0*qPos[1] - 1.0)*it->weight();
165 }
166
168 for (typename QuadratureRule<Vector,3>::const_iterator it = rule2.begin();
169 it != rule2.end(); ++it)
170 {
171 FieldVector<double,3> qPos = it->position();
172
173 f.evaluate(qPos, y);
174 out[24] += y[0]*it->weight();
175 out[25] += y[1]*it->weight();
176 out[26] += y[2]*it->weight();
177 out[27] += y[0]*qPos[1]*it->weight();
178 out[28] += y[0]*qPos[2]*it->weight();
179 out[29] += y[1]*qPos[0]*it->weight();
180 out[30] += y[1]*qPos[2]*it->weight();
181 out[31] += y[2]*qPos[0]*it->weight();
182 out[32] += y[2]*qPos[1]*it->weight();
183 out[33] += y[0]*qPos[1]*qPos[2]*it->weight();
184 out[34] += y[1]*qPos[0]*qPos[2]*it->weight();
185 out[35] += y[2]*qPos[0]*qPos[1]*it->weight();
186 }
187 }
188
189 private:
190 typename LB::Traits::RangeFieldType sign0, sign1, sign2, sign3, sign4, sign5;
191 typename LB::Traits::DomainType n0, n1, n2, n3, n4, n5;
192 };
193}
194#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS1_CUBE3D_LOCALINTERPOLATION_HH
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Abstract base class for quadrature rules.
Definition: quadraturerules.hh:97
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:225
First order Raviart-Thomas shape functions on the reference hexahedron.
Definition: raviartthomas1cube3dlocalinterpolation.hh:22
void interpolate(const F &f, std::vector< C > &out) const
Interpolate a given function with shape functions.
Definition: raviartthomas1cube3dlocalinterpolation.hh:93
RT1Cube3DLocalInterpolation(unsigned int s)
Make set number s, where 0 <= s < 64.
Definition: raviartthomas1cube3dlocalinterpolation.hh:36
RT1Cube3DLocalInterpolation()
Standard constructor.
Definition: raviartthomas1cube3dlocalinterpolation.hh:26
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:705
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)