FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
face_ref_trafo.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#include <kernel/shape.hpp>
9#include <kernel/util/math.hpp>
10#include <kernel/util/tiny_algebra.hpp>
11
12namespace FEAT
13{
14 namespace Geometry
15 {
17 namespace Intern
18 {
26 template<typename Shape_, int face_dim_>
27#ifndef DOXYGEN
28 class FaceRefTrafo;
29#else
30 class FaceRefTrafo
31 {
32 public:
45 template<typename DataType_, int sm_, int sn_, int sl_>
46 static void compute(Tiny::Matrix<DataType_, m, n, sm_, sn_>& a, Tiny::Vector<DataType_, n, sl_>& b, int face);
47 };
48#endif // DOXYGEN
49
53 template<>
54 class FaceRefTrafo<Shape::Hypercube<2>, 1>
55 {
56 public:
57 template<typename DataType_, int sm_, int sn_, int sl_>
58 static void compute(Tiny::Matrix<DataType_, 2, 1, sm_, sn_>& a, Tiny::Vector<DataType_, 2, sl_>& b, int face)
59 {
60 switch(face)
61 {
62 case 0:
63 a(Index(0),Index(0)) = DataType_(1);
64 a(Index(1),Index(0)) = DataType_(0);
65 b(Index(0)) = DataType_(0);
66 b(Index(1)) = -DataType_(1);
67 break;
68
69 case 1:
70 a(Index(0),Index(0)) = DataType_(1);
71 a(Index(1),Index(0)) = DataType_(0);
72 b(Index(0)) = DataType_(0);
73 b(Index(1)) = +DataType_(1);
74 break;
75
76 case 2:
77 a(Index(0),Index(0)) = DataType_(0);
78 a(Index(1),Index(0)) = DataType_(1);
79 b(Index(0)) = -DataType_(1);
80 b(Index(1)) = DataType_(0);
81 break;
82
83 case 3:
84 a(Index(0),Index(0)) = DataType_(0);
85 a(Index(1),Index(0)) = DataType_(1);
86 b(Index(0)) = +DataType_(1);
87 b(Index(1)) = DataType_(0);
88 break;
89 }
90 }
91 };
92
96 template<>
97 class FaceRefTrafo<Shape::Hypercube<3>, 1>
98 {
99 public:
100 template<typename DataType_, int sm_, int sn_, int sl_>
101 static void compute(Tiny::Matrix<DataType_, 3, 1, sm_, sn_>& a, Tiny::Vector<DataType_, 3, sl_>& b, int face)
102 {
103 switch(face)
104 {
105 case 0:
106 a(Index(0),Index(0)) = DataType_(1);
107 a(Index(1),Index(0)) = DataType_(0);
108 a(Index(2),Index(0)) = DataType_(0);
109 b(Index(0)) = DataType_(0);
110 b(Index(1)) = -DataType_(1);
111 b(Index(2)) = -DataType_(1);
112 break;
113
114 case 1:
115 a(Index(0),Index(0)) = DataType_(1);
116 a(Index(1),Index(0)) = DataType_(0);
117 a(Index(2),Index(0)) = DataType_(0);
118 b(Index(0)) = DataType_(0);
119 b(Index(1)) = DataType_(1);
120 b(Index(2)) = -DataType_(1);
121 break;
122
123 case 2:
124 a(Index(0),Index(0)) = DataType_(1);
125 a(Index(1),Index(0)) = DataType_(0);
126 a(Index(2),Index(0)) = DataType_(0);
127 b(Index(0)) = DataType_(0);
128 b(Index(1)) = -DataType_(1);
129 b(Index(2)) = DataType_(1);
130 break;
131
132 case 3:
133 a(Index(0),Index(0)) = DataType_(1);
134 a(Index(1),Index(0)) = DataType_(0);
135 a(Index(2),Index(0)) = DataType_(0);
136 b(Index(0)) = DataType_(0);
137 b(Index(1)) = DataType_(1);
138 b(Index(2)) = DataType_(1);
139 break;
140
141 case 4:
142 a(Index(0),Index(0)) = DataType_(0);
143 a(Index(1),Index(0)) = DataType_(1);
144 a(Index(2),Index(0)) = DataType_(0);
145 b(Index(0)) = -DataType_(1);
146 b(Index(1)) = DataType_(0);
147 b(Index(2)) = -DataType_(1);
148 break;
149
150 case 5:
151 a(Index(0),Index(0)) = DataType_(0);
152 a(Index(1),Index(0)) = DataType_(1);
153 a(Index(2),Index(0)) = DataType_(0);
154 b(Index(0)) = DataType_(1);
155 b(Index(1)) = DataType_(0);
156 b(Index(2)) = -DataType_(1);
157 break;
158
159 case 6:
160 a(Index(0),Index(0)) = DataType_(0);
161 a(Index(1),Index(0)) = DataType_(1);
162 a(Index(2),Index(0)) = DataType_(0);
163 b(Index(0)) = -DataType_(1);
164 b(Index(1)) = DataType_(0);
165 b(Index(2)) = DataType_(1);
166 break;
167
168 case 7:
169 a(Index(0),Index(0)) = DataType_(0);
170 a(Index(1),Index(0)) = DataType_(1);
171 a(Index(2),Index(0)) = DataType_(0);
172 b(Index(0)) = DataType_(1);
173 b(Index(1)) = DataType_(0);
174 b(Index(2)) = DataType_(1);
175 break;
176
177 case 8:
178 a(Index(0),Index(0)) = DataType_(0);
179 a(Index(1),Index(0)) = DataType_(0);
180 a(Index(2),Index(0)) = DataType_(1);
181 b(Index(0)) = -DataType_(1);
182 b(Index(1)) = -DataType_(1);
183 b(Index(2)) = DataType_(0);
184 break;
185
186 case 9:
187 a(Index(0),Index(0)) = DataType_(0);
188 a(Index(1),Index(0)) = DataType_(0);
189 a(Index(2),Index(0)) = DataType_(1);
190 b(Index(0)) = DataType_(1);
191 b(Index(1)) = -DataType_(1);
192 b(Index(2)) = DataType_(0);
193 break;
194
195 case 10:
196 a(Index(0),Index(0)) = DataType_(0);
197 a(Index(1),Index(0)) = DataType_(0);
198 a(Index(2),Index(0)) = DataType_(1);
199 b(Index(0)) = -DataType_(1);
200 b(Index(1)) = DataType_(1);
201 b(Index(2)) = DataType_(0);
202 break;
203
204 case 11:
205 a(Index(0),Index(0)) = DataType_(0);
206 a(Index(1),Index(0)) = DataType_(0);
207 a(Index(2),Index(0)) = DataType_(1);
208 b(Index(0)) = DataType_(1);
209 b(Index(1)) = DataType_(1);
210 b(Index(2)) = DataType_(0);
211 break;
212 }
213 }
214 };
215
219 template<>
220 class FaceRefTrafo<Shape::Hypercube<3>, 2>
221 {
222 public:
223 template<typename DataType_, int sm_, int sn_, int sl_>
224 static void compute(Tiny::Matrix<DataType_, 3, 2, sm_, sn_>& a, Tiny::Vector<DataType_, 3, sl_>& b, int face)
225 {
226 switch(face)
227 {
228 case 0:
229 a(Index(0),Index(0)) = DataType_(1);
230 a(Index(1),Index(0)) = DataType_(0);
231 a(Index(2),Index(0)) = DataType_(0);
232 a(Index(0),Index(1)) = DataType_(0);
233 a(Index(1),Index(1)) = DataType_(1);
234 a(Index(2),Index(1)) = DataType_(0);
235 b(Index(0)) = DataType_(0);
236 b(Index(1)) = DataType_(0);
237 b(Index(2)) = -DataType_(1);
238 break;
239
240 case 1:
241 a(Index(0),Index(0)) = DataType_(1);
242 a(Index(1),Index(0)) = DataType_(0);
243 a(Index(2),Index(0)) = DataType_(0);
244 a(Index(0),Index(1)) = DataType_(0);
245 a(Index(1),Index(1)) = DataType_(1);
246 a(Index(2),Index(1)) = DataType_(0);
247 b(Index(0)) = DataType_(0);
248 b(Index(1)) = DataType_(0);
249 b(Index(2)) = DataType_(1);
250 break;
251
252 case 2:
253 a(Index(0),Index(0)) = DataType_(1);
254 a(Index(1),Index(0)) = DataType_(0);
255 a(Index(2),Index(0)) = DataType_(0);
256 a(Index(0),Index(1)) = DataType_(0);
257 a(Index(1),Index(1)) = DataType_(0);
258 a(Index(2),Index(1)) = DataType_(1);
259 b(Index(0)) = DataType_(0);
260 b(Index(1)) = -DataType_(1);
261 b(Index(2)) = DataType_(0);
262 break;
263
264 case 3:
265 a(Index(0),Index(0)) = DataType_(1);
266 a(Index(1),Index(0)) = DataType_(0);
267 a(Index(2),Index(0)) = DataType_(0);
268 a(Index(0),Index(1)) = DataType_(0);
269 a(Index(1),Index(1)) = DataType_(0);
270 a(Index(2),Index(1)) = DataType_(1);
271 b(Index(0)) = DataType_(0);
272 b(Index(1)) = DataType_(1);
273 b(Index(2)) = DataType_(0);
274 break;
275
276 case 4:
277 a(Index(0),Index(0)) = DataType_(0);
278 a(Index(1),Index(0)) = DataType_(1);
279 a(Index(2),Index(0)) = DataType_(0);
280 a(Index(0),Index(1)) = DataType_(0);
281 a(Index(1),Index(1)) = DataType_(0);
282 a(Index(2),Index(1)) = DataType_(1);
283 b(Index(0)) = -DataType_(1);
284 b(Index(1)) = DataType_(0);
285 b(Index(2)) = DataType_(0);
286 break;
287
288 case 5:
289 a(Index(0),Index(0)) = DataType_(0);
290 a(Index(1),Index(0)) = DataType_(1);
291 a(Index(2),Index(0)) = DataType_(0);
292 a(Index(0),Index(1)) = DataType_(0);
293 a(Index(1),Index(1)) = DataType_(0);
294 a(Index(2),Index(1)) = DataType_(1);
295 b(Index(0)) = DataType_(1);
296 b(Index(1)) = DataType_(0);
297 b(Index(2)) = DataType_(0);
298 break;
299 }
300 }
301 };
302
306 template<>
307 class FaceRefTrafo<Shape::Simplex<2>, 1>
308 {
309 public:
310 template<typename DataType_, int sm_, int sn_, int sl_>
311 static void compute(Tiny::Matrix<DataType_, 2, 1, sm_, sn_>& a, Tiny::Vector<DataType_, 2, sl_>& b, int face)
312 {
313 switch(face)
314 {
315 case 0:
316 a(Index(0),Index(0)) = -DataType_(1);
317 a(Index(1),Index(0)) = DataType_(1);
318 b(Index(0)) = DataType_(1);
319 b(Index(1)) = DataType_(0);
320 break;
321
322 case 1:
323 a(Index(0),Index(0)) = DataType_(0);
324 a(Index(1),Index(0)) = -DataType_(1);
325 b(Index(0)) = DataType_(0);
326 b(Index(1)) = DataType_(1);
327 break;
328
329 case 2:
330 a(Index(0),Index(0)) = DataType_(1);
331 a(Index(1),Index(0)) = DataType_(0);
332 b(Index(0)) = DataType_(0);
333 b(Index(1)) = DataType_(0);
334 break;
335 }
336 }
337 };
338
342 template<>
343 class FaceRefTrafo<Shape::Simplex<3>, 1>
344 {
345 public:
346 template<typename DataType_, int sm_, int sn_, int sl_>
347 static void compute(Tiny::Matrix<DataType_, 3, 1, sm_, sn_>& a, Tiny::Vector<DataType_, 3, sl_>& b, int face)
348 {
349 switch(face)
350 {
351 case 0:
352 a(Index(0),Index(0)) = DataType_(1);
353 a(Index(1),Index(0)) = DataType_(0);
354 a(Index(2),Index(0)) = DataType_(0);
355 b(Index(0)) = DataType_(0);
356 b(Index(1)) = DataType_(0);
357 b(Index(2)) = DataType_(0);
358 break;
359
360 case 1:
361 a(Index(0),Index(0)) = DataType_(0);
362 a(Index(1),Index(0)) = DataType_(1);
363 a(Index(2),Index(0)) = DataType_(0);
364 b(Index(0)) = DataType_(0);
365 b(Index(1)) = DataType_(0);
366 b(Index(2)) = DataType_(0);
367 break;
368
369 case 2:
370 a(Index(0),Index(0)) = DataType_(0);
371 a(Index(1),Index(0)) = DataType_(0);
372 a(Index(2),Index(0)) = DataType_(1);
373 b(Index(0)) = DataType_(0);
374 b(Index(1)) = DataType_(0);
375 b(Index(2)) = DataType_(0);
376 break;
377
378 case 3:
379 a(Index(0),Index(0)) = -DataType_(1);
380 a(Index(1),Index(0)) = DataType_(1);
381 a(Index(2),Index(0)) = DataType_(0);
382 b(Index(0)) = DataType_(1);
383 b(Index(1)) = DataType_(0);
384 b(Index(2)) = DataType_(0);
385 break;
386
387 case 4:
388 a(Index(0),Index(0)) = -DataType_(1);
389 a(Index(1),Index(0)) = DataType_(0);
390 a(Index(2),Index(0)) = DataType_(1);
391 b(Index(0)) = DataType_(1);
392 b(Index(1)) = DataType_(0);
393 b(Index(2)) = DataType_(0);
394 break;
395
396 case 5:
397 a(Index(0),Index(0)) = DataType_(0);
398 a(Index(1),Index(0)) = -DataType_(1);
399 a(Index(2),Index(0)) = DataType_(1);
400 b(Index(0)) = DataType_(0);
401 b(Index(1)) = DataType_(1);
402 b(Index(2)) = DataType_(0);
403 break;
404 }
405 }
406 };
407
411 template<>
412 class FaceRefTrafo<Shape::Simplex<3>, 2>
413 {
414 public:
415 template<typename DataType_, int sm_, int sn_, int sl_>
416 static void compute(Tiny::Matrix<DataType_, 3, 2, sm_, sn_>& a, Tiny::Vector<DataType_, 3, sl_>& b, int face)
417 {
418 switch(face)
419 {
420 case 0:
421 a(Index(0),Index(0)) = -DataType_(1);
422 a(Index(1),Index(0)) = DataType_(1);
423 a(Index(2),Index(0)) = DataType_(0);
424 a(Index(0),Index(1)) = -DataType_(1);
425 a(Index(1),Index(1)) = DataType_(0);
426 a(Index(2),Index(1)) = DataType_(1);
427 b(Index(0)) = DataType_(1);
428 b(Index(1)) = DataType_(0);
429 b(Index(2)) = DataType_(0);
430 break;
431
432 case 1:
433 a(Index(0),Index(0)) = DataType_(0);
434 a(Index(1),Index(0)) = DataType_(1);
435 a(Index(2),Index(0)) = DataType_(0);
436 a(Index(0),Index(1)) = DataType_(0);
437 a(Index(1),Index(1)) = DataType_(0);
438 a(Index(2),Index(1)) = DataType_(1);
439 b(Index(0)) = DataType_(0);
440 b(Index(1)) = DataType_(0);
441 b(Index(2)) = DataType_(0);
442 break;
443
444 case 2:
445 a(Index(0),Index(0)) = DataType_(1);
446 a(Index(1),Index(0)) = DataType_(0);
447 a(Index(2),Index(0)) = DataType_(0);
448 a(Index(0),Index(1)) = DataType_(0);
449 a(Index(1),Index(1)) = DataType_(0);
450 a(Index(2),Index(1)) = DataType_(1);
451 b(Index(0)) = DataType_(0);
452 b(Index(1)) = DataType_(0);
453 b(Index(2)) = DataType_(0);
454 break;
455
456 case 3:
457 a(Index(0),Index(0)) = DataType_(1);
458 a(Index(1),Index(0)) = DataType_(0);
459 a(Index(2),Index(0)) = DataType_(0);
460 a(Index(0),Index(1)) = DataType_(0);
461 a(Index(1),Index(1)) = DataType_(1);
462 a(Index(2),Index(1)) = DataType_(0);
463 b(Index(0)) = DataType_(0);
464 b(Index(1)) = DataType_(0);
465 b(Index(2)) = DataType_(0);
466 break;
467 }
468 }
469 };
470
471 } // namespace Intern
473 } // namespace Geometry
474} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.