FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
lauffer_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/meta_math.hpp>
11
12namespace FEAT
13{
14 namespace Cubature
15 {
28 template<typename Shape_>
29 class LaufferD2Driver DOXY({});
30
31 // Simplex specialization
32 template<int dim_>
33 class LaufferD2Driver<Shape::Simplex<dim_> > :
34 public DriverBase<Shape::Simplex<dim_> >
35 {
36 public:
38 static constexpr bool variadic = false;
39 static constexpr int num_points = (dim_ + 1)*(dim_ + 2)/2;
40
42 static String name()
43 {
44 return "lauffer-degree-2";
45 }
46
53 template<
54 typename Weight_,
55 typename Coord_,
56 typename Point_>
57 static void fill(Rule<Shape::Simplex<dim_>, Weight_, Coord_, Point_>& rule)
58 {
59 // auxiliary variables
60 Weight_ V = Weight_(1) / Weight_(MetaMath::Factorial<dim_>::value);
61 Weight_ B = Weight_(2 - dim_)/Weight_((dim_ + 1)*(dim_ + 2)) * V;
62 Weight_ C = Weight_(4)/Weight_((dim_ + 1)*(dim_ + 2)) * V;
63
64 // B-points
65 for(int i(0); i <= dim_; ++i)
66 {
67 // set weight
68 rule.get_weight(i) = B;
69
70 // set point coords
71 for(int j(0); j < dim_; ++j)
72 {
73 rule.get_coord(i,j) = (i == j) ? Coord_(1) : Coord_(0);
74 }
75 }
76
77 // counter
78 int count = dim_;
79
80 // C-points
81 for(int i(1); i <= dim_; ++i)
82 {
83 for(int k(0); k < i; ++k)
84 {
85 ++count;
86 rule.get_weight(count) = C;
87
88 // set point coords
89 for(int j(0); j < dim_; ++j)
90 {
91 rule.get_coord(count,j) = ((j == k) || (j == i)) ? Coord_(1)/Coord_(2) : Coord_(0);
92 } // j-loop
93 } // k-loop
94 } // i-loop
95
96 }
97 }; // class LaufferD2Driver<Simplex<...>,...>
98
111 template<typename Shape_>
112 class LaufferD4Driver DOXY({});
113
114 // Tetrahedron specialization
115 template<>
116 class LaufferD4Driver<Shape::Simplex<3> > :
117 public DriverBase<Shape::Simplex<3> >
118 {
119 public:
121 static constexpr bool variadic = 0;
122 static constexpr int dim = 3;
123 static constexpr int num_points = (MetaMath::Factorial<dim + 4>::value)/(24*MetaMath::Factorial<dim>::value);
124
126 static String name()
127 {
128 return "lauffer-degree-4";
129 }
130
137 template<
138 typename Weight_,
139 typename Coord_,
140 typename Point_>
141 static void fill(Rule<Shape::Simplex<3>, Weight_, Coord_, Point_>& rule)
142 {
143 // auxiliary variables
144 Weight_ V = Weight_(1) / Weight_(6);
145 Weight_ B1 =
146 Weight_(-3*dim*dim*dim + 17*dim*dim - 58*dim + 72)/
147 Weight_(3*(dim + 1)*(dim + 2)*(dim + 3)*(dim + 4)) * V;
148 Weight_ B2 =
149 Weight_(16*(dim*dim - 5*dim + 12))/
150 Weight_(3*(dim + 1)*(dim + 2)*(dim + 3)*(dim + 4)) * V;
151 Weight_ B3 =
152 Weight_(4*(dim*dim - 9*dim + 12))/
153 Weight_((dim + 1)*(dim + 2)*(dim + 3)*(dim + 4)) * V;
154 Weight_ B4 =
155 Weight_(64*(4 - dim))/
156 Weight_(2*(dim + 1)*(dim + 2)*(dim + 3)*(dim + 4)) * V;
157 Weight_ B5 =
158 Weight_(256)/
159 Weight_((dim + 1)*(dim + 2)*(dim + 3)*(dim + 4)) * V;
160
161 int count = 0;
162
163 // B1-points
164 for(int i(0); i <= dim; ++i)
165 {
166 // set weight
167 rule.get_weight(count) = B1;
168
169 // set point coords
170 for(int j(0); j < dim; ++j)
171 {
172 rule.get_coord(count,j) = (i == j) ? Coord_(1) : Coord_(0);
173 }
174 ++count;
175 }
176
177 // B2-points
178 for(int i(0); i <= dim; ++i)
179 {
180 for(int j(0); j <= dim; ++j)
181 {
182 if(i != j)
183 {
184 // set weight
185 rule.get_weight(count) = B2;
186
187 // set point coords
188 for(int k(0); k < dim; ++k)
189 {
190 if(k == i)
191 {
192 rule.get_coord(count,k) = Coord_(1)/Coord_(4);
193 }
194 else if (k == j)
195 {
196 rule.get_coord(count,k) = Coord_(3)/Coord_(4);
197 }
198 else
199 {
200 rule.get_coord(count,k) = Coord_(0);
201 }
202 }
203 ++count;
204 }
205 }
206 }
207
208 // B3-points
209 for(int i(1); i <= dim; ++i)
210 {
211 for(int j(0); j < i; ++j)
212 {
213 rule.get_weight(count) = B3;
214
215 // set point coords
216 for(int k(0); k < dim; ++k)
217 {
218 rule.get_coord(count,k) = ((k == j) || (k == i)) ? Coord_(1)/Coord_(2) : Coord_(0);
219 } // k-loop
220 ++count;
221 } // j-loop
222 } // i-loop
223
224 // B4-points
225 for(int i(0); i <= dim; ++i)
226 {
227 for(int j(0); j <= dim; ++j)
228 {
229 for(int k(0); k < j; ++k)
230 {
231 if(i != j && i != k && j != k)
232 {
233 rule.get_weight(count) = B4;
234
235 // set point coords
236 for(int l(0); l < dim; ++l)
237 {
238 if(l == j || l == k)
239 {
240 rule.get_coord(count,l) = Coord_(1)/Coord_(4);
241 }
242 else if(l == i)
243 {
244 rule.get_coord(count,l) = Coord_(1)/Coord_(2);
245 }
246 else
247 {
248 rule.get_coord(count,l) = Coord_(0);
249 }
250 } // l-loop
251 ++count;
252 } // if
253 } // k-loop
254 } // j-loop
255 } //i-loop
256
257 // B5-points
258 for(int i(1); i <= dim; ++i)
259 {
260 for(int j(0); j < i; ++j)
261 {
262 for(int k(0); k < j; ++k)
263 {
264 for(int l(0); l < k; ++l)
265 {
266 rule.get_weight(count) = B5;
267
268 // set point coords
269 for(int m(0); m < dim; ++m)
270 {
271 if(m == i || m == j || m == k || m == l)
272 {
273 rule.get_coord(count,m) = Coord_(1)/Coord_(4);
274 }
275 else
276 {
277 rule.get_coord(count,m) = Coord_(0);
278 }
279 } // m-loop
280 ++count;
281 } // l-loop
282 } // k-loop
283 } // j-loop
284 } // i-loop
285 }
286 }; // class LaufferD4Driver<Simplex<3>,...>
287 } // namespace Cubature
288} // namespace FEAT
static String name()
Returns the name of the cubature rule.
static void fill(Rule< Shape::Simplex< dim_ >, Weight_, Coord_, Point_ > &rule)
Fills the cubature rule structure.
Lauffer-D2 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.
Lauffer-D4 driver class template.
Cubature Rule class template.
Definition: rule.hpp:38
String class implementation.
Definition: string.hpp:46
FEAT namespace.
Definition: adjactor.hpp:12
Factorial template meta-program.
Definition: meta_math.hpp:31
Simplex shape tag struct template.
Definition: shape.hpp:44