FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
standard_tria.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/standard_tria.hpp>
7#include <kernel/geometry/test_aux/copy_comp_set.hpp>
8
9namespace FEAT
10{
11 namespace Geometry
12 {
13 namespace TestAux
14 {
15 TriaMesh* create_tria_mesh_2d(int orientation)
16 {
17
18 Index num_entities[] =
19 {
20 3, // vertices
21 3, // edges
22 1, // triangles
23 };
24
25 // create mesh
26 TriaMesh* mesh = new TriaMesh(num_entities);
27
28 // first possibility (standard)
29
30 /*
31 v_2
32 |\
33 | \
34 | ^
35 v \
36 | \
37 e_1 e_0
38 | \
39 | \
40 | ^
41 v \
42 | \
43 v_0->-e_2-->-v_1
44
45 triangle orientation: 0-1-2
46 */
47
48 // set up vertex coordinates array
49 static const Real vtx0[3*2] =
50 {
51 0.0, 0.0,
52 1.0, 0.0,
53 0.0, 1.0
54 };
55
56 // set up vertices-at-edge array
57 static const Index v_e0[3*2] =
58 {
59 1, 2,
60 2, 0,
61 0, 1
62 };
63
64 // set up vertices-at-triangle array
65 static const Index v_t0[3] =
66 {
67 0, 1, 2
68 };
69
70 // set up edges-at-triangle array
71 static const Index e_t0[3] =
72 {
73 0, 1, 2
74 };
75
76 // second possibility
77
78 /*
79 v_2
80 |\
81 | \
82 | v
83 v \
84 | \
85 e_1 e_0
86 | \
87 | \
88 | v
89 v \
90 | \
91 v_0->-e_2-->-v_1
92
93 triangle orientation: 0-1-2
94 */
95
96 // set up vertex coordinates array
97 static const Real vtx1[3*2] =
98 {
99 0.0, 0.0,
100 1.0, 0.0,
101 0.0, 1.0
102 };
103
104 // set up vertices-at-edge array
105 static const Index v_e1[3*2] =
106 {
107 2, 1,
108 2, 0,
109 0, 1
110 };
111
112 // set up vertices-at-triangle array
113 static const Index v_t1[3*1] =
114 {
115 0, 1, 2
116 };
117
118 // set up edges-at-triangle array
119 static const Index e_t1[1*3] =
120 {
121 0, 1, 2
122 };
123
124 // third possibility
125
126 /*
127 v_2
128 |\
129 | \
130 | v
131 v \
132 | \
133 e_1 e_2
134 | \
135 | \
136 | v
137 v \
138 | \
139 v_1-<-e_0--<-v_0
140
141 triangle orientation: 1-0-2
142 */
143
144 // set up vertex coordinates array
145 static const Real vtx2[3*2] =
146 {
147 1.0, 0.0,
148 0.0, 0.0,
149 0.0, 1.0
150 };
151
152 // set up vertices-at-edge array
153 static const Index v_e2[3*2] =
154 {
155 0, 1,
156 2, 1,
157 2, 0
158 };
159
160 // set up vertices-at-triangle array
161 static const Index v_t2[3*1] =
162 {
163 1, 0, 2
164 };
165
166 // set up edges-at-triangle array
167 static const Index e_t2[3*1] =
168 {
169 2, 1, 0
170 };
171
172 // fourth possibility
173
174 /*
175 v_0
176 |\
177 | \
178 | v
179 v \
180 | \
181 e_0 e_2
182 | \
183 | \
184 | v
185 v \
186 | \
187 v_2-<-e_1--<-v_1
188
189 triangle orientation: 0-1-2
190 */
191
192 // set up vertex coordinates array
193 static const Real vtx3[3*2] =
194 {
195 0.0, 1.0,
196 1.0, 0.0,
197 0.0, 0.0
198 };
199
200 // set up vertices-at-edge array
201 static const Index v_e3[3*2] =
202 {
203 2, 0,
204 1, 2,
205 0, 1
206 };
207
208 // set up vertices-at-triangle array
209 static const Index v_t3[3*1] =
210 {
211 2, 1, 0
212 };
213
214 // set up edges-at-triangle array
215 static const Index e_t3[3] =
216 {
217 2, 0, 1
218 };
219
220 switch(orientation)
221 {
222 case 0:
223 copy_vtx(mesh->get_vertex_set(), vtx0);
224 copy_idx(mesh->get_index_set<1,0>(), v_e0);
225 copy_idx(mesh->get_index_set<2,0>(), v_t0);
226 copy_idx(mesh->get_index_set<2,1>(), e_t0);
227 break;
228 case 1:
229 copy_vtx(mesh->get_vertex_set(), vtx1);
230 copy_idx(mesh->get_index_set<1,0>(), v_e1);
231 copy_idx(mesh->get_index_set<2,0>(), v_t1);
232 copy_idx(mesh->get_index_set<2,1>(), e_t1);
233 break;
234 case 2:
235 copy_vtx(mesh->get_vertex_set(), vtx2);
236 copy_idx(mesh->get_index_set<1,0>(), v_e2);
237 copy_idx(mesh->get_index_set<2,0>(), v_t2);
238 copy_idx(mesh->get_index_set<2,1>(), e_t2);
239 break;
240 case 3:
241 copy_vtx(mesh->get_vertex_set(), vtx3);
242 copy_idx(mesh->get_index_set<1,0>(), v_e3);
243 copy_idx(mesh->get_index_set<2,0>(), v_t3);
244 copy_idx(mesh->get_index_set<2,1>(), e_t3);
245 break;
246 default:
247 XABORTM("Unhandled orientation "+stringify(orientation));
248 }
249 // okay
250 return mesh;
251 } // create_trianglerefinement_mesh_2d
252
253 void validate_refined_tria_mesh_2d(const TriaMesh& mesh, int orientation)
254 {
255
256 // validate sizes
257 if(mesh.get_num_entities(0) != 6)
258 throw String("Vertex count mismatch");
259 if(mesh.get_num_entities(1) != 9)
260 throw String("Edge count mismatch");
261 if(mesh.get_num_entities(2) != 4)
262 throw String("Triangle count mismatch");
263
264
265 // first possibility (standard)
266
267 // vertex coordinates array
268 static const Real vtx0[] =
269 {
270 0.0, 0.0,
271 1.0, 0.0,
272 0.0, 1.0,
273 0.5, 0.5,
274 0.0, 0.5,
275 0.5, 0.0
276 };
277
278 // vertices-at-edge array
279 static const Index v_e0[] =
280 {
281 1, 3,
282 3, 2,
283 2, 4,
284 4, 0,
285 0, 5,
286 5, 1,
287 5, 4,
288 3, 5,
289 4, 3
290 };
291
292 // vertices-at-triangle
293 static const Index v_t0[] =
294 {
295 0, 5, 4,
296 5, 1, 3,
297 4, 3, 2,
298 3, 4, 5
299 };
300
301 // edges-at-triangle
302 static const Index e_t0[] =
303 {
304 6, 3, 4,
305 0, 7, 5,
306 1, 2, 8,
307 6, 7, 8
308 };
309
310 // second possibility
311
312 // vertex coordinates array
313 static const Real vtx1[] =
314 {
315 0.0, 0.0,
316 1.0, 0.0,
317 0.0, 1.0,
318 0.5, 0.5,
319 0.0, 0.5,
320 0.5, 0.0
321 };
322
323 // vertices-at-edge array
324 static const Index v_e1[] =
325 {
326 2, 3,
327 3, 1,
328 2, 4,
329 4, 0,
330 0, 5,
331 5, 1,
332 5, 4,
333 3, 5,
334 4, 3
335 };
336
337 // vertices-at-triangle
338 static const Index v_t1[] =
339 {
340 0, 5, 4,
341 5, 1, 3,
342 4, 3, 2,
343 3, 4, 5
344 };
345
346 // edges-at-triangle
347 static const Index e_t1[] =
348 {
349 6, 3, 4,
350 1, 7, 5,
351 0, 2, 8,
352 6, 7, 8
353 };
354
355 // third possibility
356
357 // vertex coordinates array
358 static const Real vtx2[] =
359 {
360 1.0, 0.0,
361 0.0, 0.0,
362 0.0, 1.0,
363 0.5, 0.0,
364 0.0, 0.5,
365 0.5, 0.5
366 };
367
368 // vertices-at-edge array
369 static const Index v_e2[] =
370 {
371 0, 3,
372 3, 1,
373 2, 4,
374 4, 1,
375 2, 5,
376 5, 0,
377 3, 4,
378 5, 3,
379 4, 5
380 };
381
382 // vertices-at-triangle
383 static const Index v_t2[] =
384 {
385 1, 3, 4,
386 3, 0, 5,
387 4, 5, 2,
388 5, 4, 3
389 };
390
391 // edges-at-triangle
392 static const Index e_t2[] =
393 {
394 6, 3, 1,
395 5, 7, 0,
396 4, 2, 8,
397 6, 7, 8
398 };
399
400 // fourth possibility
401
402 // vertex coordinates array
403 static const Real vtx3[] =
404 {
405 0.0, 1.0,
406 1.0, 0.0,
407 0.0, 0.0,
408 0.0, 0.5,
409 0.5, 0.0,
410 0.5, 0.5
411 };
412
413 // vertices-at-edge array
414 static const Index v_e3[] =
415 {
416 2, 3,
417 3, 0,
418 1, 4,
419 4, 2,
420 0, 5,
421 5, 1,
422 4, 3,
423 5, 4,
424 3, 5
425 };
426
427 // vertices-at-triangle
428 static const Index v_t3[] =
429 {
430 2, 4, 3,
431 4, 1, 5,
432 3, 5, 0,
433 5, 3, 4
434 };
435
436 // edges-at-triangle
437 static const Index e_t3[] =
438 {
439 6, 0, 3,
440 5, 7, 2,
441 4, 1, 8,
442 6, 7, 8
443 };
444
445 switch(orientation)
446 {
447 case 0:
448 // check vertex coordinates array
449 if(!comp_vtx(mesh.get_vertex_set(), vtx0))
450 throw String("Vertex coordinate refinement failure");
451
452 // check vertices-at-edge array
453 if(!comp_idx(mesh.get_index_set<1,0>(), v_e0))
454 throw String("Vertex-At-Edge index set refinement failure");
455
456 // check vertices-at-triangle
457 if(!comp_idx(mesh.get_index_set<2,0>(), v_t0))
458 throw String("Vertex-At-Triangle index set refinement failure");
459
460 // check edges-at-triangle
461 if(!comp_idx(mesh.get_index_set<2,1>(), e_t0))
462 throw String("Edge-At-Triangle index set refinement failure");
463 break;
464
465 case 1:
466 // check vertex coordinates array
467 if(!comp_vtx(mesh.get_vertex_set(), vtx1))
468 throw String("Vertex coordinate refinement failure");
469
470 // check vertices-at-edge array
471 if(!comp_idx(mesh.get_index_set<1,0>(), v_e1))
472 throw String("Vertex-At-Edge index set refinement failure");
473
474 // check vertices-at-triangle
475 if(!comp_idx(mesh.get_index_set<2,0>(), v_t1))
476 throw String("Vertex-At-Triangle index set refinement failure");
477
478 // check edges-at-triangle
479 if(!comp_idx(mesh.get_index_set<2,1>(), e_t1))
480 throw String("Edge-At-Triangle index set refinement failure");
481 break;
482
483 case 2:
484 // check vertex coordinates array
485 if(!comp_vtx(mesh.get_vertex_set(), vtx2))
486 throw String("Vertex coordinate refinement failure");
487
488 // check vertices-at-edge array
489 if(!comp_idx(mesh.get_index_set<1,0>(), v_e2))
490 throw String("Vertex-At-Edge index set refinement failure");
491
492 // check vertices-at-triangle
493 if(!comp_idx(mesh.get_index_set<2,0>(), v_t2))
494 throw String("Vertex-At-Triangle index set refinement failure");
495
496 // check edges-at-triangle
497 if(!comp_idx(mesh.get_index_set<2,1>(), e_t2))
498 throw String("Edge-At-Triangle index set refinement failure");
499 break;
500
501 case 3:
502 // check vertex coordinates array
503 if(!comp_vtx(mesh.get_vertex_set(), vtx3))
504 throw String("Vertex coordinate refinement failure");
505
506 // check vertices-at-edge array
507 if(!comp_idx(mesh.get_index_set<1,0>(), v_e3))
508 throw String("Vertex-At-Edge index set refinement failure");
509
510 // check vertices-at-triangle
511 if(!comp_idx(mesh.get_index_set<2,0>(), v_t3))
512 throw String("Vertex-At-Triangle index set refinement failure");
513
514 // check edges-at-triangle
515 if(!comp_idx(mesh.get_index_set<2,1>(), e_t3))
516 throw String("Edge-At-Triangle index set refinement failure");
517 break;
518
519 default:
520 XABORTM("Unhandled orientation "+stringify(orientation));
521
522 } //switch
523 } // validate_refined_trianglerefinement_mesh_2d
524
525 TriaMesh* create_patch_tria_mesh_2d()
526 {
527
528 Index num_entities[] =
529 {
530 5, // vertices
531 8, // edges
532 4, // triangles
533 };
534
535 // create mesh
536 TriaMesh* mesh = new TriaMesh(num_entities);
537
538 //
539 // v_3________<________v_4(10,10)
540 // |\ e_2 /|
541 // | \ / |
542 // | \ t_2 / |
543 // | \ / |
544 // | \ e_6/ |
545 // | e_7v v |
546 // | \ / t_1 |
547 // | t_3 \ / |
548 // e_3v v_2(6,7) ^e_1
549 // | / \ |
550 // | / \ |
551 // | / \e_5 |
552 // | ^e_4 ^ |
553 // | / \ |
554 // | / t_0 \ |
555 // | / \ |
556 // |/_______>_______\|
557 // v_0(0,0) e_0 v_1
558 //
559 // triangle orientation:
560 // t_0: v_0-v_1-v_2
561 // t_1: v_2-v_4-v_1
562 // t_2: v_3-v_4-v_2
563 // t_3: v_2-v_3-v_0
564
565 // set up vertex coordinates array
566 static const Real vtx0[3*8] =
567 {
568 0.0, 0.0,
569 10.0, 0.0,
570 6.0, 7.0,
571 0.0, 10.0,
572 10.0, 10.0
573 };
574
575 // set up vertices-at-edge array
576 static const Index v_e0[12*2] =
577 {
578 0, 1,
579 1, 4,
580 4, 3,
581 3, 0,
582 0, 2,
583 1, 2,
584 4, 2,
585 3, 2
586 };
587
588 // set up vertices-at-triangle array
589 static const Index v_t0[6*4] =
590 {
591 0, 1, 2,
592 2, 4, 1,
593 3, 4, 2,
594 2, 3, 0
595 };
596
597 // set up edges-at-triangle array
598 static const Index e_t0[6*4] =
599 {
600 5, 4, 0,
601 1, 5, 6,
602 6, 7, 2,
603 3, 4, 7
604 };
605
606 copy_vtx(mesh->get_vertex_set(), vtx0);
607 copy_idx(mesh->get_index_set<1,0>(), v_e0);
608 copy_idx(mesh->get_index_set<2,0>(), v_t0);
609 copy_idx(mesh->get_index_set<2,1>(), e_t0);
610
611 // okay
612 return mesh;
613 } // create_patch_tria_mesh_2d
614
615 void validate_refined_patch_tria_mesh_2d(const TriaMesh& mesh)
616 {
617
618 // validate sizes
619 if(mesh.get_num_entities(0) != 13)
620 throw String("Vertex count mismatch");
621 if(mesh.get_num_entities(1) != 28)
622 throw String("Edge count mismatch");
623 if(mesh.get_num_entities(2) != 16)
624 throw String("Triangle count mismatch");
625
626 // vertex coordinates array
627 static const Real vtx0[] =
628 {
629 0.0, 0.0,
630 10.0, 0.0,
631 6.0, 7.0,
632 0.0, 10.0,
633 10.0, 10.0,
634 5.0, 0.0,
635 10.0, 5.0,
636 5.0, 10.0,
637 0.0, 5.0,
638 3.0, 3.5,
639 8.0, 3.5,
640 8.0, 8.5,
641 3.0, 8.5
642 };
643
644 // vertices-at-edge array
645 static const Index v_e0[] =
646 {
647 0, 5,
648 5, 1,
649 1, 6,
650 6, 4,
651 4, 7,
652 7, 3,
653 3, 8,
654 8, 0,
655 0, 9,
656 9, 2,
657 1, 10,
658 10, 2,
659 4, 11,
660 11, 2,
661 3, 12,
662 12, 2,
663 5, 9,
664 10, 5,
665 9, 10,
666 11, 10,
667 6, 11,
668 10, 6,
669 7, 12,
670 11, 7,
671 12, 11,
672 12, 9,
673 8, 12,
674 9, 8
675 };
676
677 // vertices-at-triangle
678 static const Index v_t0[] =
679 {
680 0, 5, 9, //0
681 5, 1, 10,
682 9, 10, 2,
683 10, 9, 5,
684 2, 11, 10,
685 11, 4, 6,//5
686 10, 6, 1,
687 6, 10, 11,
688 3, 7, 12,
689 7, 4, 11,
690 12, 11, 2,//10
691 11, 12, 7,
692 2, 12, 9,
693 12, 3, 8,
694 9, 8, 0,
695 8, 9, 12//15
696 };
697
698 // edges-at-triangle
699 static const Index e_t0[] =
700 {
701 16, 8, 0,
702 10, 17, 1,
703 11, 9, 18,
704 16, 17, 18,
705 19, 11, 13,
706 3, 20, 12,
707 2, 10, 21,
708 19, 20, 21,
709 22, 14, 5,
710 12, 23, 4,
711 13, 15, 24,
712 22, 23, 24,
713 25, 9, 15,
714 6, 26, 14,
715 7, 8, 27,
716 25, 26, 27
717 };
718
719 // check vertex coordinates array
720 if(!comp_vtx(mesh.get_vertex_set(), vtx0))
721 throw String("Vertex coordinate refinement failure");
722
723 // check vertices-at-edge array
724 if(!comp_idx(mesh.get_index_set<1,0>(), v_e0))
725 throw String("Vertex-At-Edge index set refinement failure");
726
727 // check vertices-at-triangle
728 if(!comp_idx(mesh.get_index_set<2,0>(), v_t0))
729 throw String("Vertex-At-Triangle index set refinement failure");
730
731 // check edges-at-triangle
732 if(!comp_idx(mesh.get_index_set<2,1>(), e_t0))
733 throw String("Edge-At-Triangle index set refinement failure");
734
735 } // validate_refined_patch_tria_mesh_2d
736
737 TriaSubMesh* create_patch_tria_submesh_2d()
738 {
739 /*
740 v_0(0,10)
741 |\
742 | \
743 | \
744 | \
745 | \
746 | e_3^
747 | \
748 | t_0 \
749 e_0v v_3(6,7)
750 | / \
751 | / \
752 | / \e_2
753 | ve_1 ^
754 | / \
755 | / t_1 \
756 | / \
757 |/_______<_______\
758 v_1(0,0) e_4 v_2(10,0)
759
760 triangle orientation:
761 t_0: v_0-v_3-v_1
762 t_1: v_1-v_3-v_2
763 */
764
765 Index num_entities[] =
766 {
767 4, // vertices
768 5, // edges
769 2 // triangles
770 };
771
772 // create mesh
773 TriaSubMesh* mesh = new TriaSubMesh(num_entities, true);
774 // create a AttributeSet that holds one value for each vertex
775 std::unique_ptr<TriaSubMesh::AttributeSetType> my_attrib_set(new TriaSubMesh::AttributeSetType(num_entities[0],2));
776 // Add the attribute to mesh
777 mesh->add_attribute(std::move(my_attrib_set), "TriaSubAttributeSet");
778
779 // set up vertex coordinates array
780 Real attr[] =
781 {
782 0.0, 10.0,
783 0.0, 0.0,
784 10.0, 0.0,
785 6.0, 7.0
786 };
787 copy_attr(*(mesh->find_attribute("TriaSubAttributeSet")), attr);
788
789 // set up vertices-at-edge array
790 Index v_e[] =
791 {
792 0, 1,
793 3, 1,
794 2, 3,
795 3, 0,
796 2, 1
797 };
798 copy_idx(mesh->get_index_set<1,0>(), v_e);
799
800 // set up vertices-at-triangle array
801 Index v_t[] =
802 {
803 0, 3, 1,
804 1, 3, 2
805 };
806 copy_idx(mesh->get_index_set<2,0>(), v_t);
807
808 // set up edges-at-triangle array
809 Index e_t[] =
810 {
811 1, 0, 3,
812 2, 4, 1
813 };
814 copy_idx(mesh->get_index_set<2,1>(), e_t);
815
816 // set up vertex-target indices
817 Index vti[] =
818 {
819 3, 0, 1, 2
820 };
821 copy_trg(mesh->get_target_set<0>(), vti);
822
823 // set up edge-target indices
824 Index eti[] =
825 {
826 3, 4, 5, 7, 0
827 };
828 copy_trg(mesh->get_target_set<1>(), eti);
829
830 // set up triangle-target indices
831 Index tti[] =
832 {
833 3, 0
834 };
835 copy_trg(mesh->get_target_set<2>(), tti);
836 // okay
837 return mesh;
838 } // create_patch_tria_submesh_2d
839
840 void validate_refined_patch_tria_submesh_2d(const TriaSubMesh& mesh)
841 {
842
843 // validate sizes
844 if(mesh.get_num_entities(0) != 9)
845 throw String("Vertex count mismatch");
846 if(mesh.get_num_entities(1) != 16)
847 throw String("Edge count mismatch");
848 if(mesh.get_num_entities(2) != 8)
849 throw String("Triangle count mismatch");
850
851 // check vertex coordinates array
852 Real attr[] =
853 {
854 0.0, 10.0,
855 0.0, 0.0,
856 10.0, 0.0,
857 6.0, 7.0,
858 0.0, 5.0,
859 3.0, 3.5,
860 8.0, 3.5,
861 3.0, 8.5,
862 5.0, 0.0
863 };
864
865 if(!comp_attr(*(mesh.find_attribute("TriaSubAttributeSet")), attr))
866 throw String("Attribute refinement failure");
867
868 // check vertices-at-edge array
869 Index v_e[] =
870 {
871 0, 4,
872 4, 1,
873 3, 5,
874 5, 1,
875 2, 6,
876 6, 3,
877 3, 7,
878 7, 0,
879 2, 8,
880 8, 1,
881 7, 4,
882 5, 7,
883 4, 5,
884 5, 8,
885 6, 5,
886 8, 6
887 };
888 if(!comp_idx(mesh.get_index_set<1,0>(), v_e))
889 throw String("Vertex-At-Edge index set refinement failure");
890
891 // check vertices-at-triangle
892 Index v_t[] =
893 {
894 0, 7, 4,
895 7, 3, 5,
896 4, 5, 1,
897 5, 4, 7,
898 1, 5, 8,
899 5, 3, 6,
900 8, 6, 2,
901 6, 8, 5
902 };
903 if(!comp_idx(mesh.get_index_set<2,0>(), v_t))
904 throw String("Vertex-At-Tria index set refinement failure");
905
906 // check edges-at-triangle
907 Index e_t[] =
908 {
909 10, 0, 7,
910 2, 11, 6,
911 3, 1, 12,
912 10, 11, 12,
913 13, 9, 3,
914 5, 14, 2,
915 4, 8, 15,
916 13, 14, 15
917 };
918 if(!comp_idx(mesh.get_index_set<2,1>(), e_t))
919 throw String("Edges-At-Tria refinement failure");
920
921 // check vertex-target indices
922 Index vti[] =
923 {
924 3, 0, 1, 2, 8, 9, 10, 12, 5
925 };
926 if(!comp_trg(mesh.get_target_set<0>(), vti))
927 throw String("Vertex-Target-Indices refinement failure");
928
929 // check edge-target indices
930 Index eti[] =
931 {
932 6, 7, 9, 8, 10, 11, 15, 14, 1, 0, 26, 25, 27, 16, 18, 17
933 };
934 if(!comp_trg(mesh.get_target_set<1>(), eti))
935 throw String("Edge-Target-Indices refinement failure");
936
937 // check triangle-target indices
938 Index tti[] =
939 {
940 13, 12, 14, 15, 0, 2, 1, 3
941 };
942 if(!comp_trg(mesh.get_target_set<2>(), tti))
943 throw String("Tria-Target-Indices refinement failure");
944 } // validate_refined_patch_tria_submesh_2d
945
946 TriaSubMesh* create_patch_edge_submesh_2d()
947 {
948
949 Index num_entities[] =
950 {
951 5, // vertices
952 4, // edges
953 0 // triangles
954 };
955
956 // create mesh
957 TriaSubMesh* mesh = new TriaSubMesh(num_entities, true);
958 // create a AttributeSet that holds one value for each vertex
959 std::unique_ptr<TriaSubMesh::AttributeSetType> my_attrib_set(new TriaSubMesh::AttributeSetType(num_entities[0]));
960 // Add the attribute to mesh
961 mesh->add_attribute(std::move(my_attrib_set), "PatchEdgeAttribute");
962
963 // set up vertex coordinates array
964 Real attr[] =
965 {
966 0.0,
967 1.0,
968 2.0,
969 3.0,
970 4.0
971 };
972 copy_attr(*(mesh->find_attribute("PatchEdgeAttribute")), attr);
973
974 // set up vertices-at-edge array
975 Index v_e[] =
976 {
977 0, 1,
978 1, 2,
979 2, 3,
980 3, 4,
981 };
982 copy_idx(mesh->get_index_set<1,0>(), v_e);
983
984 // set up vertex-target indices
985 Index vti[] =
986 {
987 1, 4, 2, 3, 0
988 };
989 copy_trg(mesh->get_target_set<0>(), vti);
990
991 // set up edge-target indices
992 Index eti[] =
993 {
994 1, 6, 7, 3
995 };
996 copy_trg(mesh->get_target_set<1>(), eti);
997
998 // okay
999 return mesh;
1000 } // create_patch_edge_submesh_2d
1001
1002 void validate_refined_patch_edge_submesh_2d(const TriaSubMesh& mesh)
1003 {
1004
1005 // validate sizes
1006 if(mesh.get_num_entities(0) != 9)
1007 throw String("Vertex count mismatch");
1008 if(mesh.get_num_entities(1) != 8)
1009 throw String("Edge count mismatch");
1010
1011 // check vertex coordinates array
1012 Real attr[] =
1013 {
1014 0.0,
1015 1.0,
1016 2.0,
1017 3.0,
1018 4.0,
1019 0.5,
1020 1.5,
1021 2.5,
1022 3.5
1023 };
1024
1025 if(!comp_attr(*(mesh.find_attribute("PatchEdgeAttribute")), attr))
1026 throw String("Attribute refinement failure");
1027
1028 // check vertices-at-edge array
1029 Index v_e[] =
1030 {
1031 0, 5,
1032 5, 1,
1033 1, 6,
1034 6, 2,
1035 2, 7,
1036 7, 3,
1037 3, 8,
1038 8, 4
1039 };
1040 if(!comp_idx(mesh.get_index_set<1,0>(), v_e))
1041 throw String("Vertex-At-Edge index set refinement failure");
1042
1043 // check vertex-target indices
1044 Index vti[] =
1045 {
1046 1, 4, 2, 3, 0, 6, 11, 12, 8
1047 };
1048 if(!comp_trg(mesh.get_target_set<0>(), vti))
1049 throw String("Vertex-Target-Indices refinement failure");
1050
1051 // check edge-target indices
1052 Index eti[] =
1053 {
1054 2, 3, 12, 13, 15, 14, 6, 7
1055 };
1056 if(!comp_trg(mesh.get_target_set<1>(), eti))
1057 throw String("Edge-Target-Indices refinement failure");
1058
1059 } // validate_refined_patch_edge_submesh_2d
1060
1061 } // namespace TestAux
1062 } // namespace Geometry
1063} // namespace FEAT
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
FEAT namespace.
Definition: adjactor.hpp:12
double Real
Real data type.
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:944
std::uint64_t Index
Index data type.