FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
standard_quad.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_quad.hpp>
7#include <kernel/geometry/test_aux/copy_comp_set.hpp>
8
9namespace FEAT
10{
11 namespace Geometry
12 {
13 namespace TestAux
14 {
15 QuadMesh* create_quad_mesh_2d(int orientation)
16 {
17 Index num_entities[] =
18 {
19 4, // vertices
20 4, // edges
21 1 // quads
22 };
23
24 // create mesh
25 QuadMesh* mesh = new QuadMesh(num_entities);
26
28
29 // e_1
30 // v_2_______>_______v_3
31 // | |
32 // | -->--- |
33 // | \ |
34 // | ^ |
35 // e_2 ^ \ ^ e_3
36 // | \ |
37 // | -->--- |
38 // |________>________|
39 // v_0 e_0 v_1
40 //
41
42 // set up vertex coordinates array
43 static const Real vtx0[4*2] =
44 {
45 0.0, 0.0,
46 1.0, 0.0,
47 0.0, 1.0,
48 1.0, 1.0
49 };
50
51 // set up vertices-at-edge array
52 static const Index v_e0[4*2] =
53 {
54 0, 1,
55 2, 3,
56 0, 2,
57 1, 3
58 };
59
60 // set up vertices-at-quad array
61 static const Index v_q0[1*4] =
62 {
63 0, 1, 2, 3
64 };
65
66 // set up edges-at-quad array
67 static const Index e_q0[1*4] =
68 {
69 0, 1, 2, 3
70 };
71
73
74 // e_0
75 // v_1_______<_______v_2
76 // | |
77 // | | /| |
78 // | | / | |
79 // | | / | |
80 // e_2 v ^ v ^ v e_1
81 // | | / | |
82 // | |/ | |
83 // |________<________|
84 // v_3 e_3 v_0
85 //
86
87 // set up vertex coordinates array
88 static const Real vtx1[4*2] =
89 {
90 1.0, 0.0,
91 0.0, 1.0,
92 1.0, 1.0,
93 0.0, 0.0
94 };
95
96 // set up vertices-at-edge array
97 static const Index v_e1[4*2] =
98 {
99 2, 1,
100 2, 0,
101 1, 3,
102 0, 3
103 };
104
105 // set up vertices-at-quad array
106 static const Index v_q1[1*4] =
107 {
108 0, 2, 3, 1
109 };
110
111 // set up edges-at-quad array
112 static const Index e_q1[1*4] =
113 {
114 1, 2, 3, 0
115 };
116
118
119 // e_2
120 // v_2_______>_______v_1
121 // | |
122 // | --<--- |
123 // | \ |
124 // | v |
125 // e_3 ^ \ ^ e_0
126 // | \ |
127 // | --<--- |
128 // |________>________|
129 // v_0 e_1 v_3
130 //
131
132 // set up vertex coordinates array
133 static const Real vtx2[4*2] =
134 {
135 0.0, 0.0,
136 1.0, 1.0,
137 0.0, 1.0,
138 1.0, 0.0
139 };
140
141 // set up vertices-at-edge array
142 static const Index v_e2[4*2] =
143 {
144 3, 1,
145 0, 3,
146 2, 1,
147 0, 2
148 };
149
150 // set up vertices-at-quad array
151 static const Index v_q2[1*4] =
152 {
153 1, 2, 3, 0
154 };
155
156 // set up edges-at-quad array
157 static const Index e_q2[1*4] =
158 {
159 2, 1, 0, 3
160 };
161
163
164 // e_2
165 // v_1_______>_______v_2
166 // | |
167 // | | /| |
168 // | | / | |
169 // | | / | |
170 // e_1 ^ v ^ v v e_0
171 // | | / | |
172 // | |/ | |
173 // |________<________|
174 // v_0 e_3 v_3
175 //
176
177 // set up vertex coordinates array
178 static const Real vtx3[4*2] =
179 {
180 0.0, 0.0,
181 0.0, 1.0,
182 1.0, 1.0,
183 1.0, 0.0
184 };
185
186 // set up vertices-at-edge array
187 static const Index v_e3[4*2] =
188 {
189 2, 3,
190 0, 1,
191 1, 2,
192 3, 0
193 };
194
195 // set up vertices-at-quad array
196 static const Index v_q3[1*4] =
197 {
198 1, 0, 2, 3
199 };
200
201 // set up edges-at-quad array
202 static const Index e_q3[1*4] =
203 {
204 1, 0, 2, 3
205 };
206
207 switch(orientation)
208 {
209 case 0:
210 copy_vtx(mesh->get_vertex_set(), vtx0);
211 copy_idx(mesh->get_index_set<1,0>(), v_e0);
212 copy_idx(mesh->get_index_set<2,0>(), v_q0);
213 copy_idx(mesh->get_index_set<2,1>(), e_q0);
214 break;
215 case 1:
216 copy_vtx(mesh->get_vertex_set(), vtx1);
217 copy_idx(mesh->get_index_set<1,0>(), v_e1);
218 copy_idx(mesh->get_index_set<2,0>(), v_q1);
219 copy_idx(mesh->get_index_set<2,1>(), e_q1);
220 break;
221 case 2:
222 copy_vtx(mesh->get_vertex_set(), vtx2);
223 copy_idx(mesh->get_index_set<1,0>(), v_e2);
224 copy_idx(mesh->get_index_set<2,0>(), v_q2);
225 copy_idx(mesh->get_index_set<2,1>(), e_q2);
226 break;
227 case 3:
228 copy_vtx(mesh->get_vertex_set(), vtx3);
229 copy_idx(mesh->get_index_set<1,0>(), v_e3);
230 copy_idx(mesh->get_index_set<2,0>(), v_q3);
231 copy_idx(mesh->get_index_set<2,1>(), e_q3);
232 break;
233 default:
234 XABORTM("Unhandled orientation "+stringify(orientation));
235 }
236 // okay
237 return mesh;
238 } // create_quad_mesh_2d
239
240 void validate_refined_quad_mesh_2d(const QuadMesh& mesh, int orientation)
241 {
242 // validate sizes
243 if(mesh.get_num_entities(0) != 9)
244 throw String("Vertex count mismatch");
245 if(mesh.get_num_entities(1) != 12)
246 throw String("Edge count mismatch");
247 if(mesh.get_num_entities(2) != 4)
248 throw String("Quad count mismatch");
249
251
252 // vertex coordinates array
253 static const Real vtx0[] =
254 {
255 0.0, 0.0, // coarse mesh vertices (0,...,3)
256 1.0, 0.0,
257 0.0, 1.0,
258 1.0, 1.0,
259 0.5, 0.0,
260 0.5, 1.0,
261 0.0, 0.5,
262 1.0, 0.5,
263 0.5, 0.5
264 };
265
266 // vertices-at-edge array
267 static const Index v_e0[] =
268 {
269 0, 4,
270 4, 1,
271 2, 5,
272 5, 3,
273 0, 6,
274 6, 2,
275 1, 7,
276 7, 3,
277 4, 8,
278 8, 5,
279 6, 8,
280 8, 7
281 };
282
283 // vertices-at-quad
284 static const Index v_q0[] =
285 {
286 0, 4, 6, 8,
287 4, 1, 8, 7,
288 6, 8, 2, 5,
289 8, 7, 5, 3
290 };
291
292 // edges-at-quad
293 static const Index e_q0[] =
294 {
295 0, 10, 4, 8,
296 1, 11, 8, 6,
297 10, 2, 5, 9,
298 11, 3, 9, 7
299 };
300
302
303 // vertex coordinates array
304 static const Real vtx1[] =
305 {
306 1.0, 0.0,
307 0.0, 1.0,
308 1.0, 1.0,
309 0.0, 0.0,
310 0.5, 1.0,
311 1.0, 0.5,
312 0.0, 0.5,
313 0.5, 0.0,
314 0.5, 0.5
315 };
316
317 // vertices-at-edge array
318 static const Index v_e1[] =
319 {
320 2, 4,
321 4, 1,
322 2, 5,
323 5, 0,
324 1, 6,
325 6, 3,
326 0, 7,
327 7, 3,
328 5, 8,
329 8, 6,
330 7, 8,
331 8, 4
332 };
333
334 // vertices-at-quad
335 static const Index v_q1[] =
336 {
337 0, 5, 7, 8,
338 5, 2, 8, 4,
339 7, 8, 3, 6,
340 8, 4, 6, 1
341 };
342
343 // edges-at-quad
344 static const Index e_q1[] =
345 {
346 3, 10, 6, 8,
347 2, 11, 8, 0,
348 10, 5, 7, 9,
349 11, 4, 9, 1
350 };
351
353
354 // vertex coordinates array
355 static const Real vtx2[] =
356 {
357 0.0, 0.0,
358 1.0, 1.0,
359 0.0, 1.0,
360 1.0, 0.0,
361 1.0, 0.5,
362 0.5, 0.0,
363 0.5, 1.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 3, 4,
372 4, 1,
373 0, 5,
374 5, 3,
375 2, 6,
376 6, 1,
377 0, 7,
378 7, 2,
379 6, 8,
380 8, 5,
381 4, 8,
382 8, 7
383 };
384
385 // vertices-at-quad
386 static const Index v_q2[] =
387 {
388 1, 6, 4, 8,
389 6, 2, 8, 7,
390 4, 8, 3, 5,
391 8, 7, 5, 0
392 };
393
394 // edges-at-quad
395 static const Index e_q2[] =
396 {
397 5, 10, 1, 8,
398 4, 11, 8, 7,
399 10, 3, 0, 9,
400 11, 2, 9, 6
401 };
402
404
405 // vertex coordinates array
406 static const Real vtx3[] =
407 {
408 0.0, 0.0,
409 0.0, 1.0,
410 1.0, 1.0,
411 1.0, 0.0,
412 1.0, 0.5,
413 0.0, 0.5,
414 0.5, 1.0,
415 0.5, 0.0,
416 0.5, 0.5
417 };
418
419 // vertices-at-edge array
420 static const Index v_e3[] =
421 {
422 2, 4,
423 4, 3,
424 0, 5,
425 5, 1,
426 1, 6,
427 6, 2,
428 3, 7,
429 7, 0,
430 5, 8,
431 8, 4,
432 6, 8,
433 8, 7
434 };
435
436 // vertices-at-quad
437 static const Index v_q3[] =
438 {
439 1, 5, 6, 8,
440 5, 0, 8, 7,
441 6, 8, 2, 4,
442 8, 7, 4, 3
443 };
444
445 // edges-at-quad
446 static const Index e_q3[] =
447 {
448 3, 10, 4, 8,
449 2, 11, 8, 7,
450 10, 0, 5, 9,
451 11, 1, 9, 6
452 };
453
454
455 switch(orientation)
456 {
457 case 0:
458 // check vertex coordinates array
459 if(!comp_vtx(mesh.get_vertex_set(), vtx0))
460 throw String("Vertex coordinate refinement failure");
461
462 // check vertices-at-edge array
463 if(!comp_idx(mesh.get_index_set<1,0>(), v_e0))
464 throw String("Vertex-At-Edge index set refinement failure");
465
466 // check vertices-at-quad
467 if(!comp_idx(mesh.get_index_set<2,0>(), v_q0))
468 throw String("Vertex-At-Quad index set refinement failure");
469
470 // check edges-at-quad
471 if(!comp_idx(mesh.get_index_set<2,1>(), e_q0))
472 throw String("Edge-At-Quad index set refinement failure");
473 break;
474
475 case 1:
476 // check vertex coordinates array
477 if(!comp_vtx(mesh.get_vertex_set(), vtx1))
478 throw String("Vertex coordinate refinement failure");
479
480 // check vertices-at-edge array
481 if(!comp_idx(mesh.get_index_set<1,0>(), v_e1))
482 throw String("Vertex-At-Edge index set refinement failure");
483
484 // check vertices-at-quad
485 if(!comp_idx(mesh.get_index_set<2,0>(), v_q1))
486 throw String("Vertex-At-Quad index set refinement failure");
487
488 // check edges-at-quad
489 if(!comp_idx(mesh.get_index_set<2,1>(), e_q1))
490 throw String("Edge-At-Quad index set refinement failure");
491 break;
492
493 case 2:
494 // check vertex coordinates array
495 if(!comp_vtx(mesh.get_vertex_set(), vtx2))
496 throw String("Vertex coordinate refinement failure");
497
498 // check vertices-at-edge array
499 if(!comp_idx(mesh.get_index_set<1,0>(), v_e2))
500 throw String("Vertex-At-Edge index set refinement failure");
501
502 // check vertices-at-quad
503 if(!comp_idx(mesh.get_index_set<2,0>(), v_q2))
504 throw String("Vertex-At-Quad index set refinement failure");
505
506 // check edges-at-quad
507 if(!comp_idx(mesh.get_index_set<2,1>(), e_q2))
508 throw String("Edge-At-Quad index set refinement failure");
509 break;
510
511 case 3:
512 // check vertex coordinates array
513 if(!comp_vtx(mesh.get_vertex_set(), vtx3))
514 throw String("Vertex coordinate refinement failure");
515
516 // check vertices-at-edge array
517 if(!comp_idx(mesh.get_index_set<1,0>(), v_e3))
518 throw String("Vertex-At-Edge index set refinement failure");
519
520 // check vertices-at-quad
521 if(!comp_idx(mesh.get_index_set<2,0>(), v_q3))
522 throw String("Vertex-At-Quad index set refinement failure");
523
524 // check edges-at-quad
525 if(!comp_idx(mesh.get_index_set<2,1>(), e_q3))
526 throw String("Edge-At-Quad index set refinement failure");
527 break;
528
529 default:
530 XABORTM("Unhandled orientation "+stringify(orientation));
531 } //switch
532 } // validate_refined_quad_mesh_2d
533
534 } // namespace TestAux
535 } // namespace Geometry
536} // 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.