FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
hammer_stroud_driver.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/cubature/driver_base.hpp>
10#include <kernel/util/math.hpp>
11#include <kernel/util/meta_math.hpp>
12
13namespace FEAT
14{
15 namespace Cubature
16 {
29 template<typename Shape_>
30 class HammerStroudD2Driver DOXY({});
31
32 // Simplex specialization
33 template<int dim_>
34 class HammerStroudD2Driver<Shape::Simplex<dim_> > :
35 public DriverBase<Shape::Simplex<dim_> >
36 {
37 public:
39 static constexpr bool variadic = false;
40 static constexpr int num_points = dim_ + 1;
41
43 static String name()
44 {
45 return "hammer-stroud-degree-2";
46 }
47
54 template<
55 typename Weight_,
56 typename Coord_,
57 typename Point_>
58 static void fill(Rule<Shape::Simplex<dim_>, Weight_, Coord_, Point_>& rule)
59 {
60 // auxiliary variables
61 Coord_ r = (Coord_(dim_ + 2) - Math::sqrt(Coord_(dim_ + 2)))/
62 (Coord_(dim_ + 2) * Coord_(dim_ + 1));
63 Coord_ s = (Coord_(dim_ + 2) + Coord_(dim_) * Math::sqrt(Coord_(dim_ + 2)))/
64 (Coord_(dim_ + 2) * Coord_(dim_ + 1));
65
66 for(int i(0); i <= dim_; ++i)
67 {
68 // set weight
69 rule.get_weight(i) = Weight_(1) / Weight_(MetaMath::Factorial<dim_ + 1>::value);
70
71 // set point coords
72 for(int j(0); j < dim_; ++j)
73 {
74 rule.get_coord(i,j) = (i == j) ? s : r;
75 }
76 }
77 }
78 }; // class HammerStroudD2Driver<Simplex<...>,...>
79
92 template<typename Shape_>
93 class HammerStroudD3Driver DOXY({});
94
95 // Simplex specialization
96 template<int dim_>
97 class HammerStroudD3Driver<Shape::Simplex<dim_> > :
98 public DriverBase<Shape::Simplex<dim_> >
99 {
100 public:
102 static constexpr bool variadic = false;
103 static constexpr int num_points = dim_ + 2;
104
106 static String name()
107 {
108 return "hammer-stroud-degree-3";
109 }
110
117 template<
118 typename Weight_,
119 typename Coord_,
120 typename Point_>
121 static void fill(Rule<Shape::Simplex<dim_>, Weight_, Coord_, Point_>& rule)
122 {
123 // auxiliary variables
124 Weight_ V = Weight_(1) / Weight_(MetaMath::Factorial<dim_>::value);
125 Weight_ B = - Weight_((dim_ + 1)*(dim_ + 1))/Weight_(4*dim_ + 8) * V;
126 Weight_ C = Weight_((dim_ + 3)*(dim_ + 3))/Weight_(4*(dim_ + 1)*(dim_ + 2)) * V;
127
128 // B-point
129 rule.get_weight(0) = B;
130 for(int j(0); j < dim_; ++j)
131 {
132 rule.get_coord(0,j) = Coord_(1) / Coord_(dim_ + 1);
133 }
134
135 // C-points
136 int count = 0;
137
138 for(int i(0); i <= dim_; ++i)
139 {
140 ++count;
141
142 // set weight
143 rule.get_weight(count) = C;
144
145 // set point coords
146 for(int j(0); j < dim_; ++j)
147 {
148 rule.get_coord(count,j) = Coord_((i == j) ? 3 : 1) / Coord_(dim_ + 3);
149 }
150 }
151
152 }
153 }; // class HammerStroudD3Driver<Simplex<...>,...>
154
167 template<typename Shape_>
168 class HammerStroudD5Driver DOXY({});
169
170 // Simplex specialization
171 template<>
172 class HammerStroudD5Driver<Shape::Simplex<3> > :
173 public DriverBase<Shape::Simplex<3> >
174 {
175 public:
177 static constexpr bool variadic = false;
178 static constexpr int dim = 3;
179 static constexpr int num_points = 15;
180
182 static String name()
183 {
184 return "hammer-stroud-degree-5";
185 }
186
193 template<
194 typename Weight_,
195 typename Coord_,
196 typename Point_>
197 static void fill(Rule<Shape::Simplex<3>, Weight_, Coord_, Point_>& rule)
198 {
199 // auxiliary variables
200 Weight_ V = Weight_(1) / Weight_(MetaMath::Factorial<dim>::value);
201 Weight_ A = Weight_(16)/Weight_(135) * V;
202 Weight_ B1 = (Weight_(2665) + Weight_(14)*Math::sqrt(Weight_(15)))/Weight_(37800)*V;
203 Weight_ B2 = (Weight_(2665) - Weight_(14)*Math::sqrt(Weight_(15)))/Weight_(37800)*V;
204 Weight_ C = Weight_(20)/Weight_(378)*V;
205
206 Coord_ s1 = (Coord_(7) - Math::sqrt(Coord_(15)))/Coord_(34);
207 Coord_ s2 = (Coord_(7) + Math::sqrt(Coord_(15)))/Coord_(34);
208 Coord_ t1 = (Coord_(13) + Coord_(3)*Math::sqrt(Coord_(15)))/Coord_(34);
209 Coord_ t2 = (Coord_(13) - Coord_(3)*Math::sqrt(Coord_(15)))/Coord_(34);
210 Coord_ u = (Coord_(10) - Coord_(2)*Math::sqrt(Coord_(15)))/Coord_(40);
211 Coord_ v = (Coord_(10) + Coord_(2)*Math::sqrt(Coord_(15)))/Coord_(40);
212
213 // counter
214 int count = 0;
215
216 // A-point
217 rule.get_weight(count) = A;
218 for(int j(0); j < dim; ++j)
219 {
220 rule.get_coord(count,j) = Coord_(1)/Coord_(4);
221 }
222 ++count;
223
224 // B1-points
225 for(int i(0); i <= dim; ++i)
226 {
227 // set weight
228 rule.get_weight(count) = B1;
229
230 // set point coords
231 for(int j(0); j < dim; ++j)
232 {
233 rule.get_coord(count,j) = (i == j) ? t1 : s1;
234 }
235 ++count;
236 }
237
238 // B2-points
239 for(int i(0); i <= dim; ++i)
240 {
241
242 // set weight
243 rule.get_weight(count) = B2;
244
245 // set point coords
246 for(int j(0); j < dim; ++j)
247 {
248 rule.get_coord(count,j) = (i == j) ? t2 : s2;
249 }
250 ++count;
251 }
252
253 // C-points
254 for(int i(0); i <= dim; ++i)
255 {
256 for(int j(0); j < i; ++j)
257 {
258 if(i != j)
259 {
260 // set weight
261 rule.get_weight(count) = C;
262
263 // set point coords
264 for(int k(0); k < dim; ++k)
265 {
266 rule.get_coord(count,k) = (k == i) || (k == j) ? u : v;
267 }
268 ++count;
269 }
270 }
271 }
272 }
273 }; // class HammerStroudD5Driver<Simplex<3>,...>
274 } // namespace Cubature
275} // namespace FEAT
static void fill(Rule< Shape::Simplex< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
static String name()
Returns the name of the cubature rule.
Hammer-Stroud-D2 driver class template.
static void fill(Rule< Shape::Simplex< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
static String name()
Returns the name of the cubature rule.
Hammer-Stroud-D3 driver class template.
static String name()
Returns the name of the cubature rule.
static void fill(Rule< Shape::Simplex< 3 >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
Hammer-Stroud-D5 driver class template.
Cubature Rule class template.
Definition: rule.hpp:38
String class implementation.
Definition: string.hpp:46
T_ sqrt(T_ x)
Returns the square-root of a value.
Definition: math.hpp:300
FEAT namespace.
Definition: adjactor.hpp:12
Factorial template meta-program.
Definition: meta_math.hpp:31
Simplex shape tag struct template.
Definition: shape.hpp:44