FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
shape_convert_index.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/geometry/index_set.hpp>
10#include <kernel/geometry/intern/shape_convert_traits.hpp>
11#include <kernel/geometry/intern/entity_counter.hpp>
12
13namespace FEAT
14{
15 namespace Geometry
16 {
18 namespace Intern
19 {
20 template<
21 typename Shape_,
22 int cell_dim_>
23 struct ShapeConvertIndex;
24
25 /* *************************************************************************************** */
26 /* *************************************************************************************** */
27 /* ***************************** Hypercube --> Simplex *********************************** */
28 /* *************************************************************************************** */
29 /* *************************************************************************************** */
30
36 template<>
37 struct ShapeConvertIndex<Shape::Simplex<1>, 1>
38 {
39 static constexpr int shape_dim = 1;
40 static constexpr int cell_dim = 1;
41 typedef Shape::Simplex<shape_dim> ShapeType;
42 typedef Shape::Hypercube<shape_dim> OtherShapeType;
43 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
44 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
45 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
46
47 static Index refine(
48 IndexSetType& index_set_out,
49 const Index offset,
50 const Index index_offsets[],
51 const IndexSetHolderType& index_set_holder_in)
52 {
53 // fetch vertex index offsets
54 const Index iov = index_offsets[0];
55
56 // typedef index set vector reference for output index set
57 typedef IndexSetType::IndexTupleType IndexTupleType;
58
59 // typedef index set types
60 typedef IndexSet<2> IndexSetTypeIn;
61
62 // typedef index vector type
63 typedef IndexSetTypeIn::IndexTupleType IndexTupleTypeIn;
64
65 // fetch the vertices-at-edge index set
66 const IndexSetTypeIn& index_set_in = index_set_holder_in.get_index_set<1,0>();
67
68 // fetch number of coarse mesh edges
69 const Index num_edges = index_set_in.get_num_entities();
70
71 // loop over all coarse mesh quads
72 FEAT_PRAGMA_OMP(parallel for)
73 for(Index i = 0; i < num_edges; ++i)
74 {
75 // fetch coarse mesh vertices-at-quad index vector
76 const IndexTupleTypeIn& v_e = index_set_in[i];
77
78 // fetch fine mesh vertices-at-edge index vectors
79 IndexTupleType& e_0 = index_set_out[offset + i];
80
81 e_0[0] = iov + v_e[0];
82 e_0[1] = iov + v_e[1];
83 }
84
85 // return inner edge count
86 return num_edges;
87 }
88 };
89
95 template<>
96 struct ShapeConvertIndex<Shape::Simplex<2>, 1>
97 {
98 static constexpr int shape_dim = 2;
99 static constexpr int cell_dim = 1;
100 typedef Shape::Simplex<shape_dim> ShapeType;
101 typedef Shape::Hypercube<shape_dim> OtherShapeType;
102 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
103 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
104 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
105
106 static Index refine(
107 IndexSetType& index_set_out,
108 const Index offset,
109 const Index index_offsets[],
110 const IndexSetHolderType& index_set_holder_in)
111 {
112 // fetch vertex index offsets
113 const Index iov = index_offsets[0];
114 const Index ioq = index_offsets[2];
115
116 // typedef index set vector reference for output index set
117 typedef IndexSetType::IndexTupleType IndexTupleType;
118
119 // typedef index set types
120 typedef IndexSet<4> IndexSetTypeIn;
121
122 // typedef index vector type
123 typedef IndexSetTypeIn::IndexTupleType IndexTupleTypeIn;
124
125 // fetch the vertices-at-quad index set
126 const IndexSetTypeIn& index_set_in = index_set_holder_in.get_index_set<2,0>();
127
128 // fetch number of coarse mesh quads
129 const Index num_quads = index_set_in.get_num_entities();
130
131 // Each quad generates four inner edges (e_i) upon conversion,
132 // with each one connecting one of the quad's corner vertices (v_i)
133 // with the vertex generated from the quad midpoint (X).
134 //
135 // v_2-------------------------v_3
136 // |\__ __/|
137 // | \ / |
138 // | e_2__ __e_3 |
139 // | \__ __/ |
140 // | \ / |
141 // | X |
142 // | __/ \__ |
143 // | __/ \__ |
144 // | e_0 e_1 |
145 // | __/ \__ |
146 // |/ \|
147 // v_0-------------------------v_1
148
149
150 // loop over all coarse mesh quads
151 FEAT_PRAGMA_OMP(parallel for)
152 for(Index i = 0; i < num_quads; ++i)
153 {
154 // fetch coarse mesh vertices-at-quad index vector
155 const IndexTupleTypeIn& v_q = index_set_in[i];
156
157 // fetch fine mesh vertices-at-edge index vectors
158 IndexTupleType& e_0 = index_set_out[offset + 4*i + 0];
159 IndexTupleType& e_1 = index_set_out[offset + 4*i + 1];
160 IndexTupleType& e_2 = index_set_out[offset + 4*i + 2];
161 IndexTupleType& e_3 = index_set_out[offset + 4*i + 3];
162
163 e_0[0] = iov + v_q[0]; // v_0
164 e_0[1] = ioq + i; // X
165
166 e_1[0] = iov + v_q[1]; // v_1
167 e_1[1] = ioq + i; // X
168
169 e_2[0] = iov + v_q[2]; // v_2
170 e_2[1] = ioq + i; // X
171
172 e_3[0] = iov + v_q[3]; // v_3
173 e_3[1] = ioq + i; // X
174 }
175
176 // return inner edge count
177 return 4*num_quads;
178 }
179 };
180
186 template<>
187 struct ShapeConvertIndex<Shape::Simplex<3>, 1>
188 {
189 static constexpr int shape_dim = 3;
190 static constexpr int cell_dim = 1;
191 typedef Shape::Simplex<shape_dim> ShapeType;
192 typedef Shape::Hypercube<shape_dim> OtherShapeType;
193 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
194 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
195 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
196
197 static Index refine(
198 IndexSetType& index_set_out,
199 const Index offset,
200 const Index index_offsets[],
201 const IndexSetHolderType& index_set_holder_in)
202 {
203 // fetch vertex index offsets
204 const Index iov = index_offsets[0];
205 const Index ioq = index_offsets[2];
206 const Index ioc = index_offsets[3];
207
208 // typedef index set vector reference for output index set
209 typedef IndexSetType::IndexTupleType IndexTupleType;
210
211 // typedef index set types
212 typedef IndexSet<8> IndexSetTypeIn_v_c;
213 typedef IndexSet<6> IndexSetTypeIn_q_c;
214
215 // typedef index vector type
216 typedef IndexSetTypeIn_v_c::IndexTupleType IndexTupleType_v_c;
217 typedef IndexSetTypeIn_q_c::IndexTupleType IndexTupleType_q_c;
218
219 // fetch the vertices-at-hexa and the quad-at-hexa index set
220 const IndexSetTypeIn_v_c& index_set_in_v_c = index_set_holder_in.get_index_set<3,0>();
221 const IndexSetTypeIn_q_c& index_set_in_q_c = index_set_holder_in.get_index_set<3,2>();
222
223 // fetch number of coarse mesh hexas
224 const Index num_hexas = index_set_in_v_c.get_num_entities();
225
226 // loop over all coarse mesh hexas
227 FEAT_PRAGMA_OMP(parallel for)
228 for(Index i = 0; i < num_hexas; ++i)
229 {
230 // fetch coarse mesh vertices-at-hexa index vector
231 const IndexTupleType_v_c& v_c = index_set_in_v_c[i];
232 const IndexTupleType_q_c& q_c = index_set_in_q_c[i];
233
234 // fetch new mesh vertices-at-edge index vectors
235 IndexTupleType& e_0 = index_set_out[offset + 14*i + 0];
236 IndexTupleType& e_1 = index_set_out[offset + 14*i + 1];
237 IndexTupleType& e_2 = index_set_out[offset + 14*i + 2];
238 IndexTupleType& e_3 = index_set_out[offset + 14*i + 3];
239 IndexTupleType& e_4 = index_set_out[offset + 14*i + 4];
240 IndexTupleType& e_5 = index_set_out[offset + 14*i + 5];
241 IndexTupleType& e_6 = index_set_out[offset + 14*i + 6];
242 IndexTupleType& e_7 = index_set_out[offset + 14*i + 7];
243 IndexTupleType& e_8 = index_set_out[offset + 14*i + 8];
244 IndexTupleType& e_9 = index_set_out[offset + 14*i + 9];
245 IndexTupleType& e_10 = index_set_out[offset + 14*i + 10];
246 IndexTupleType& e_11 = index_set_out[offset + 14*i + 11];
247 IndexTupleType& e_12 = index_set_out[offset + 14*i + 12];
248 IndexTupleType& e_13 = index_set_out[offset + 14*i + 13];
249
250 // corner-midpoint edges
251 e_0[0] = iov + v_c[0]; // v_0
252 e_0[1] = ioc + i; // X
253
254 e_1[0] = iov + v_c[1]; // v_1
255 e_1[1] = ioc + i; // X
256
257 e_2[0] = iov + v_c[2]; // v_2
258 e_2[1] = ioc + i; // X
259
260 e_3[0] = iov + v_c[3]; // v_3
261 e_3[1] = ioc + i; // X
262
263 e_4[0] = iov + v_c[4]; // v_4
264 e_4[1] = ioc + i; // X
265
266 e_5[0] = iov + v_c[5]; // v_5
267 e_5[1] = ioc + i; // X
268
269 e_6[0] = iov + v_c[6]; // v_6
270 e_6[1] = ioc + i; // X
271
272 e_7[0] = iov + v_c[7]; // v_7
273 e_7[1] = ioc + i; // X
274
275
276 // face-midpoint edges
277 e_8[0] = ioq + q_c[0]; // q_0
278 e_8[1] = ioc + i; // X
279
280 e_9[0] = ioq + q_c[1]; // q_1
281 e_9[1] = ioc + i; // X
282
283 e_10[0] = ioq + q_c[2]; // q_2
284 e_10[1] = ioc + i; // X
285
286 e_11[0] = ioq + q_c[3]; // q_3
287 e_11[1] = ioc + i; // X
288
289 e_12[0] = ioq + q_c[4]; // q_4
290 e_12[1] = ioc + i; // X
291
292 e_13[0] = ioq + q_c[5]; // q_5
293 e_13[1] = ioc + i; // X
294
295 }
296
297 // return inner edge count
298 return 14*num_hexas;
299 }
300 };
301
307 template<>
308 struct ShapeConvertIndex<Shape::Simplex<2>, 2>
309 {
310 static constexpr int shape_dim = 2;
311 static constexpr int cell_dim = 2;
312 typedef Shape::Simplex<shape_dim> ShapeType;
313 typedef Shape::Hypercube<shape_dim> OtherShapeType;
314 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
315 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
316 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
317
318 static Index refine(
319 IndexSetType& index_set_out,
320 const Index offset,
321 const Index index_offsets[],
322 const IndexSetHolderType& index_set_holder_in)
323 {
324 // fetch vertex index offsets
325 const Index iov = index_offsets[0];
326 const Index ioq = index_offsets[2];
327
328 // typedef index set vector reference for output index set
329 typedef IndexSetType::IndexTupleType IndexTupleType;
330
331 // typedef index set types
332 typedef IndexSet<4> IndexSetTypeIn;
333
334 // typedef index vector type
335 typedef IndexSetTypeIn::IndexTupleType IndexTupleTypeIn;
336
337 // fetch the vertices-at-quad index set
338 const IndexSetTypeIn& index_set_in = index_set_holder_in.get_index_set<2,0>();
339
340 // fetch number of coarse mesh quads
341 const Index num_quads = index_set_in.get_num_entities();
342
343 // Each quad generates four inner triangles (t_i) upon conversion,
344 // with each one connecting two of the quad's corner vertices (v_i)
345 // with the vertex generated from the quad midpoint (X).
346 //
347 // v_2-------------------------v_3
348 // |\__ __/|
349 // | \__ t_1 __/ |
350 // | \__ __/ |
351 // | \__ __/ |
352 // | \ / |
353 // | t_2 X t_3 |
354 // | __/ \__ |
355 // | __/ \__ |
356 // | __/ \__ |
357 // | __/ t_0 \__ |
358 // |/ \|
359 // v_0-------------------------v_1
360
361
362 // loop over all coarse mesh quads
363 FEAT_PRAGMA_OMP(parallel for)
364 for(Index i = 0; i < num_quads; ++i)
365 {
366 // fetch coarse mesh vertices-at-quad index vector
367 const IndexTupleTypeIn& v_q = index_set_in[i];
368
369 // fetch fine mesh vertices-at-edge index vectors
370 IndexTupleType& t_0 = index_set_out[offset + 4*i + 0];
371 IndexTupleType& t_1 = index_set_out[offset + 4*i + 1];
372 IndexTupleType& t_2 = index_set_out[offset + 4*i + 2];
373 IndexTupleType& t_3 = index_set_out[offset + 4*i + 3];
374
375 t_0[0] = ioq + i; // X
376 t_0[1] = iov + v_q[0]; // v_0
377 t_0[2] = iov + v_q[1]; // v_1
378
379 t_1[0] = ioq + i; // X
380 t_1[1] = iov + v_q[3]; // v_3
381 t_1[2] = iov + v_q[2]; // v_2
382
383 t_2[0] = ioq + i; // X
384 t_2[1] = iov + v_q[2]; // v_2
385 t_2[2] = iov + v_q[0]; // v_0
386
387 t_3[0] = ioq + i; // X
388 t_3[1] = iov + v_q[1]; // v_1
389 t_3[2] = iov + v_q[3]; // v_3
390 }
391
392 // return triangle count
393 return 4*num_quads;
394 }
395 };
396
397
403 template<>
404 struct ShapeConvertIndex<Shape::Simplex<3>, 2>
405 {
406 static constexpr int shape_dim = 3;
407 static constexpr int cell_dim = 2;
408 typedef Shape::Simplex<shape_dim> ShapeType;
409 typedef Shape::Hypercube<shape_dim> OtherShapeType;
410 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
411 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
412 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
413
414 static Index refine(
415 IndexSetType& index_set_out,
416 const Index offset,
417 const Index index_offsets[],
418 const IndexSetHolderType& index_set_holder_in)
419 {
420 // fetch vertex index offsets
421 const Index iov = index_offsets[0];
422 const Index ioq = index_offsets[2];
423 const Index ioc = index_offsets[3];
424
425 // typedef index set vector reference for output index set
426 typedef IndexSetType::IndexTupleType IndexTupleType;
427
428 // typedef index set types
429 typedef IndexSet<8> IndexSetTypeIn_v_c;
430 typedef IndexSet<6> IndexSetTypeIn_q_c;
431
432 // typedef index vector type
433 typedef IndexSetTypeIn_v_c::IndexTupleType IndexTupleType_v_c;
434 typedef IndexSetTypeIn_q_c::IndexTupleType IndexTupleType_q_c;
435
436 // fetch the vertices-at-hexa and quad-at-hexa index set
437 const IndexSetTypeIn_v_c& index_set_in_v_c = index_set_holder_in.get_index_set<3,0>();
438 const IndexSetTypeIn_q_c& index_set_in_q_c = index_set_holder_in.get_index_set<3,2>();
439
440 // fetch number of coarse mesh hexas
441 const Index num_cubes = index_set_in_v_c.get_num_entities();
442
443 // loop over all coarse mesh hexas
444 FEAT_PRAGMA_OMP(parallel for)
445 for(Index i = 0; i < num_cubes; ++i)
446 {
447 // fetch coarse mesh vertices-at-hexas and quad-at-hexa index vector
448 const IndexTupleType_v_c& v_c = index_set_in_v_c[i];
449 const IndexTupleType_q_c& q_c = index_set_in_q_c[i];
450
451 // fetch fine mesh vertices-at-triangle index vectors
452 IndexTupleType& t_0 = index_set_out[offset + 36*i + 0];
453 IndexTupleType& t_1 = index_set_out[offset + 36*i + 1];
454 IndexTupleType& t_2 = index_set_out[offset + 36*i + 2];
455 IndexTupleType& t_3 = index_set_out[offset + 36*i + 3];
456 IndexTupleType& t_4 = index_set_out[offset + 36*i + 4];
457 IndexTupleType& t_5 = index_set_out[offset + 36*i + 5];
458 IndexTupleType& t_6 = index_set_out[offset + 36*i + 6];
459 IndexTupleType& t_7 = index_set_out[offset + 36*i + 7];
460 IndexTupleType& t_8 = index_set_out[offset + 36*i + 8];
461 IndexTupleType& t_9 = index_set_out[offset + 36*i + 9];
462 IndexTupleType& t_10 = index_set_out[offset + 36*i + 10];
463 IndexTupleType& t_11 = index_set_out[offset + 36*i + 11];
464 IndexTupleType& t_12 = index_set_out[offset + 36*i + 12];
465 IndexTupleType& t_13 = index_set_out[offset + 36*i + 13];
466 IndexTupleType& t_14 = index_set_out[offset + 36*i + 14];
467 IndexTupleType& t_15 = index_set_out[offset + 36*i + 15];
468 IndexTupleType& t_16 = index_set_out[offset + 36*i + 16];
469 IndexTupleType& t_17 = index_set_out[offset + 36*i + 17];
470 IndexTupleType& t_18 = index_set_out[offset + 36*i + 18];
471 IndexTupleType& t_19 = index_set_out[offset + 36*i + 19];
472 IndexTupleType& t_20 = index_set_out[offset + 36*i + 20];
473 IndexTupleType& t_21 = index_set_out[offset + 36*i + 21];
474 IndexTupleType& t_22 = index_set_out[offset + 36*i + 22];
475 IndexTupleType& t_23 = index_set_out[offset + 36*i + 23];
476 IndexTupleType& t_24 = index_set_out[offset + 36*i + 24];
477 IndexTupleType& t_25 = index_set_out[offset + 36*i + 25];
478 IndexTupleType& t_26 = index_set_out[offset + 36*i + 26];
479 IndexTupleType& t_27 = index_set_out[offset + 36*i + 27];
480 IndexTupleType& t_28 = index_set_out[offset + 36*i + 28];
481 IndexTupleType& t_29 = index_set_out[offset + 36*i + 29];
482 IndexTupleType& t_30 = index_set_out[offset + 36*i + 30];
483 IndexTupleType& t_31 = index_set_out[offset + 36*i + 31];
484 IndexTupleType& t_32 = index_set_out[offset + 36*i + 32];
485 IndexTupleType& t_33 = index_set_out[offset + 36*i + 33];
486 IndexTupleType& t_34 = index_set_out[offset + 36*i + 34];
487 IndexTupleType& t_35 = index_set_out[offset + 36*i + 35];
488
489 const auto x = ioc + i;
490 const auto v_0 = iov + v_c[0];
491 const auto v_1 = iov + v_c[1];
492 const auto v_2 = iov + v_c[2];
493 const auto v_3 = iov + v_c[3];
494 const auto v_4 = iov + v_c[4];
495 const auto v_5 = iov + v_c[5];
496 const auto v_6 = iov + v_c[6];
497 const auto v_7 = iov + v_c[7];
498 const auto q_0 = ioq + q_c[0];
499 const auto q_1 = ioq + q_c[1];
500 const auto q_2 = ioq + q_c[2];
501 const auto q_3 = ioq + q_c[3];
502 const auto q_4 = ioq + q_c[4];
503 const auto q_5 = ioq + q_c[5];
504
505 //Unrolling leads to compiler bug with GCC 15 and AVX
506 for (Index j = 0; j < 36; ++j)
507 index_set_out[offset + 36*i +j][0] = x; //t_j[0] = x; j=0,...,35
508
509 // coarse edge triangles
510 t_0[1] = v_0;
511 t_0[2] = v_1;
512 t_1[1] = v_3;
513 t_1[2] = v_2;
514 t_2[1] = v_4;
515 t_2[2] = v_5;
516 t_3[1] = v_7;
517 t_3[2] = v_6;
518 t_4[1] = v_2;
519 t_4[2] = v_0;
520 t_5[1] = v_1;
521 t_5[2] = v_3;
522 t_6[1] = v_6;
523 t_6[2] = v_4;
524 t_7[1] = v_5;
525 t_7[2] = v_7;
526 t_8[1] = v_4;
527 t_8[2] = v_0;
528 t_9[1] = v_1;
529 t_9[2] = v_5;
530 t_10[1] = v_6;
531 t_10[2] = v_2;
532 t_11[1] = v_3;
533 t_11[2] = v_7;
534
535 // face triangles
536 // face 0
537 t_12[1] = q_0;
538 t_12[2] = v_0;
539 t_13[1] = q_0;
540 t_13[2] = v_1;
541 t_14[1] = q_0;
542 t_14[2] = v_2;
543 t_15[1] = q_0;
544 t_15[2] = v_3;
545
546 // face 1
547 t_16[1] = q_1;
548 t_16[2] = v_4;
549 t_17[1] = q_1;
550 t_17[2] = v_5;
551 t_18[1] = q_1;
552 t_18[2] = v_6;
553 t_19[1] = q_1;
554 t_19[2] = v_7;
555
556 // face 2
557 t_20[1] = q_2;
558 t_20[2] = v_0;
559 t_21[1] = q_2;
560 t_21[2] = v_1;
561 t_22[1] = q_2;
562 t_22[2] = v_4;
563 t_23[1] = q_2;
564 t_23[2] = v_5;
565
566 // face 3
567 t_24[1] = q_3;
568 t_24[2] = v_2;
569 t_25[1] = q_3;
570 t_25[2] = v_3;
571 t_26[1] = q_3;
572 t_26[2] = v_6;
573 t_27[1] = q_3;
574 t_27[2] = v_7;
575
576 // face 4
577 t_28[1] = q_4;
578 t_28[2] = v_0;
579 t_29[1] = q_4;
580 t_29[2] = v_2;
581 t_30[1] = q_4;
582 t_30[2] = v_4;
583 t_31[1] = q_4;
584 t_31[2] = v_6;
585
586 // face 5
587 t_32[1] = q_5;
588 t_32[2] = v_1;
589 t_33[1] = q_5;
590 t_33[2] = v_3;
591 t_34[1] = q_5;
592 t_34[2] = v_5;
593 t_35[1] = q_5;
594 t_35[2] = v_7;
595
596 }
597
598 // return triangle count
599 return 36*num_cubes;
600 }
601 };
602
603
610 template<>
611 struct ShapeConvertIndex<Shape::Simplex<3>, 3>
612 {
613 static constexpr int shape_dim = 3;
614 static constexpr int cell_dim = 3;
615 typedef Shape::Simplex<shape_dim> ShapeType;
616 typedef Shape::Hypercube<shape_dim> OtherShapeType;
617 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
618 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
619 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
620
621 static Index refine(
622 IndexSetType& index_set_out,
623 const Index offset,
624 const Index index_offsets[],
625 const IndexSetHolderType& index_set_holder_in)
626 {
627 // fetch vertex index offsets
628 const Index iov = index_offsets[0];
629 const Index ioq = index_offsets[2];
630 const Index ioc = index_offsets[3];
631
632 // typedef index set vector reference for output index set
633 typedef IndexSetType::IndexTupleType IndexTupleType;
634
635 // typedef index set types
636 typedef IndexSet<8> IndexSetTypeIn_v_c;
637 typedef IndexSet<6> IndexSetTypeIn_q_c;
638
639 // typedef index vector type
640 typedef IndexSetTypeIn_v_c::IndexTupleType IndexTupleType_v_c;
641 typedef IndexSetTypeIn_q_c::IndexTupleType IndexTupleType_q_c;
642
643 // fetch the vertices-at-hexas and quad-at-hexas index set
644 const IndexSetTypeIn_v_c& index_set_in_v_c = index_set_holder_in.get_index_set<3,0>();
645 const IndexSetTypeIn_q_c& index_set_in_q_c = index_set_holder_in.get_index_set<3,2>();
646
647 // fetch number of coarse mesh hexas
648 const Index num_cubes = index_set_in_v_c.get_num_entities();
649
650 // loop over all coarse mesh hexas
651 FEAT_PRAGMA_OMP(parallel for)
652 for(Index i = 0; i < num_cubes; ++i)
653 {
654 // fetch coarse mesh vertices-at-hexas and quad-at-hexas index vector
655 const IndexTupleType_v_c& v_c = index_set_in_v_c[i];
656 const IndexTupleType_q_c& q_c = index_set_in_q_c[i];
657
658 // fetch fine mesh vertices-at-tetra index vectors
659 IndexTupleType& t_0 = index_set_out[offset + 24*i + 0];
660 IndexTupleType& t_1 = index_set_out[offset + 24*i + 1];
661 IndexTupleType& t_2 = index_set_out[offset + 24*i + 2];
662 IndexTupleType& t_3 = index_set_out[offset + 24*i + 3];
663 IndexTupleType& t_4 = index_set_out[offset + 24*i + 4];
664 IndexTupleType& t_5 = index_set_out[offset + 24*i + 5];
665 IndexTupleType& t_6 = index_set_out[offset + 24*i + 6];
666 IndexTupleType& t_7 = index_set_out[offset + 24*i + 7];
667 IndexTupleType& t_8 = index_set_out[offset + 24*i + 8];
668 IndexTupleType& t_9 = index_set_out[offset + 24*i + 9];
669 IndexTupleType& t_10 = index_set_out[offset + 24*i + 10];
670 IndexTupleType& t_11 = index_set_out[offset + 24*i + 11];
671 IndexTupleType& t_12 = index_set_out[offset + 24*i + 12];
672 IndexTupleType& t_13 = index_set_out[offset + 24*i + 13];
673 IndexTupleType& t_14 = index_set_out[offset + 24*i + 14];
674 IndexTupleType& t_15 = index_set_out[offset + 24*i + 15];
675 IndexTupleType& t_16 = index_set_out[offset + 24*i + 16];
676 IndexTupleType& t_17 = index_set_out[offset + 24*i + 17];
677 IndexTupleType& t_18 = index_set_out[offset + 24*i + 18];
678 IndexTupleType& t_19 = index_set_out[offset + 24*i + 19];
679 IndexTupleType& t_20 = index_set_out[offset + 24*i + 20];
680 IndexTupleType& t_21 = index_set_out[offset + 24*i + 21];
681 IndexTupleType& t_22 = index_set_out[offset + 24*i + 22];
682 IndexTupleType& t_23 = index_set_out[offset + 24*i + 23];
683
684 // end up with X and use convention for tetrahedron index numbering (see wiki)
685 // face 0
686 t_0[0] = iov + v_c[0]; // v_0
687 t_0[1] = iov + v_c[1]; // v_1
688 t_0[2] = ioq + q_c[0]; // q_0
689 t_0[3] = ioc + i; // X
690
691 t_1[0] = iov + v_c[3]; // v_3
692 t_1[1] = iov + v_c[2]; // v_2
693 t_1[2] = ioq + q_c[0]; // q_0
694 t_1[3] = ioc + i; // X
695
696 t_2[0] = iov + v_c[2]; // v_2
697 t_2[1] = iov + v_c[0]; // v_0
698 t_2[2] = ioq + q_c[0]; // q_0
699 t_2[3] = ioc + i; // X
700
701 t_3[0] = iov + v_c[1]; // v_1
702 t_3[1] = iov + v_c[3]; // v_3
703 t_3[2] = ioq + q_c[0]; // q_0
704 t_3[3] = ioc + i; // X
705
706 // face 1
707 t_4[0] = iov + v_c[5]; // v_5
708 t_4[1] = iov + v_c[4]; // v_4
709 t_4[2] = ioq + q_c[1]; // q_1
710 t_4[3] = ioc + i; // X
711
712 t_5[0] = iov + v_c[6]; // v_6
713 t_5[1] = iov + v_c[7]; // v_7
714 t_5[2] = ioq + q_c[1]; // q_1
715 t_5[3] = ioc + i; // X
716
717 t_6[0] = iov + v_c[4]; // v_4
718 t_6[1] = iov + v_c[6]; // v_6
719 t_6[2] = ioq + q_c[1]; // q_1
720 t_6[3] = ioc + i; // X
721
722 t_7[0] = iov + v_c[7]; // v_7
723 t_7[1] = iov + v_c[5]; // v_5
724 t_7[2] = ioq + q_c[1]; // q_1
725 t_7[3] = ioc + i; // X
726
727 // face 2
728 t_8[0] = iov + v_c[1]; // v_1
729 t_8[1] = iov + v_c[0]; // v_0
730 t_8[2] = ioq + q_c[2]; // q_2
731 t_8[3] = ioc + i; // X
732
733 t_9[0] = iov + v_c[4]; // v_4
734 t_9[1] = iov + v_c[5]; // v_5
735 t_9[2] = ioq + q_c[2]; // q_2
736 t_9[3] = ioc + i; // X
737
738 t_10[0] = iov + v_c[0]; // v_0
739 t_10[1] = iov + v_c[4]; // v_4
740 t_10[2] = ioq + q_c[2]; // q_2
741 t_10[3] = ioc + i; // X
742
743 t_11[0] = iov + v_c[5]; // v_5
744 t_11[1] = iov + v_c[1]; // v_1
745 t_11[2] = ioq + q_c[2]; // q_2
746 t_11[3] = ioc + i; // X
747
748 // face 3
749 t_12[0] = iov + v_c[2]; // v_2
750 t_12[1] = iov + v_c[3]; // v_3
751 t_12[2] = ioq + q_c[3]; // q_3
752 t_12[3] = ioc + i; // X
753
754 t_13[0] = iov + v_c[7]; // v_7
755 t_13[1] = iov + v_c[6]; // v_6
756 t_13[2] = ioq + q_c[3]; // q_3
757 t_13[3] = ioc + i; // X
758
759 t_14[0] = iov + v_c[6]; // v_6
760 t_14[1] = iov + v_c[2]; // v_2
761 t_14[2] = ioq + q_c[3]; // q_3
762 t_14[3] = ioc + i; // X
763
764 t_15[0] = iov + v_c[3]; // v_3
765 t_15[1] = iov + v_c[7]; // v_7
766 t_15[2] = ioq + q_c[3]; // q_3
767 t_15[3] = ioc + i; // X
768
769 // face 4
770 t_16[0] = iov + v_c[0]; // v_0
771 t_16[1] = iov + v_c[2]; // v_2
772 t_16[2] = ioq + q_c[4]; // q_4
773 t_16[3] = ioc + i; // X
774
775 t_17[0] = iov + v_c[6]; // v_6
776 t_17[1] = iov + v_c[4]; // v_4
777 t_17[2] = ioq + q_c[4]; // q_4
778 t_17[3] = ioc + i; // X
779
780 t_18[0] = iov + v_c[4]; // v_4
781 t_18[1] = iov + v_c[0]; // v_0
782 t_18[2] = ioq + q_c[4]; // q_4
783 t_18[3] = ioc + i; // X
784
785 t_19[0] = iov + v_c[2]; // v_2
786 t_19[1] = iov + v_c[6]; // v_6
787 t_19[2] = ioq + q_c[4]; // q_4
788 t_19[3] = ioc + i; // X
789
790 // face 5
791 t_20[0] = iov + v_c[3]; // v_3
792 t_20[1] = iov + v_c[1]; // v_1
793 t_20[2] = ioq + q_c[5]; // q_5
794 t_20[3] = ioc + i; // X
795
796 t_21[0] = iov + v_c[5]; // v_5
797 t_21[1] = iov + v_c[7]; // v_7
798 t_21[2] = ioq + q_c[5]; // q_5
799 t_21[3] = ioc + i; // X
800
801 t_22[0] = iov + v_c[1]; // v_1
802 t_22[1] = iov + v_c[5]; // v_5
803 t_22[2] = ioq + q_c[5]; // q_5
804 t_22[3] = ioc + i; // X
805
806 t_23[0] = iov + v_c[7]; // v_7
807 t_23[1] = iov + v_c[3]; // v_3
808 t_23[2] = ioq + q_c[5]; // q_5
809 t_23[3] = ioc + i; // X
810 }
811
812 // return triangle count
813 return 24*num_cubes;
814 }
815 };
816
817 /* *************************************************************************************** */
818 /* *************************************************************************************** */
819 /* ***************************** Simplex --> Hypercube *********************************** */
820 /* *************************************************************************************** */
821 /* *************************************************************************************** */
822
828 template<>
829 struct ShapeConvertIndex<Shape::Hypercube<1>, 1>
830 {
831 static constexpr int shape_dim = 1;
832 static constexpr int cell_dim = 1;
833 typedef Shape::Hypercube<shape_dim> ShapeType;
834 typedef Shape::Simplex<shape_dim> OtherShapeType;
835 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
836 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
837 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
838
839 static Index refine(
840 IndexSetType& index_set_out,
841 const Index offset,
842 const Index index_offsets[],
843 const IndexSetHolderType& index_set_holder_in)
844 {
845 // fetch vertex index offsets
846 const Index iov = index_offsets[0];
847 const Index ioe = index_offsets[1];
848
849 // typedef index set vector reference for output index set
850 typedef IndexSetType::IndexTupleType IndexTupleType;
851
852 // typedef index set types
853 typedef IndexSet<2> IndexSetTypeIn;
854
855 // typedef index vector type
856 typedef IndexSetTypeIn::IndexTupleType IndexTupleTypeIn;
857
858 // fetch the vertices-at-edge index set
859 const IndexSetTypeIn& index_set_in = index_set_holder_in.get_index_set<1,0>();
860
861 // fetch number of coarse mesh edges
862 const Index num_edges = index_set_in.get_num_entities();
863
864 // loop over all coarse mesh edges
865 FEAT_PRAGMA_OMP(parallel for)
866 for(Index i = 0; i < num_edges; ++i)
867 {
868 // fetch coarse mesh vertices-at-edge index vector
869 const IndexTupleTypeIn& v_e = index_set_in[i];
870
871 // fetch fine mesh vertices-at-edge index vectors
872 IndexTupleType& e_0 = index_set_out[offset + 2*i+0];
873 IndexTupleType& e_1 = index_set_out[offset + 2*i+1];
874
875 e_0[0] = iov + v_e[0];
876 e_0[1] = ioe + i;
877
878 e_1[0] = ioe + i;
879 e_1[1] = iov + v_e[1];
880 }
881
882 // return inner edge count
883 return 2*num_edges;
884 }
885 };
886
892 template<>
893 struct ShapeConvertIndex<Shape::Hypercube<2>, 1>
894 {
895 static constexpr int shape_dim = 2;
896 static constexpr int cell_dim = 1;
897 typedef Shape::Hypercube<shape_dim> ShapeType;
898 typedef Shape::Simplex<shape_dim> OtherShapeType;
899 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
900 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
901 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
902
903 static Index refine(
904 IndexSetType& index_set_out,
905 const Index offset,
906 const Index index_offsets[],
907 const IndexSetHolderType& index_set_holder_in)
908 {
909 // fetch vertex index offsets
910 const Index ioe = index_offsets[1];
911 const Index iot = index_offsets[2];
912
913 // typedef index set vector reference for output index set
914 typedef IndexSetType::IndexTupleType IndexTupleType;
915
916 // typedef index set types
917 typedef IndexSet<3> IndexSetTypeIn;
918
919 // typedef index vector type
920 typedef IndexSetTypeIn::IndexTupleType IndexTupleTypeIn;
921
922 // fetch the edge-at-triangle index set
923 const IndexSetTypeIn& index_set_in = index_set_holder_in.get_index_set<2,1>();
924
925 // fetch number of coarse mesh triangle
926 const Index num_trias = index_set_in.get_num_entities();
927
928 // loop over all coarse mesh triangle
929 FEAT_PRAGMA_OMP(parallel for)
930 for(Index i = 0; i < num_trias; ++i)
931 {
932 // fetch coarse mesh edge-at-triangle index vector
933 const IndexTupleTypeIn& e_t = index_set_in[i];
934
935 // fetch fine mesh vertices-at-edge index vectors
936 IndexTupleType& e_0 = index_set_out[offset + 3*i + 0];
937 IndexTupleType& e_1 = index_set_out[offset + 3*i + 1];
938 IndexTupleType& e_2 = index_set_out[offset + 3*i + 2];
939
940 // end with X
941 e_0[0] = ioe + e_t[0]; // v_0
942 e_0[1] = iot + i; // X
943
944 e_1[0] = ioe + e_t[1]; // v_1
945 e_1[1] = iot + i; // X
946
947 e_2[0] = ioe + e_t[2]; // v_2
948 e_2[1] = iot + i; // X
949 }
950
951 // return inner edge count
952 return 3*num_trias;
953 }
954 };
955
961 template<>
962 struct ShapeConvertIndex<Shape::Hypercube<3>, 1>
963 {
964 static constexpr int shape_dim = 3;
965 static constexpr int cell_dim = 1;
966 typedef Shape::Hypercube<shape_dim> ShapeType;
967 typedef Shape::Simplex<shape_dim> OtherShapeType;
968 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
969 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
970 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
971
972 static Index refine(
973 IndexSetType& index_set_out,
974 const Index offset,
975 const Index index_offsets[],
976 const IndexSetHolderType& index_set_holder_in)
977 {
978 // fetch vertex index offsets
979 const Index iot = index_offsets[2];
980 const Index iotet = index_offsets[3];
981
982 // typedef index set vector reference for output index set
983 typedef IndexSetType::IndexTupleType IndexTupleType;
984
985 // typedef index set types
986 typedef IndexSet<4> IndexSetTypeIn_t_tet;
987
988 // typedef index vector type
989 typedef IndexSetTypeIn_t_tet::IndexTupleType IndexTupleType_t_tet;
990
991 // fetch the triangle-at-tetra
992 const IndexSetTypeIn_t_tet& index_set_in_t_tet = index_set_holder_in.get_index_set<3,2>();
993
994 // fetch number of coarse mesh tetras
995 const Index num_tetras = index_set_in_t_tet.get_num_entities();
996
997 // loop over all coarse mesh tetras
998 FEAT_PRAGMA_OMP(parallel for)
999 for(Index i = 0; i < num_tetras; ++i)
1000 {
1001 // fetch coarse mesh triangle-at-tetra index vector
1002 const IndexTupleType_t_tet& t_tet = index_set_in_t_tet[i];
1003
1004 // fetch new mesh vertices-at-edge index vectors
1005 IndexTupleType& e_0 = index_set_out[offset + 4*i + 0];
1006 IndexTupleType& e_1 = index_set_out[offset + 4*i + 1];
1007 IndexTupleType& e_2 = index_set_out[offset + 4*i + 2];
1008 IndexTupleType& e_3 = index_set_out[offset + 4*i + 3];
1009
1010
1011 // end with X
1012 e_0[0] = iot + t_tet[0]; // v_0
1013 e_0[1] = iotet + i; // X
1014
1015 e_1[0] = iot + t_tet[1]; // v_1
1016 e_1[1] = iotet + i; // X
1017
1018 e_2[0] = iot + t_tet[2]; // v_2
1019 e_2[1] = iotet + i; // X
1020
1021 e_3[0] = iot + t_tet[3]; // v_3
1022 e_3[1] = iotet + i; // X
1023
1024 }
1025
1026 // return inner edge count
1027 return 4*num_tetras;
1028 }
1029 };
1030
1036 template<>
1037 struct ShapeConvertIndex<Shape::Hypercube<2>, 2>
1038 {
1039 static constexpr int shape_dim = 2;
1040 static constexpr int cell_dim = 2;
1041 typedef Shape::Hypercube<shape_dim> ShapeType;
1042 typedef Shape::Simplex<shape_dim> OtherShapeType;
1043 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
1044 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1045 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
1046
1047 static Index refine(
1048 IndexSetType& index_set_out,
1049 const Index offset,
1050 const Index index_offsets[],
1051 const IndexSetHolderType& index_set_holder_in)
1052 {
1053 // fetch vertex index offsets
1054 const Index iov = index_offsets[0];
1055 const Index ioe = index_offsets[1];
1056 const Index iot = index_offsets[2];
1057
1058 // typedef index set vector reference for output index set
1059 typedef IndexSetType::IndexTupleType IndexTupleType;
1060
1061 // typedef index set types
1062 typedef IndexSet<3> IndexSetTypeIn_v_t;
1063 typedef IndexSet<3> IndexSetTypeIn_e_t;
1064
1065 // typedef index vector type
1066 typedef IndexSetTypeIn_v_t::IndexTupleType IndexTupleType_v_t;
1067 typedef IndexSetTypeIn_e_t::IndexTupleType IndexTupleType_e_t;
1068
1069 // fetch the vertices-at-triangle and edge-at-triangle index set
1070 const IndexSetTypeIn_v_t& index_set_in_v_t = index_set_holder_in.get_index_set<2,0>();
1071 const IndexSetTypeIn_e_t& index_set_in_e_t = index_set_holder_in.get_index_set<2,1>();
1072
1073 // fetch number of coarse mesh triangle
1074 const Index num_trias = index_set_in_e_t.get_num_entities();
1075
1076 // loop over all coarse mesh triangles
1077 FEAT_PRAGMA_OMP(parallel for)
1078 for(Index i = 0; i < num_trias; ++i)
1079 {
1080 // fetch coarse mesh vertices-at-triangle and edge-at-triangle index vector
1081 const IndexTupleType_v_t& v_t = index_set_in_v_t[i];
1082 const IndexTupleType_e_t& e_t = index_set_in_e_t[i];
1083
1084 // fetch fine mesh vertices-at-quads index vectors
1085 IndexTupleType& q_0 = index_set_out[offset + 3*i + 0];
1086 IndexTupleType& q_1 = index_set_out[offset + 3*i + 1];
1087 IndexTupleType& q_2 = index_set_out[offset + 3*i + 2];
1088
1089 // start with X and end with the corresponding corner
1090 // follow the convention in between (wiki)
1091 q_0[0] = iot + i; // X
1092 q_0[1] = ioe + e_t[1]; // e_1
1093 q_0[2] = ioe + e_t[2]; // e_2
1094 q_0[3] = iov + v_t[0]; // v_0
1095
1096 q_1[0] = iot + i; // X
1097 q_1[1] = ioe + e_t[2]; // e_2
1098 q_1[2] = ioe + e_t[0]; // e_0
1099 q_1[3] = iov + v_t[1]; // v_1
1100
1101 q_2[0] = iot + i; // X
1102 q_2[1] = ioe + e_t[0]; // e_0
1103 q_2[2] = ioe + e_t[1]; // e_1
1104 q_2[3] = iov + v_t[2]; // v_2
1105
1106 }
1107
1108 // return quads count
1109 return 3*num_trias;
1110 }
1111 };
1112
1118 template<>
1119 struct ShapeConvertIndex<Shape::Hypercube<3>, 2>
1120 {
1121 static constexpr int shape_dim = 3;
1122 static constexpr int cell_dim = 2;
1123 typedef Shape::Hypercube<shape_dim> ShapeType;
1124 typedef Shape::Simplex<shape_dim> OtherShapeType;
1125 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
1126 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1127 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
1128
1129 static Index refine(
1130 IndexSetType& index_set_out,
1131 const Index offset,
1132 const Index index_offsets[],
1133 const IndexSetHolderType& index_set_holder_in)
1134 {
1135 // fetch vertex index offsets
1136 const Index ioe = index_offsets[1];
1137 const Index iot = index_offsets[2];
1138 const Index iotet = index_offsets[3];
1139
1140 // typedef index set vector reference for output index set
1141 typedef IndexSetType::IndexTupleType IndexTupleType;
1142
1143 // typedef index set types
1144 typedef IndexSet<6> IndexSetTypeIn_e_tet;
1145 typedef IndexSet<4> IndexSetTypeIn_t_tet;
1146
1147 // typedef index vector type
1148 typedef IndexSetTypeIn_e_tet::IndexTupleType IndexTupleType_e_tet;
1149 typedef IndexSetTypeIn_t_tet::IndexTupleType IndexTupleType_t_tet;
1150
1151 // fetch the edge-at-tetra and triangle-at-tetra index set
1152 const IndexSetTypeIn_e_tet& index_set_in_e_tet = index_set_holder_in.get_index_set<3,1>();
1153 const IndexSetTypeIn_t_tet& index_set_in_t_tet = index_set_holder_in.get_index_set<3,2>();
1154
1155 // fetch number of coarse mesh tetras
1156 const Index num_tetras = index_set_in_e_tet.get_num_entities();
1157
1158 // loop over all coarse mesh tetras
1159 FEAT_PRAGMA_OMP(parallel for)
1160 for(Index i = 0; i < num_tetras; ++i)
1161 {
1162 // fetch coarse mesh edge-at-tetra and triangle-at-tetra index vector
1163 const IndexTupleType_e_tet& e_tet = index_set_in_e_tet[i];
1164 const IndexTupleType_t_tet& t_tet = index_set_in_t_tet[i];
1165
1166 // fetch fine mesh vertices-at-quad index vectors
1167 IndexTupleType& q_0 = index_set_out[offset + 6*i + 0];
1168 IndexTupleType& q_1 = index_set_out[offset + 6*i + 1];
1169 IndexTupleType& q_2 = index_set_out[offset + 6*i + 2];
1170 IndexTupleType& q_3 = index_set_out[offset + 6*i + 3];
1171 IndexTupleType& q_4 = index_set_out[offset + 6*i + 4];
1172 IndexTupleType& q_5 = index_set_out[offset + 6*i + 5];
1173
1174 // start with X move to the face with lower index
1175 // and end up with edge vertex index
1176 q_0[0] = iotet + i; // X
1177 q_0[1] = iot + t_tet[2]; // t_2
1178 q_0[2] = iot + t_tet[3]; // t_3
1179 q_0[3] = ioe + e_tet[0]; // e_0
1180
1181 q_1[0] = iotet + i; // X
1182 q_1[1] = iot + t_tet[1]; // t_1
1183 q_1[2] = iot + t_tet[3]; // t_3
1184 q_1[3] = ioe + e_tet[1]; // e_1
1185
1186 q_2[0] = iotet + i; // X
1187 q_2[1] = iot + t_tet[1]; // t_1
1188 q_2[2] = iot + t_tet[2]; // t_2
1189 q_2[3] = ioe + e_tet[2]; // e_2
1190
1191 q_3[0] = iotet + i; // X
1192 q_3[1] = iot + t_tet[0]; // t_0
1193 q_3[2] = iot + t_tet[3]; // t_3
1194 q_3[3] = ioe + e_tet[3]; // e_3
1195
1196 q_4[0] = iotet + i; // X
1197 q_4[1] = iot + t_tet[0]; // t_0
1198 q_4[2] = iot + t_tet[2]; // t_2
1199 q_4[3] = ioe + e_tet[4]; // e_4
1200
1201 q_5[0] = iotet + i; // X
1202 q_5[1] = iot + t_tet[0]; // t_0
1203 q_5[2] = iot + t_tet[1]; // t_1
1204 q_5[3] = ioe + e_tet[5]; // e_5
1205
1206 }
1207
1208 // return quad count
1209 return 6*num_tetras;
1210 }
1211 };
1212
1219 template<>
1220 struct ShapeConvertIndex<Shape::Hypercube<3>, 3>
1221 {
1222 static constexpr int shape_dim = 3;
1223 static constexpr int cell_dim = 3;
1224 typedef Shape::Hypercube<shape_dim> ShapeType;
1225 typedef Shape::Simplex<shape_dim> OtherShapeType;
1226 typedef Shape::FaceTraits<ShapeType, cell_dim>::ShapeType CellType;
1227 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1228 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
1229
1230 static Index refine(
1231 IndexSetType& index_set_out,
1232 const Index offset,
1233 const Index index_offsets[],
1234 const IndexSetHolderType& index_set_holder_in)
1235 {
1236 // fetch vertex index offsets
1237 const Index iov = index_offsets[0];
1238 const Index ioe = index_offsets[1];
1239 const Index iot = index_offsets[2];
1240 const Index iotet = index_offsets[3];
1241
1242 // typedef index set vector reference for output index set
1243 typedef IndexSetType::IndexTupleType IndexTupleType;
1244
1245 // typedef index set types
1246 typedef IndexSet<4> IndexSetTypeIn_v_tet;
1247 typedef IndexSet<6> IndexSetTypeIn_e_tet;
1248 typedef IndexSet<4> IndexSetTypeIn_t_tet;
1249
1250 // typedef index vector type
1251 typedef IndexSetTypeIn_v_tet::IndexTupleType IndexTupleType_v_tet;
1252 typedef IndexSetTypeIn_e_tet::IndexTupleType IndexTupleType_e_tet;
1253 typedef IndexSetTypeIn_t_tet::IndexTupleType IndexTupleType_t_tet;
1254
1255 // fetch the vertices-at-tetra, edge-at-tetra and triangle-at-tetra index set
1256 const IndexSetTypeIn_v_tet& index_set_in_v_tet = index_set_holder_in.get_index_set<3,0>();
1257 const IndexSetTypeIn_e_tet& index_set_in_e_tet = index_set_holder_in.get_index_set<3,1>();
1258 const IndexSetTypeIn_t_tet& index_set_in_t_tet = index_set_holder_in.get_index_set<3,2>();
1259
1260 // fetch number of coarse mesh tetras
1261 const Index num_tetras = index_set_in_e_tet.get_num_entities();
1262
1263 // loop over all coarse mesh tetras
1264 FEAT_PRAGMA_OMP(parallel for)
1265 for(Index i = 0; i < num_tetras; ++i)
1266 {
1267 // fetch coarse mesh vertices-at-tetra, edge-at-tetra and triangle-at-tetra index vector
1268 const IndexTupleType_v_tet& v_tet = index_set_in_v_tet[i];
1269 const IndexTupleType_e_tet& e_tet = index_set_in_e_tet[i];
1270 const IndexTupleType_t_tet& t_tet = index_set_in_t_tet[i];
1271
1272 // fetch fine mesh vertices-at-hexa index vectors
1273 IndexTupleType& c_0 = index_set_out[offset + 4*i + 0];
1274 IndexTupleType& c_1 = index_set_out[offset + 4*i + 1];
1275 IndexTupleType& c_2 = index_set_out[offset + 4*i + 2];
1276 IndexTupleType& c_3 = index_set_out[offset + 4*i + 3];
1277
1278 // start with X. move the face with lowest index,
1279 // move to the next lowest face index and proceed according to
1280 // the conventions (wiki) and end with the corresponding corner
1281 c_0[0] = iotet + i; // X
1282 c_0[1] = iot + t_tet[1]; // t_1
1283 c_0[2] = iot + t_tet[2]; // t_2
1284 c_0[3] = ioe + e_tet[2]; // e_2
1285 c_0[4] = iot + t_tet[3]; // t_3
1286 c_0[5] = ioe + e_tet[1]; // e_1
1287 c_0[6] = ioe + e_tet[0]; // e_0
1288 c_0[7] = iov + v_tet[0]; // v_0
1289
1290 c_1[0] = iotet + i; // X
1291 c_1[1] = iot + t_tet[0]; // t_0
1292 c_1[2] = iot + t_tet[2]; // t_2
1293 c_1[3] = ioe + e_tet[4]; // e_4
1294 c_1[4] = iot + t_tet[3]; // t_3
1295 c_1[5] = ioe + e_tet[3]; // e_3
1296 c_1[6] = ioe + e_tet[0]; // e_0
1297 c_1[7] = iov + v_tet[1]; // v_1
1298
1299 c_2[0] = iotet + i; // X
1300 c_2[1] = iot + t_tet[0]; // t_0
1301 c_2[2] = iot + t_tet[1]; // t_1
1302 c_2[3] = ioe + e_tet[5]; // e_5
1303 c_2[4] = iot + t_tet[3]; // t_3
1304 c_2[5] = ioe + e_tet[3]; // e_3
1305 c_2[6] = ioe + e_tet[1]; // e_1
1306 c_2[7] = iov + v_tet[2]; // v_2
1307
1308 c_3[0] = iotet + i; // X
1309 c_3[1] = iot + t_tet[0]; // t_0
1310 c_3[2] = iot + t_tet[1]; // t_1
1311 c_3[3] = ioe + e_tet[5]; // e_5
1312 c_3[4] = iot + t_tet[2]; // t_2
1313 c_3[5] = ioe + e_tet[4]; // e_4
1314 c_3[6] = ioe + e_tet[2]; // e_2
1315 c_3[7] = iov + v_tet[3]; // v_3
1316 }
1317
1318 // return hexa count
1319 return 4*num_tetras;
1320 }
1321 };
1322 /* *************************************************************************************** */
1323 /* *************************************************************************************** */
1324 /* *************************************************************************************** */
1325 /* *************************************************************************************** */
1326 /* *************************************************************************************** */
1327
1328 template<
1329 typename Shape_,
1330 int cell_dim_,
1331 // The following "dummy" argument is necessary for partial specialization;
1332 // shape_dim_ *must* coincide with Shape_::dimension !!!
1333 int shape_dim_ = Shape_::dimension>
1334 struct ShapeConvertIndexShapeWrapper
1335 {
1336 static_assert(shape_dim_ == Shape_::dimension, "invalid shape dimension");
1337 // the case shape_dim_ = cell_dim_ is specialized below
1338 static_assert(shape_dim_ > cell_dim_, "invalid cell dimension");
1339 static_assert(cell_dim_ > 0, "invalid cell dimension");
1340
1341 typedef Shape_ ShapeType;
1342 typedef typename OtherShape<Shape_>::Type OtherShapeType;
1343 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
1344 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1345 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
1346
1347 static String name()
1348 {
1349 return "ShapeConvertIndexShapeWrapper<" + Shape_::name() + "," + stringify(cell_dim_) + ","
1350 + stringify(shape_dim_) + ">";
1351 }
1352
1353 static Index refine(
1354 IndexSetType& index_set_out,
1355 const Index index_offsets[],
1356 const IndexSetHolderType& index_set_holder_in)
1357 {
1358 typedef typename Shape::FaceTraits<ShapeType, shape_dim_ - 1>::ShapeType FacetType;
1359
1360 // refine facets
1361 Index offset = ShapeConvertIndexShapeWrapper<FacetType, cell_dim_>
1362 ::refine(index_set_out, index_offsets, index_set_holder_in);
1363
1364 // call index refiner and return new offset
1365 Index num_faces = ShapeConvertIndex<Shape_, cell_dim_>
1366 ::refine(index_set_out, offset, index_offsets, index_set_holder_in);
1367
1368 // validate number of created indices
1369 Index num_shapes = index_set_holder_in.template get_index_set<shape_dim_, 0>().get_num_entities();
1370 XASSERTM(num_faces == (ShapeConvertTraits<OtherShapeType, cell_dim_>::count * num_shapes),
1371 "ShapeConvertIndex output does not match ShapeConvertTraits prediction");
1372
1373 // calculate new offset and return
1374 return offset + num_faces;
1375 }
1376 };
1377
1378 template<
1379 typename Shape_,
1380 int cell_dim_>
1381 struct ShapeConvertIndexShapeWrapper<Shape_, cell_dim_, cell_dim_>
1382 {
1383 static_assert(cell_dim_ == Shape_::dimension, "invalid shape dimension");
1384 static_assert(cell_dim_ > 0, "invalid cell dimension");
1385
1386 typedef Shape_ ShapeType;
1387 typedef typename OtherShape<Shape_>::Type OtherShapeType;
1388 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
1389 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1390 typedef IndexSetHolder<OtherShapeType> IndexSetHolderType;
1391
1392 static String name()
1393 {
1394 return "ShapeConvertIndexShapeWrapper<" + Shape_::name() + "," + stringify(cell_dim_) + ","
1395 + "," + stringify(cell_dim_) + ">";
1396 }
1397
1398 static Index refine(
1399 IndexSetType& index_set_out,
1400 const Index index_offsets[],
1401 const IndexSetHolderType& index_set_holder_in)
1402 {
1403 // call index refiner
1404 Index num_faces = ShapeConvertIndex<Shape_, cell_dim_>
1405 ::refine(index_set_out, 0, index_offsets, index_set_holder_in);
1406
1407 // validate number of created indices
1408 Index num_shapes = index_set_holder_in.template get_index_set<cell_dim_, 0>().get_num_entities();
1409 XASSERTM(num_faces == (ShapeConvertTraits<OtherShapeType, cell_dim_>::count * num_shapes),
1410 "ShapeConvertIndex output does not match ShapeConvertTraits prediction");
1411
1412 // return offset
1413 return num_faces;
1414 }
1415 };
1416
1417 /* ********************************************************************************************************* */
1418
1419 template<
1420 typename Shape_,
1421 int cell_dim_ = Shape_::dimension>
1422 struct ShapeConvertIndexWrapper
1423 {
1424 // the case cell_dim_ = 1 is handled by the partial specialization below
1425 static_assert(cell_dim_ > 1, "invalid cell dimension");
1426 static_assert(cell_dim_ <= Shape_::dimension, "invalid cell dimension");
1427
1428 typedef Shape_ ShapeType;
1429 typedef typename OtherShape<Shape_>::Type OtherShapeType;
1430 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
1431 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1432 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
1433 typedef IndexSetHolder<OtherShapeType> IndexSetHolderTypeIn;
1434
1435 static String name()
1436 {
1437 return "ShapeConvertIndexWrapper<" + Shape_::name() + "," + stringify(cell_dim_) + ">";
1438 }
1439
1440 static void refine(
1441 IndexSetHolderType& index_set_holder_out,
1442 const Index num_entities[],
1443 const IndexSetHolderTypeIn& index_set_holder_in)
1444 {
1445 // recursive call of IndexRefineWrapper
1446 ShapeConvertIndexWrapper<Shape_, cell_dim_ - 1>
1447 ::refine(index_set_holder_out, num_entities, index_set_holder_in);
1448
1449 // fetch output index set
1450 IndexSetType& index_set_out = index_set_holder_out.template get_index_set<cell_dim_, 0>();
1451
1452 // calculate index offsets
1453 Index index_offsets[Shape_::dimension+1];
1454 EntityCounter<ShapeConvertTraits,OtherShapeType, 0>::offset(index_offsets, num_entities);
1455
1456 // call face wrapper
1457 ShapeConvertIndexShapeWrapper<Shape_, cell_dim_>
1458 ::refine(index_set_out, index_offsets, index_set_holder_in);
1459 }
1460 };
1461
1462 template<typename Shape_>
1463 struct ShapeConvertIndexWrapper<Shape_, 1>
1464 {
1465 static_assert(1 <= Shape_::dimension, "invalid shape dimension");
1466
1467 typedef Shape_ ShapeType;
1468 typedef typename OtherShape<Shape_>::Type OtherShapeType;
1469 typedef typename Shape::FaceTraits<ShapeType, 1>::ShapeType CellType;
1470 typedef IndexSet<Shape::FaceTraits<CellType, 0>::count> IndexSetType;
1471 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
1472 typedef IndexSetHolder<OtherShapeType> IndexSetHolderTypeIn;
1473
1474 static String name()
1475 {
1476 return "ShapeConvertIndexWrapper<" + Shape_::name() + ",1>";
1477 }
1478
1479 static void refine(
1480 IndexSetHolderType& index_set_holder_out,
1481 const Index num_entities[],
1482 const IndexSetHolderTypeIn& index_set_holder_in)
1483 {
1484 // fetch output index set
1485 IndexSetType& index_set_out = index_set_holder_out.template get_index_set<1, 0>();
1486
1487 // calculate index offsets
1488 Index index_offsets[Shape_::dimension+1];
1489 EntityCounter<ShapeConvertTraits,OtherShapeType, 0>::offset(index_offsets, num_entities);
1490
1491 // call face wrapper
1492 ShapeConvertIndexShapeWrapper<Shape_, 1>::refine(index_set_out, index_offsets, index_set_holder_in);
1493 }
1494 };
1495 } // namespace Intern
1497 } // namespace Geometry
1498} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT namespace.
Definition: adjactor.hpp:12
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:993
std::uint64_t Index
Index data type.