FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
standard_target_refiner.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/target_set.hpp>
11#include <kernel/geometry/intern/target_index_mapping.hpp>
12
13namespace FEAT
14{
15 namespace Geometry
16 {
18 namespace Intern
19 {
20 template<
21 typename Shape_,
22 int cell_dim_>
23 struct StandardTargetRefiner;
24
25 template<>
26 struct StandardTargetRefiner<Shape::Vertex, 0>
27 {
28 typedef Shape::Vertex ShapeType;
29 typedef TargetSet TargetSetType;
30 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
31
32 static Index refine(
33 TargetSetType& target_set_out,
34 const Index offset,
35 const Index* index_offsets,
36 const TargetSetHolderType& target_set_holder_in)
37 {
38 const Index num_verts = target_set_holder_in.get_num_entities(0);
39 const TargetSetType& target_set_in = target_set_holder_in.get_target_set<0>();
40
41 FEAT_PRAGMA_OMP(parallel for)
42 for(Index i = 0; i < num_verts; ++i)
43 {
44 target_set_out[i] = index_offsets[0] + target_set_in[offset + i];
45 }
46
47 return num_verts;
48 }
49 };
50
56 template<int shape_dim_>
57 struct StandardTargetRefiner<Shape::Simplex<shape_dim_>, 0>
58 {
59 typedef Shape::Simplex<shape_dim_> ShapeType;
60 typedef TargetSet TargetSetType;
61 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
62 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
63
64 static Index refine(
65 TargetSetType& target_set_out,
66 const Index offset,
67 const Index* index_offsets,
68 const TargetSetHolderType& target_set_holder_in,
69 const IndexSetHolderType& /*index_set_holder_src*/,
70 const IndexSetHolderType& /*index_set_holder_trg*/)
71 {
72 // fetch indices
73 const TargetSet& target_set_in = target_set_holder_in.template get_target_set<shape_dim_>();
74 Index num_cells = target_set_in.get_num_entities();
75
76 // set target indices
77 FEAT_PRAGMA_OMP(parallel for)
78 for(Index i = 0; i < num_cells; ++i)
79 {
80 target_set_out[offset + i] = index_offsets[shape_dim_] + target_set_in[i];
81 }
82
83 return num_cells;
84 }
85 }; // StandardTargetRefiner<Shape::Simplex<...>, 0>
86
92 template<>
93 struct StandardTargetRefiner<Shape::Simplex<1>, 1>
94 {
95 typedef Shape::Simplex<1> ShapeType;
96 typedef TargetSet TargetSetType;
97 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
98 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
99
100 static Index refine(
101 TargetSetType& target_set_out,
102 const Index offset,
103 const Index* index_offsets,
104 const TargetSetHolderType& target_set_holder_in,
105 const IndexSetHolderType& index_set_holder_src,
106 const IndexSetHolderType& index_set_holder_trg)
107 {
108 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
109
110 // fetch index offset
111 const Index ioe = index_offsets[1];
112
113 // typedef index set types
114 typedef IndexSet<2> IndexSetTypeEV;
115
116 // typedef index vector type
117 typedef IndexSetTypeEV::IndexTupleType IndexTupleTypeEV;
118
119 // fetch the edge-vertex index sets
120 const IndexSetTypeEV& index_src_e_v = index_set_holder_src.get_index_set<1,0>();
121 const IndexSetTypeEV& index_trg_e_v = index_set_holder_trg.get_index_set<1,0>();
122
123 // fetch target indices
124 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
125 const TargetSet& target_set_e = target_set_holder_in.get_target_set<1>();
126 Index num_cells = target_set_e.get_num_entities();
127
128 // set target indices
129 FEAT_PRAGMA_OMP(parallel for)
130 for(Index i = 0; i < num_cells; ++i)
131 {
132 // fetch edge target index
133 const Index trg_e = target_set_e[i];
134
135 // fetch target edge-vert index vector
136 const IndexTupleTypeEV& trg_e_v = index_trg_e_v[trg_e];
137
138 // fetch source edge-vert index vector
139 const IndexTupleTypeEV& src_e_v = index_src_e_v[i];
140
141 // create a target-index mapping object
142 TargetIndexMappingType tim(trg_e_v, src_e_v, target_set_v);
143
144 // fetch fine mesh target indices
145 Index& e_0 = target_set_out[offset + 2*i + 0];
146 Index& e_1 = target_set_out[offset + 2*i + 1];
147
148 // calculate fine edge target indices
149 e_0 = ioe + 2*trg_e + tim.map(0);
150 e_1 = ioe + 2*trg_e + tim.map(1);
151 }
152 return 2*num_cells;
153 }
154 }; // StandardTargetRefiner<Shape::Simplex<1>,1>
155
161 template<>
162 struct StandardTargetRefiner<Shape::Simplex<2>, 0>
163 {
164 typedef Shape::Simplex<2> ShapeType;
165 typedef TargetSet TargetSetType;
166 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
167 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
168
169 static Index refine(
170 TargetSetType& /*target_set_out*/,
171 const Index /*offset*/,
172 const Index* /*index_offsets*/,
173 const TargetSetHolderType& /*target_set_holder_in*/,
174 const IndexSetHolderType& /*index_set_holder_src*/,
175 const IndexSetHolderType& /*index_set_holder_trg*/)
176 {
177 return 0;
178 }
179 }; // StandardTargetRefiner<Shape::Simplex<2>, 0>
180
186 template<>
187 struct StandardTargetRefiner<Shape::Simplex<2>, 1>
188 {
189 typedef Shape::Simplex<2> ShapeType;
190 typedef TargetSet TargetSetType;
191 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
192 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
193
194 static Index refine(
195 TargetSetType& target_set_out,
196 const Index offset,
197 const Index* index_offsets,
198 const TargetSetHolderType& target_set_holder_in,
199 const IndexSetHolderType& index_set_holder_src,
200 const IndexSetHolderType& index_set_holder_trg)
201 {
202 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
203
204 // fetch index offset
205 const Index ioe = index_offsets[2];
206
207 // typedef index set types
208 typedef IndexSet<3> IndexSetTypeTV;
209
210 // typedef index vector type
211 typedef IndexSetTypeTV::IndexTupleType IndexTupleTypeTV;
212
213 // fetch the tria-vertex index sets
214 const IndexSetTypeTV& index_src_t_v = index_set_holder_src.get_index_set<2,0>();
215 const IndexSetTypeTV& index_trg_t_v = index_set_holder_trg.get_index_set<2,0>();
216
217 // fetch target indices
218 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
219 const TargetSet& target_set_t = target_set_holder_in.get_target_set<2>();
220 Index num_cells = target_set_t.get_num_entities();
221
222 // set target indices
223 FEAT_PRAGMA_OMP(parallel for)
224 for(Index i = 0; i < num_cells; ++i)
225 {
226 // fetch tria target index
227 const Index trg_t = target_set_t[i];
228
229 // fetch target triangle-vert index vector
230 const IndexTupleTypeTV& trg_t_v = index_trg_t_v[trg_t];
231
232 // fetch source edge-vert index vector
233 const IndexTupleTypeTV& src_t_v = index_src_t_v[i];
234
235 // create a target-index mapping object
236 TargetIndexMappingType tim(trg_t_v, src_t_v, target_set_v);
237
238 // fetch fine mesh target indices
239 Index& e_0 = target_set_out[offset + 3*i + 0];
240 Index& e_1 = target_set_out[offset + 3*i + 1];
241 Index& e_2 = target_set_out[offset + 3*i + 2];
242
243 // calculate fine edge target indices
244 e_0 = ioe + 3*trg_t + tim.map(0);
245 e_1 = ioe + 3*trg_t + tim.map(1);
246 e_2 = ioe + 3*trg_t + tim.map(2);
247 }
248 return 3*num_cells;
249 }
250 }; // StandardTargetRefiner<Shape::Simplex<2>,1>
251
257 template<>
258 struct StandardTargetRefiner<Shape::Simplex<2>, 2>
259 {
260 typedef Shape::Simplex<2> ShapeType;
261 typedef TargetSet TargetSetType;
262 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
263 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
264
265 static Index refine(
266 TargetSetType& target_set_out,
267 const Index offset,
268 const Index* index_offsets,
269 const TargetSetHolderType& target_set_holder_in,
270 const IndexSetHolderType& index_set_holder_src,
271 const IndexSetHolderType& index_set_holder_trg)
272 {
273 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
274
275 // fetch index offset
276 const Index iot = index_offsets[2];
277
278 // typedef index set types
279 typedef IndexSet<3> IndexSetTypeTV;
280
281 // typedef index vector type
282 typedef IndexSetTypeTV::IndexTupleType IndexTupleTypeTV;
283
284 // fetch the tria-vertex index sets
285 const IndexSetTypeTV& index_src_t_v = index_set_holder_src.get_index_set<2,0>();
286 const IndexSetTypeTV& index_trg_t_v = index_set_holder_trg.get_index_set<2,0>();
287
288 // fetch target indices
289 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
290 const TargetSet& target_set_t = target_set_holder_in.get_target_set<2>();
291 Index num_cells = target_set_t.get_num_entities();
292
293 // set target indices
294 FEAT_PRAGMA_OMP(parallel for)
295 for(Index i = 0; i < num_cells; ++i)
296 {
297 // fetch tria target index
298 const Index trg_t = target_set_t[i];
299
300 // fetch target tria-vert index vector
301 const IndexTupleTypeTV& trg_t_v = index_trg_t_v[trg_t];
302
303 // fetch source edge-vert index vector
304 const IndexTupleTypeTV& src_t_v = index_src_t_v[i];
305
306 // create a target-index mapping object
307 TargetIndexMappingType tim(trg_t_v, src_t_v, target_set_v);
308
309 // fetch fine mesh target indices
310 Index& t_0 = target_set_out[offset + 4*i + 0];
311 Index& t_1 = target_set_out[offset + 4*i + 1];
312 Index& t_2 = target_set_out[offset + 4*i + 2];
313 Index& t_3 = target_set_out[offset + 4*i + 3];
314
315 // calculate fine triangle target indices
316 t_0 = iot + 4*trg_t + tim.map(0);
317 t_1 = iot + 4*trg_t + tim.map(1);
318 t_2 = iot + 4*trg_t + tim.map(2);
319 t_3 = iot + 4*trg_t + 3;
320 }
321
322 return 4*num_cells;
323 }
324 }; // StandardTargetRefiner<Shape::Simplex<2>,2>
325
331 template<int cell_dim_>
332 struct StandardTargetRefiner<Shape::Simplex<3>, cell_dim_>
333 {
334 typedef Shape::Simplex<3> ShapeType;
335 typedef TargetSet TargetSetType;
336 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
337 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
338
339 static Index refine(
340 TargetSetType& /*target_set_out*/,
341 const Index /*offset*/,
342 const Index* /*index_offsets*/,
343 const TargetSetHolderType& target_set_holder_in,
344 const IndexSetHolderType& /*index_set_holder_src*/,
345 const IndexSetHolderType& /*index_set_holder_trg*/)
346 {
347 // We do not have an implementation of 3D tetrahedral submeshes yet due to the lack of a
348 // tetrahedral congruency sampler (see Congruency::Sampler<...> class template) which is needed
349 // to implement this function. However, this function will also be called when refining a
350 // 2D submesh of a 3D tetrahedral mesh -- in this case the number of tetrahedra is zero,
351 // so we'll check for that to ensure that we don't prohibit this valid scenario.
352 Index num_cells = target_set_holder_in.get_target_set<3>().get_num_entities();
353 XASSERTM(num_cells == 0, "TargetSet refinement not implemented for Tetrahedra");
354
355 // okay, no tetrahedron to be refined...
356 return 0;
357 }
358 }; // StandardTargetRefiner<Shape::Simplex<3>,...>
359
367 template<>
368 struct StandardTargetRefiner<Shape::Simplex<3>,0>
369 {
370 typedef Shape::Simplex<3> ShapeType;
371 typedef TargetSet TargetSetType;
372 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
373 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
374
375 static Index refine(
376 TargetSetType& /*target_set_out*/,
377 const Index /*offset*/,
378 const Index* /*index_offsets*/,
379 const TargetSetHolderType& /*target_set_holder_in*/,
380 const IndexSetHolderType& /*index_set_holder_src*/,
381 const IndexSetHolderType& /*index_set_holder_trg*/)
382 {
383 return 0;
384 }
385 }; // StandardTargetRefiner<Shape::Simplex<3>,...>
391 template<int shape_dim_>
392 struct StandardTargetRefiner<Shape::Hypercube<shape_dim_>, 0>
393 {
394 typedef Shape::Hypercube<shape_dim_> ShapeType;
395 typedef TargetSet TargetSetType;
396 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
397 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
398
399 static Index refine(
400 TargetSetType& target_set_out,
401 const Index offset,
402 const Index* index_offsets,
403 const TargetSetHolderType& target_set_holder_in,
404 const IndexSetHolderType& /*index_set_holder_src*/,
405 const IndexSetHolderType& /*index_set_holder_trg*/)
406 {
407 // fetch indices
408 const TargetSet& target_set_in = target_set_holder_in.template get_target_set<shape_dim_>();
409 Index num_cells = target_set_in.get_num_entities();
410
411 // set target indices
412 FEAT_PRAGMA_OMP(parallel for)
413 for(Index i = 0; i < num_cells; ++i)
414 {
415 target_set_out[offset + i] = index_offsets[shape_dim_] + target_set_in[i];
416 }
417
418 return num_cells;
419 }
420 }; // StandardTargetRefiner<Shape::Hypercube<...>, 0>
421
427 template<>
428 struct StandardTargetRefiner<Shape::Hypercube<1>, 1>
429 {
430 typedef Shape::Hypercube<1> ShapeType;
431 typedef TargetSet TargetSetType;
432 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
433 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
434
435 static Index refine(
436 TargetSetType& target_set_out,
437 const Index offset,
438 const Index* index_offsets,
439 const TargetSetHolderType& target_set_holder_in,
440 const IndexSetHolderType& index_set_holder_src,
441 const IndexSetHolderType& index_set_holder_trg)
442 {
443 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
444
445 // fetch index offset
446 const Index ioe = index_offsets[1];
447
448 // typedef index set types
449 typedef IndexSet<2> IndexSetTypeEV;
450
451 // typedef index vector type
452 typedef IndexSetTypeEV::IndexTupleType IndexTupleTypeEV;
453
454 // fetch the edge-vertex index sets
455 const IndexSetTypeEV& index_src_e_v = index_set_holder_src.get_index_set<1,0>();
456 const IndexSetTypeEV& index_trg_e_v = index_set_holder_trg.get_index_set<1,0>();
457
458 // fetch target indices
459 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
460 const TargetSet& target_set_e = target_set_holder_in.get_target_set<1>();
461 Index num_cells = target_set_e.get_num_entities();
462
463 // set target indices
464 FEAT_PRAGMA_OMP(parallel for)
465 for(Index i = 0; i < num_cells; ++i)
466 {
467 // fetch edge target index
468 const Index trg_e = target_set_e[i];
469
470 // fetch target edge-vert index vector
471 const IndexTupleTypeEV& trg_e_v = index_trg_e_v[trg_e];
472
473 // fetch source edge-vert index vector
474 const IndexTupleTypeEV& src_e_v = index_src_e_v[i];
475
476 // create a target-index mapping object
477 TargetIndexMappingType tim(trg_e_v, src_e_v, target_set_v);
478
479 // fetch fine mesh target indices
480 Index& e_0 = target_set_out[offset + 2*i + 0];
481 Index& e_1 = target_set_out[offset + 2*i + 1];
482
483 // calculate fine edge target indices
484 e_0 = ioe + 2*trg_e + tim.map(0);
485 e_1 = ioe + 2*trg_e + tim.map(1);
486 }
487
488 return 2*num_cells;
489 }
490 }; // StandardTargetRefiner<Shape::Hypercube<1>,1>
491
492
498 template<>
499 struct StandardTargetRefiner<Shape::Hypercube<2>, 1>
500 {
501 typedef Shape::Hypercube<2> ShapeType;
502 typedef TargetSet TargetSetType;
503 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
504 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
505
506 static Index refine(
507 TargetSetType& target_set_out,
508 const Index offset,
509 const Index* index_offsets,
510 const TargetSetHolderType& target_set_holder_in,
511 const IndexSetHolderType& index_set_holder_src,
512 const IndexSetHolderType& index_set_holder_trg)
513 {
514 typedef TargetIndexMapping<ShapeType, 1> TargetIndexMappingType;
515
516 // fetch index offset
517 const Index ioe = index_offsets[2];
518
519 // typedef index set types
520 typedef IndexSet<4> IndexSetTypeQV;
521
522 // typedef index vector type
523 typedef IndexSetTypeQV::IndexTupleType IndexTupleTypeQV;
524
525 // fetch the quad-vertex index sets
526 const IndexSetTypeQV& index_src_q_v = index_set_holder_src.get_index_set<2,0>();
527 const IndexSetTypeQV& index_trg_q_v = index_set_holder_trg.get_index_set<2,0>();
528
529 // fetch target indices
530 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
531 const TargetSet& target_set_q = target_set_holder_in.get_target_set<2>();
532 Index num_cells = target_set_q.get_num_entities();
533
534 // set target indices
535 FEAT_PRAGMA_OMP(parallel for)
536 for(Index i = 0; i < num_cells; ++i)
537 {
538 // fetch quad target index
539 const Index trg_q = target_set_q[i];
540
541 // fetch target quad-vert index vector
542 const IndexTupleTypeQV& trg_q_v = index_trg_q_v[trg_q];
543
544 // fetch source edge-vert index vector
545 const IndexTupleTypeQV& src_q_v = index_src_q_v[i];
546
547 // create a target-index mapping object
548 TargetIndexMappingType tim(trg_q_v, src_q_v, target_set_v);
549
550 // fetch fine mesh target indices
551 Index& e_0 = target_set_out[offset + 4*i + 0];
552 Index& e_1 = target_set_out[offset + 4*i + 1];
553 Index& e_2 = target_set_out[offset + 4*i + 2];
554 Index& e_3 = target_set_out[offset + 4*i + 3];
555
556 // calculate fine edge target indices
557 e_0 = ioe + 4*trg_q + tim.map(0);
558 e_1 = ioe + 4*trg_q + tim.map(1);
559 e_2 = ioe + 4*trg_q + tim.map(2);
560 e_3 = ioe + 4*trg_q + tim.map(3);
561 }
562
563 return 4*num_cells;
564 }
565 }; // StandardTargetRefiner<Shape::Hypercube<2>,1>
566
572 template<>
573 struct StandardTargetRefiner<Shape::Hypercube<2>, 2>
574 {
575 typedef Shape::Hypercube<2> ShapeType;
576 typedef TargetSet TargetSetType;
577 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
578 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
579
580 static Index refine(
581 TargetSetType& target_set_out,
582 const Index offset,
583 const Index* index_offsets,
584 const TargetSetHolderType& target_set_holder_in,
585 const IndexSetHolderType& index_set_holder_src,
586 const IndexSetHolderType& index_set_holder_trg)
587 {
588 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
589
590 // fetch index offset
591 const Index ioe = index_offsets[2];
592
593 // typedef index set types
594 typedef IndexSet<4> IndexSetTypeQV;
595
596 // typedef index vector type
597 typedef IndexSetTypeQV::IndexTupleType IndexTupleTypeQV;
598
599 // fetch the quad-vertex index sets
600 const IndexSetTypeQV& index_src_q_v = index_set_holder_src.get_index_set<2,0>();
601 const IndexSetTypeQV& index_trg_q_v = index_set_holder_trg.get_index_set<2,0>();
602
603 // fetch target indices
604 const TargetSet& target_set_v = target_set_holder_in.get_target_set<0>();
605 const TargetSet& target_set_q = target_set_holder_in.get_target_set<2>();
606 Index num_cells = target_set_q.get_num_entities();
607
608 // set target indices
609 FEAT_PRAGMA_OMP(parallel for)
610 for(Index i = 0; i < num_cells; ++i)
611 {
612 // fetch quad target index
613 const Index trg_q = target_set_q[i];
614
615 // fetch target quad-vert index vector
616 const IndexTupleTypeQV& trg_q_v = index_trg_q_v[trg_q];
617
618 // fetch source edge-vert index vector
619 const IndexTupleTypeQV& src_q_v = index_src_q_v[i];
620
621 // create a target-index mapping object
622 TargetIndexMappingType tim(trg_q_v, src_q_v, target_set_v);
623
624 // fetch fine mesh target indices
625 Index& q_0 = target_set_out[offset + 4*i + 0];
626 Index& q_1 = target_set_out[offset + 4*i + 1];
627 Index& q_2 = target_set_out[offset + 4*i + 2];
628 Index& q_3 = target_set_out[offset + 4*i + 3];
629
630 // calculate fine quad target indices
631 q_0 = ioe + 4*trg_q + tim.map(0);
632 q_1 = ioe + 4*trg_q + tim.map(1);
633 q_2 = ioe + 4*trg_q + tim.map(2);
634 q_3 = ioe + 4*trg_q + tim.map(3);
635 }
636
637 return 4*num_cells;
638 }
639 }; // StandardTargetRefiner<Shape::Hypercube<2>,2>
640
646 template<int cell_dim_>
647 struct StandardTargetRefiner<Shape::Hypercube<3>, cell_dim_>
648 {
649 typedef Shape::Hypercube<3> ShapeType;
650 typedef TargetSet TargetSetType;
651 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
652 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
653
654 static Index refine(
655 TargetSetType& /*target_set_out*/,
656 const Index /*offset*/,
657 const Index* /*index_offsets*/,
658 const TargetSetHolderType& target_set_holder_in,
659 const IndexSetHolderType& /*index_set_holder_src*/,
660 const IndexSetHolderType& /*index_set_holder_trg*/)
661 {
662 // We do not have an implementation of 3D hexahedral submeshes yet due to the lack of a
663 // hexahedral congruency sampler (see Congruency::Sampler<...> class template) which is needed
664 // to implement this function. However, this function will also be called when refining a
665 // 2D submesh of a 3D hexahedral mesh -- in this case the number of hexahedra is zero,
666 // so we'll check for that to ensure that we don't prohibit this valid scenario.
667 Index num_cells = target_set_holder_in.get_target_set<3>().get_num_entities();
668 XASSERTM(num_cells == 0, "TargetSet refinement not implemented for Hexahedra");
669
670 // okay, no hexahedra to be refined...
671 return 0;
672 }
673 }; // StandardTargetRefiner<Shape::Hypercube<3>,...>
674
682 template<>
683 struct StandardTargetRefiner<Shape::Hypercube<3>,0>
684 {
685 typedef Shape::Hypercube<3> ShapeType;
686 typedef TargetSet TargetSetType;
687 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
688 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
689
690 static Index refine(
691 TargetSetType& /*target_set_out*/,
692 const Index /*offset*/,
693 const Index* /*index_offsets*/,
694 const TargetSetHolderType& /*target_set_holder_in*/,
695 const IndexSetHolderType& /*index_set_holder_src*/,
696 const IndexSetHolderType& /*index_set_holder_trg*/)
697 {
698 return 0;
699 }
700 }; // StandardTargetRefiner<Shape::Hypercube<3>,...>
701
702 /* *************************************************************************************** */
703 /* *************************************************************************************** */
704 /* *************************************************************************************** */
705 /* *************************************************************************************** */
706 /* *************************************************************************************** */
707
708 template<
709 typename Shape_,
710 int cell_dim_,
711 int shape_dim_ = Shape_::dimension>
712 class TargetRefineShapeWrapper
713 {
714 public:
715 typedef Shape_ ShapeType;
716 typedef TargetSet TargetSetType;
717 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
718 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
719
720 static String name()
721 {
722 return "TargetRefineShapeWrapper<" + Shape_::name() + "," + stringify(cell_dim_)
723 + "," + stringify(shape_dim_) + ">";
724 }
725
726 static Index refine(
727 TargetSetType& target_set_out,
728 const Index index_offsets[],
729 const TargetSetHolderType& target_set_holder_in,
730 const IndexSetHolderType& index_set_holder_src,
731 const IndexSetHolderType& index_set_holder_trg)
732 {
733 // recursive call of TargetRefineShapeWrapper
734 typedef typename Shape::FaceTraits<ShapeType, shape_dim_ - 1>::ShapeType FacetType;
735 Index offset = TargetRefineShapeWrapper<FacetType, cell_dim_>::refine(
736 target_set_out,
737 index_offsets,
738 target_set_holder_in,
739 index_set_holder_src,
740 index_set_holder_trg);
741
742 // call target refiner
743 StandardTargetRefiner<ShapeType, cell_dim_>::refine(
744 target_set_out,
745 offset,
746 index_offsets,
747 target_set_holder_in,
748 index_set_holder_src,
749 index_set_holder_trg);
750
751 // return new offset
752 return offset + Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count *
753 target_set_holder_in.get_num_entities(shape_dim_);
754 }
755 };
756
757 template<
758 typename Shape_,
759 int cell_dim_>
760 class TargetRefineShapeWrapper<Shape_, cell_dim_, cell_dim_>
761 {
762 public:
763 typedef Shape_ ShapeType;
764 typedef TargetSet TargetSetType;
765 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
766 typedef TargetSetHolder<CellType> TargetSetHolderType;
767 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
768
769 static String name()
770 {
771 return "TargetRefineShapeWrapper<" + Shape_::name() + "," + stringify(cell_dim_)
772 + "," + stringify(cell_dim_) + ">";
773 }
774
775 static Index refine(
776 TargetSetType& target_set_out,
777 const Index index_offsets[],
778 const TargetSetHolderType& target_set_holder_in,
779 const IndexSetHolderType& index_set_holder_src,
780 const IndexSetHolderType& index_set_holder_trg)
781 {
782 // call target refiner
783 StandardTargetRefiner<ShapeType, cell_dim_>::refine(
784 target_set_out,
785 0,
786 index_offsets,
787 target_set_holder_in,
788 index_set_holder_src,
789 index_set_holder_trg);
790
791 // return new offset
792 return Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count
793 * target_set_holder_in.get_num_entities(cell_dim_);
794 }
795 };
796
797 template<int cell_dim_>
798 class TargetRefineShapeWrapper<Shape::Vertex, cell_dim_, cell_dim_>
799 {
800 public:
801 typedef Shape::Vertex ShapeType;
802 typedef TargetSet TargetSetType;
803 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
804 typedef TargetSetHolder<CellType> TargetSetHolderType;
805 typedef IndexSetHolder<Shape::Vertex> IndexSetHolderType;
806
807 static String name()
808 {
809 return "TargetRefineShapeWrapper<Vertex," + stringify(cell_dim_) + "," + stringify(cell_dim_) + ">";
810 }
811
812 static Index refine(
813 TargetSetType& target_set_out,
814 const Index index_offsets[],
815 const TargetSetHolderType& target_set_holder_in,
816 const IndexSetHolderType& /*index_set_holder_src*/,
817 const IndexSetHolderType& /*index_set_holder_trg*/)
818 {
819 // call target refiner
820 StandardTargetRefiner<ShapeType, cell_dim_>
821 ::refine(target_set_out, 0, index_offsets, target_set_holder_in);
822
823 // return new offset
824 return Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count
825 * target_set_holder_in.get_num_entities(cell_dim_);
826 }
827 };
828
829 /* ********************************************************************************************************* */
830
831 template<
832 typename Shape_,
833 int cell_dim_ = Shape_::dimension>
834 class TargetRefineWrapper
835 {
836 public:
837 typedef Shape_ ShapeType;
838 typedef TargetSet TargetSetType;
839 typedef typename Shape::FaceTraits<ShapeType, cell_dim_>::ShapeType CellType;
840 typedef TargetSetHolder<CellType> TargetSetHolderTypeOut;
841 typedef TargetSetHolder<ShapeType> TargetSetHolderTypeIn;
842 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
843
844 static String name()
845 {
846 return "TargetRefineWrapper<" + Shape_::name() + "," + stringify(cell_dim_) + ">";
847 }
848
849 static void refine(
850 TargetSetHolderTypeOut& target_set_holder_out,
851 const Index num_entities_trg[],
852 const TargetSetHolderTypeIn& target_set_holder_in,
853 const IndexSetHolderType& index_set_holder_src,
854 const IndexSetHolderType& index_set_holder_trg)
855 {
856 // recursive call of TargetRefineWrapper
857 TargetRefineWrapper<ShapeType, cell_dim_ - 1>::refine(
858 target_set_holder_out,
859 num_entities_trg,
860 target_set_holder_in,
861 index_set_holder_src,
862 index_set_holder_trg);
863
864 // calculate index offsets
865 Index index_offsets[Shape_::dimension+1];
866 Intern::EntityCounter<Intern::StandardRefinementTraits, ShapeType, cell_dim_>
867 ::offset(index_offsets, num_entities_trg);
868
869 // call shape wrapper
870 TargetRefineShapeWrapper<ShapeType, cell_dim_>::refine(
871 target_set_holder_out.template get_target_set<cell_dim_>(),
872 index_offsets,
873 target_set_holder_in,
874 index_set_holder_src,
875 index_set_holder_trg);
876 }
877 };
878
879 template<typename Shape_>
880 class TargetRefineWrapper<Shape_, 0>
881 {
882 public:
883 typedef Shape_ ShapeType;
884 typedef TargetSet TargetSetType;
885 typedef TargetSetHolder<Shape::Vertex> TargetSetHolderTypeOut;
886 typedef TargetSetHolder<ShapeType> TargetSetHolderTypeIn;
887 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
888
889 static String name()
890 {
891 return "TargetRefineWrapper<" + Shape_::name() + ",0>";
892 }
893
894 static void refine(
895 TargetSetHolderTypeOut& target_set_holder_out,
896 const Index num_entities_trg[],
897 const TargetSetHolderTypeIn& target_set_holder_in,
898 const IndexSetHolderType& index_set_holder_src,
899 const IndexSetHolderType& index_set_holder_trg)
900 {
901 // calculate index offsets
902 Index index_offsets[Shape_::dimension+1];
903 Intern::EntityCounter<Intern::StandardRefinementTraits, ShapeType, 0>::offset(index_offsets, num_entities_trg);
904
905 // call shape wrapper
906 TargetRefineShapeWrapper<ShapeType, 0>::refine(
907 target_set_holder_out.template get_target_set<0>(),
908 index_offsets,
909 target_set_holder_in,
910 index_set_holder_src,
911 index_set_holder_trg);
912 }
913 };
914 } // namespace Intern
916 } // namespace Geometry
917} // 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:944
std::uint64_t Index
Index data type.