FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
validate_structured_meshes.cpp
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#include <kernel/geometry/test_aux/validate_structured_meshes.hpp>
7#include <kernel/geometry/test_aux/copy_comp_set.hpp>
8
9namespace FEAT
10{
11 namespace Geometry
12 {
13 namespace TestAux
14 {
15 void validate_structured_mesh_2d(const StructuredMesh<2>* mesh)
16 {
17
18 // validate sizes
19 if(mesh->get_num_entities(0) != 21)
20 throw String("Vertex count mismatch");
21 if(mesh->get_num_entities(1) != 32)
22 throw String("Edge count mismatch");
23 if(mesh->get_num_entities(2) != 12)
24 throw String("Quad count mismatch");
25
26 // vertices-at-edge array
27 static const Index v_e[] =
28 {
29 0, 1,
30 1, 2,
31 2, 3,
32 3, 4,
33 4, 5,
34 5, 6,
35 7, 8,
36 8, 9,
37 9, 10,
38 10, 11,
39 11, 12,
40 12, 13,
41 14, 15,
42 15, 16,
43 16, 17,
44 17, 18,
45 18, 19,
46 19, 20,
47
48 0, 7,
49 7, 14,
50 1, 8,
51 8, 15,
52 2, 9,
53 9, 16,
54 3, 10,
55 10, 17,
56 4, 11,
57 11, 18,
58 5, 12,
59 12, 19,
60 6, 13,
61 13, 20
62 };
63
64 // vertices-at-quad array
65 static const Index v_q[] =
66 {
67 0, 1, 7, 8,
68 1, 2, 8, 9,
69 2, 3, 9, 10,
70 3, 4, 10, 11,
71 4, 5, 11, 12,
72 5, 6, 12, 13,
73 7, 8, 14, 15,
74 8, 9, 15, 16,
75 9, 10, 16, 17,
76 10, 11, 17, 18,
77 11, 12, 18, 19,
78 12, 13, 19, 20
79 };
80
81 // edges-at-quad array
82 static const Index e_q[] =
83 {
84 0, 6, 18, 20,
85 1, 7, 20, 22,
86 2, 8, 22, 24,
87 3, 9, 24, 26,
88 4, 10, 26, 28,
89 5, 11, 28, 30,
90
91 6, 12, 19, 21,
92 7, 13, 21, 23,
93 8, 14, 23, 25,
94 9, 15, 25, 27,
95 10, 16, 27, 29,
96 11, 17, 29, 31
97 };
98
99 // get struct- index sets
100 const StructIndexSet<2,1,0>& set_v_e = mesh->get_index_set<1,0>();
101 const StructIndexSet<2,2,0>& set_v_q = mesh->get_index_set<2,0>();
102 const StructIndexSet<2,2,1>& set_e_q = mesh->get_index_set<2,1>();
103
104 // check vertex at edge
105 Index i(0);
106 for(Index j(0); j < 32; ++j)
107 {
108 for(int k(0); k < 2; ++k)
109 {
110 if(set_v_e(j,k) != v_e[i])
111 {
112 throw String("Vertex-At-Edge index set error");
113 }
114 ++i;
115 }
116 }
117
118 // check vertex at quad
119 i = 0;
120 for(Index j(0); j < 12; ++j)
121 {
122 for(int k(0); k < 4; ++k)
123 {
124 if(set_v_q(j,k) != v_q[i])
125 {
126 throw String("Vertex-At-Quad index set error");
127 }
128 ++i;
129 }
130 }
131
132 //check edge at quad
133 i = 0;
134 for(Index j(0); j < 12; ++j)
135 {
136 for(int k(0); k < 4; ++k)
137 {
138 if(set_e_q(j,k) != e_q[i])
139 {
140 throw String("Edge-At-Quad index set error");
141 }
142 ++i;
143 }
144 }
145 } // validate_structured_mesh_2d
146
147 void validate_structured_mesh_3d(const StructuredMesh<3>* mesh)
148 {
149
150 // validate sizes
151 if(mesh->get_num_entities(0) != 60)
152 throw String("Vertex count mismatch");
153 if(mesh->get_num_entities(1) != 133)
154 throw String("Edge count mismatch");
155 if(mesh->get_num_entities(2) != 98)
156 throw String("Quad count mismatch");
157 if(mesh->get_num_entities(3) != 24)
158 throw String("Hexa count mismatch");
159
160 // vertices-at-edge array
161 static const Index v_e[] =
162 {
163 // x direction
164 0, 1,
165 1, 2,
166 2, 3,
167 3, 4,
168
169 5, 6,
170 6, 7,
171 7, 8,
172 8, 9,
173
174 10, 11,
175 11, 12,
176 12, 13,
177 13, 14,
178
179 15, 16,
180 16, 17,
181 17, 18,
182 18, 19,
183
184 20, 21,
185 21, 22,
186 22, 23,
187 23, 24,
188
189 25, 26,
190 26, 27,
191 27, 28,
192 28, 29,
193
194 30, 31,
195 31, 32,
196 32, 33,
197 33, 34,
198
199 35, 36,
200 36, 37,
201 37, 38,
202 38, 39,
203
204 40, 41,
205 41, 42,
206 42, 43,
207 43, 44,
208
209 45, 46,
210 46, 47,
211 47, 48,
212 48, 49,
213
214 50, 51,
215 51, 52,
216 52, 53,
217 53, 54,
218
219 55, 56,
220 56, 57,
221 57, 58,
222 58, 59,
223
224 // y direction
225 0, 5,
226 5, 10,
227 1, 6,
228 6, 11,
229 2, 7,
230 7, 12,
231 3, 8,
232 8, 13,
233 4, 9,
234 9, 14,
235 15, 20,
236 20, 25,
237 16, 21,
238 21, 26,
239 17, 22,
240 22, 27,
241 18, 23,
242 23, 28,
243 19, 24,
244 24, 29,
245 30, 35,
246 35, 40,
247 31, 36,
248 36, 41,
249 32, 37,
250 37, 42,
251 33, 38,
252 38, 43,
253 34, 39,
254 39, 44,
255 45, 50,
256 50, 55,
257 46, 51,
258 51, 56,
259 47, 52,
260 52, 57,
261 48, 53,
262 53, 58,
263 49, 54,
264 54, 59,
265
266 // z direction
267 0, 15,
268 15, 30,
269 30, 45,
270 1, 16,
271 16, 31,
272 31, 46,
273 2, 17,
274 17, 32,
275 32, 47,
276 3, 18,
277 18, 33,
278 33, 48,
279 4, 19,
280 19, 34,
281 34, 49,
282
283 5, 20,
284 20, 35,
285 35, 50,
286 6, 21,
287 21, 36,
288 36, 51,
289 7, 22,
290 22, 37,
291 37, 52,
292 8, 23,
293 23, 38,
294 38, 53,
295 9, 24,
296 24, 39,
297 39, 54,
298
299 10, 25,
300 25, 40,
301 40, 55,
302 11, 26,
303 26, 41,
304 41, 56,
305 12, 27,
306 27, 42,
307 42, 57,
308 13, 28,
309 28, 43,
310 43, 58,
311 14, 29,
312 29, 44,
313 44, 59
314 };
315
316 // vertices-at-quad array
317 static const Index v_q[] =
318 {
319 // z normal
320 0, 1, 5, 6,
321 1, 2, 6, 7,
322 2, 3, 7, 8,
323 3, 4, 8, 9,
324 5, 6, 10, 11,
325 6, 7, 11, 12,
326 7, 8, 12, 13,
327 8, 9, 13, 14,
328 15, 16, 20, 21,
329 16, 17, 21, 22,
330 17, 18, 22, 23,
331 18, 19, 23, 24,
332 20, 21, 25, 26,
333 21, 22, 26, 27,
334 22, 23, 27, 28,
335 23, 24, 28, 29,
336 30, 31, 35, 36,
337 31, 32, 36, 37,
338 32, 33, 37, 38,
339 33, 34, 38, 39,
340 35, 36, 40, 41,
341 36, 37, 41, 42,
342 37, 38, 42, 43,
343 38, 39, 43, 44,
344 45, 46, 50, 51,
345 46, 47, 51, 52,
346 47, 48, 52, 53,
347 48, 49, 53, 54,
348 50, 51, 55, 56,
349 51, 52, 56, 57,
350 52, 53, 57, 58,
351 53, 54, 58, 59,
352
353 // y normal
354 0, 1, 15, 16,
355 1, 2, 16, 17,
356 2, 3, 17, 18,
357 3, 4, 18, 19,
358 15, 16, 30, 31,
359 16, 17, 31, 32,
360 17, 18, 32, 33,
361 18, 19, 33, 34,
362 30, 31, 45, 46,
363 31, 32, 46, 47,
364 32, 33, 47, 48,
365 33, 34, 48, 49,
366 5, 6, 20, 21,
367 6, 7, 21, 22,
368 7, 8, 22, 23,
369 8, 9, 23, 24,
370 20, 21, 35, 36,
371 21, 22, 36, 37,
372 22, 23, 37, 38,
373 23, 24, 38, 39,
374 35, 36, 50, 51,
375 36, 37, 51, 52,
376 37, 38, 52, 53,
377 38, 39, 53, 54,
378 10, 11, 25, 26,
379 11, 12, 26, 27,
380 12, 13, 27, 28,
381 13, 14, 28, 29,
382 25, 26, 40, 41,
383 26, 27, 41, 42,
384 27, 28, 42, 43,
385 28, 29, 43, 44,
386 40, 41, 55, 56,
387 41, 42, 56, 57,
388 42, 43, 57, 58,
389 43, 44, 58, 59,
390
391 // x normal
392 0, 5, 15, 20,
393 5, 10, 20, 25,
394 15, 20, 30, 35,
395 20, 25, 35, 40,
396 30, 35, 45, 50,
397 35, 40, 50, 55,
398
399 1, 6, 16, 21,
400 6, 11, 21, 26,
401 16, 21, 31, 36,
402 21, 26, 36, 41,
403 31, 36, 46, 51,
404 36, 41, 51, 56,
405
406 2, 7, 17, 22,
407 7, 12, 22, 27,
408 17, 22, 32, 37,
409 22, 27, 37, 42,
410 32, 37, 47, 52,
411 37, 42, 52, 57,
412
413 3, 8, 18, 23,
414 8, 13, 23, 28,
415 18, 23, 33, 38,
416 23, 28, 38, 43,
417 33, 38, 48, 53,
418 38, 43, 53, 58,
419
420 4, 9, 19, 24,
421 9, 14, 24, 29,
422 19, 24, 34, 39,
423 24, 29, 39, 44,
424 34, 39, 49, 54,
425 39, 44, 54, 59
426 };
427
428 // vertices-at-hexa array
429 static const Index v_h[] =
430 {
431 0, 1, 5, 6, 15, 16, 20, 21,
432 1, 2, 6, 7, 16, 17, 21, 22,
433 2, 3, 7, 8, 17, 18, 22, 23,
434 3, 4, 8, 9, 18, 19, 23, 24,
435 5, 6, 10, 11, 20, 21, 25, 26,
436 6, 7, 11, 12, 21, 22, 26, 27,
437 7, 8, 12, 13, 22, 23, 27, 28,
438 8, 9, 13, 14, 23, 24, 28, 29,
439
440 15, 16, 20, 21, 30, 31, 35, 36,
441 16, 17, 21, 22, 31, 32, 36, 37,
442 17, 18, 22, 23, 32, 33, 37, 38,
443 18, 19, 23, 24, 33, 34, 38, 39,
444 20, 21, 25, 26, 35, 36, 40, 41,
445 21, 22, 26, 27, 36, 37, 41, 42,
446 22, 23, 27, 28, 37, 38, 42, 43,
447 23, 24, 28, 29, 38, 39, 43, 44,
448
449 30, 31, 35, 36, 45, 46, 50, 51,
450 31, 32, 36, 37, 46, 47, 51, 52,
451 32, 33, 37, 38, 47, 48, 52, 53,
452 33, 34, 38, 39, 48, 49, 53, 54,
453 35, 36, 40, 41, 50, 51, 55, 56,
454 36, 37, 41, 42, 51, 52, 56, 57,
455 37, 38, 42, 43, 52, 53, 57, 58,
456 38, 39, 43, 44, 53, 54, 58, 59
457 };
458
459 // edges-at-quad array
460 static const Index e_q[] =
461 {
462 // z normal
463 0, 4, 48, 50,
464 1, 5, 50, 52,
465 2, 6, 52, 54,
466 3, 7, 54, 56,
467 4, 8, 49, 51,
468 5, 9, 51, 53,
469 6, 10, 53, 55,
470 7, 11, 55, 57,
471 12, 16, 58, 60,
472 13, 17, 60, 62,
473 14, 18, 62, 64,
474 15, 19, 64, 66,
475 16, 20, 59, 61,
476 17, 21, 61, 63,
477 18, 22, 63, 65,
478 19, 23, 65, 67,
479 24, 28, 68, 70,
480 25, 29, 70, 72,
481 26, 30, 72, 74,
482 27, 31, 74, 76,
483 28, 32, 69, 71,
484 29, 33, 71, 73,
485 30, 34, 73, 75,
486 31, 35, 75, 77,
487 36, 40, 78, 80,
488 37, 41, 80, 82,
489 38, 42, 82, 84,
490 39, 43, 84, 86,
491 40, 44, 79, 81,
492 41, 45, 81, 83,
493 42, 46, 83, 85,
494 43, 47, 85, 87,
495
496 // y normal
497 0, 12, 88, 91,
498 1, 13, 91, 94,
499 2, 14, 94, 97,
500 3, 15, 97, 100,
501 12, 24, 89, 92,
502 13, 25, 92, 95,
503 14, 26, 95, 98,
504 15, 27, 98, 101,
505 24, 36, 90, 93,
506 25, 37, 93, 96,
507 26, 38, 96, 99,
508 27, 39, 99, 102,
509 4, 16, 103, 106,
510 5, 17, 106, 109,
511 6, 18, 109, 112,
512 7, 19, 112, 115,
513 16, 28, 104, 107,
514 17, 29, 107, 110,
515 18, 30, 110, 113,
516 19, 31, 113, 116,
517 28, 40, 105, 108,
518 29, 41, 108, 111,
519 30, 42, 111, 114,
520 31, 43, 114, 117,
521 8, 20, 118, 121,
522 9, 21, 121, 124,
523 10, 22, 124, 127,
524 11, 23, 127, 130,
525 20, 32, 119, 122,
526 21, 33, 122, 125,
527 22, 34, 125, 128,
528 23, 35, 128, 131,
529 32, 44, 120, 123,
530 33, 45, 123, 126,
531 34, 46, 126, 129,
532 35, 47, 129, 132,
533
534 // x normal
535 48, 58, 88, 103,
536 49, 59, 103, 118,
537 58, 68, 89, 104,
538 59, 69, 104, 119,
539 68, 78, 90, 105,
540 69, 79, 105, 120,
541 50, 60, 91, 106,
542 51, 61, 106, 121,
543 60, 70, 92, 107,
544 61, 71, 107, 122,
545 70, 80, 93, 108,
546 71, 81, 108, 123,
547 52, 62, 94, 109,
548 53, 63, 109, 124,
549 62, 72, 95, 110,
550 63, 73, 110, 125,
551 72, 82, 96, 111,
552 73, 83, 111, 126,
553 54, 64, 97, 112,
554 55, 65, 112, 127,
555 64, 74, 98, 113,
556 65, 75, 113, 128,
557 74, 84, 99, 114,
558 75, 85, 114, 129,
559 56, 66, 100, 115,
560 57, 67, 115, 130,
561 66, 76, 101, 116,
562 67, 77, 116, 131,
563 76, 86, 102, 117,
564 77, 87, 117, 132
565 };
566
567 // edges-at-hexa array
568 static const Index e_h[] =
569 {
570 0, 4, 12, 16, 48, 50, 58, 60, 88, 91, 103, 106,
571 1, 5, 13, 17, 50, 52, 60, 62, 91, 94, 106, 109,
572 2, 6, 14, 18, 52, 54, 62, 64, 94, 97, 109, 112,
573 3, 7, 15, 19, 54, 56, 64, 66, 97, 100, 112, 115,
574 4, 8, 16, 20, 49, 51, 59, 61, 103, 106, 118, 121,
575 5, 9, 17, 21, 51, 53, 61, 63, 106, 109, 121, 124,
576 6, 10, 18, 22, 53, 55, 63, 65, 109, 112, 124, 127,
577 7, 11, 19, 23, 55, 57, 65, 67, 112, 115, 127, 130,
578 12, 16, 24, 28, 58, 60, 68, 70, 89, 92, 104, 107,
579 13, 17, 25, 29, 60, 62, 70, 72, 92, 95, 107, 110,
580 14, 18, 26, 30, 62, 64, 72, 74, 95, 98, 110, 113,
581 15, 19, 27, 31, 64, 66, 74, 76, 98, 101, 113, 116,
582 16, 20, 28, 32, 59, 61, 69, 71, 104, 107, 119, 122,
583 17, 21, 29, 33, 61, 63, 71, 73, 107, 110, 122, 125,
584 18, 22, 30, 34, 63, 65, 73, 75, 110, 113, 125, 128,
585 19, 23, 31, 35, 65, 67, 75, 77, 113, 116, 128, 131,
586 24, 28, 36, 40, 68, 70, 78, 80, 90, 93, 105, 108,
587 25, 29, 37, 41, 70, 72, 80, 82, 93, 96, 108, 111,
588 26, 30, 38, 42, 72, 74, 82, 84, 96, 99, 111, 114,
589 27, 31, 39, 43, 74, 76, 84, 86, 99, 102, 114, 117,
590 28, 32, 40, 44, 69, 71, 79, 81, 105, 108, 120, 123,
591 29, 33, 41, 45, 71, 73, 81, 83, 108, 111, 123, 126,
592 30, 34, 42, 46, 73, 75, 83, 85, 111, 114, 126, 129,
593 31, 35, 43, 47, 75, 77, 85, 87, 114, 117, 129, 132
594 };
595
596 // quad-at-hexa array
597 static const Index q_h[] =
598 {
599 0, 8, 32, 44, 68, 74,
600 1, 9, 33, 45, 74, 80,
601 2, 10, 34, 46, 80, 86,
602 3, 11, 35, 47, 86, 92,
603 4, 12, 44, 56, 69, 75,
604 5, 13, 45, 57, 75, 81,
605 6, 14, 46, 58, 81, 87,
606 7, 15, 47, 59, 87, 93,
607 8, 16, 36, 48, 70, 76,
608 9, 17, 37, 49, 76, 82,
609 10, 18, 38, 50, 82, 88,
610 11, 19, 39, 51, 88, 94,
611 12, 20, 48, 60, 71, 77,
612 13, 21, 49, 61, 77, 83,
613 14, 22, 50, 62, 83, 89,
614 15, 23, 51, 63, 89, 95,
615 16, 24, 40, 52, 72, 78,
616 17, 25, 41, 53, 78, 84,
617 18, 26, 42, 54, 84, 90,
618 19, 27, 43, 55, 90, 96,
619 20, 28, 52, 64, 73, 79,
620 21, 29, 53, 65, 79, 85,
621 22, 30, 54, 66, 85, 91,
622 23, 31, 55, 67, 91, 97
623 };
624
625 // get struct- index sets
626 const StructIndexSet<3,1,0>& set_v_e = mesh->get_index_set<1,0>();
627 const StructIndexSet<3,2,0>& set_v_q = mesh->get_index_set<2,0>();
628 const StructIndexSet<3,3,0>& set_v_h = mesh->get_index_set<3,0>();
629 const StructIndexSet<3,2,1>& set_e_q = mesh->get_index_set<2,1>();
630 const StructIndexSet<3,3,1>& set_e_h = mesh->get_index_set<3,1>();
631 const StructIndexSet<3,3,2>& set_q_h = mesh->get_index_set<3,2>();
632
633 // check vertex at edge
634 Index i(0);
635 for(Index j(0); j < 133; ++j)
636 {
637 for(int k(0); k < 2; ++k)
638 {
639 if(set_v_e(j,k) != v_e[i])
640 {
641 throw String("Vertex-At-Edge index set error");
642 }
643 ++i;
644 }
645 }
646
647 // check vertex at quad
648 i = 0;
649 for(Index j(0); j < 98; ++j)
650 {
651 for(int k(0); k < 4; ++k)
652 {
653 if(set_v_q(j,k) != v_q[i])
654 {
655 throw String("Vertex-At-Quad index set error");
656 }
657 ++i;
658 }
659 }
660
661 // check vertex at hexa
662 i = 0;
663 for(Index j(0); j < 24; ++j)
664 {
665 for(int k(0); k < 8; ++k)
666 {
667 if(set_v_h(j,k) != v_h[i])
668 {
669 throw String("Vertex-At-Hexa index set error");
670 }
671 ++i;
672 }
673 }
674
675 // check edge at quad
676 i = 0;
677 for(Index j(0); j < 98; ++j)
678 {
679 for(int k(0); k < 4; ++k)
680 {
681 if(set_e_q(j,k) != e_q[i])
682 {
683 throw String("Edge-At-Quad index set error");
684 }
685 ++i;
686 }
687 }
688
689 // check edge at hexa
690 i = 0;
691 for(Index j(0); j < 24; ++j)
692 {
693 for(int k(0); k < 12; ++k)
694 {
695 if(set_e_h(j,k) != e_h[i])
696 {
697 throw String("Edge-At-Hexa index set error");
698 }
699 ++i;
700 }
701 }
702
703 // check quad at hexa
704 i = 0;
705 for(Index j(0); j < 24; ++j)
706 {
707 for(int k(0); k < 6; ++k)
708 {
709 if(set_q_h(j,k) != q_h[i])
710 {
711 throw String("Quad-At-Hexa index set error");
712 }
713 ++i;
714 }
715 }
716
717 } // validate_structured_mesh_3d
718
719 } // namespace TestAux
720 } // namespace Geometry
721} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.