9#include <kernel/geometry/index_set.hpp>
10#include <kernel/geometry/target_set.hpp>
11#include <kernel/geometry/intern/target_index_mapping.hpp>
23 struct StandardTargetRefiner;
26 struct StandardTargetRefiner<Shape::Vertex, 0>
28 typedef Shape::Vertex ShapeType;
29 typedef TargetSet TargetSetType;
30 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
33 TargetSetType& target_set_out,
35 const Index* index_offsets,
36 const TargetSetHolderType& target_set_holder_in)
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>();
41 FEAT_PRAGMA_OMP(parallel
for)
42 for(Index i = 0; i < num_verts; ++i)
44 target_set_out[i] = index_offsets[0] + target_set_in[offset + i];
56 template<
int shape_dim_>
57 struct StandardTargetRefiner<Shape::Simplex<shape_dim_>, 0>
59 typedef Shape::Simplex<shape_dim_> ShapeType;
60 typedef TargetSet TargetSetType;
61 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
62 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
65 TargetSetType& target_set_out,
67 const Index* index_offsets,
68 const TargetSetHolderType& target_set_holder_in,
69 const IndexSetHolderType& ,
70 const IndexSetHolderType& )
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();
77 FEAT_PRAGMA_OMP(parallel
for)
78 for(Index i = 0; i < num_cells; ++i)
80 target_set_out[offset + i] = index_offsets[shape_dim_] + target_set_in[i];
93 struct StandardTargetRefiner<Shape::Simplex<1>, 1>
95 typedef Shape::Simplex<1> ShapeType;
96 typedef TargetSet TargetSetType;
97 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
98 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
101 TargetSetType& target_set_out,
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)
108 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
111 const Index ioe = index_offsets[1];
114 typedef IndexSet<2> IndexSetTypeEV;
117 typedef IndexSetTypeEV::IndexTupleType IndexTupleTypeEV;
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>();
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();
129 FEAT_PRAGMA_OMP(parallel
for)
130 for(Index i = 0; i < num_cells; ++i)
133 const Index trg_e = target_set_e[i];
136 const IndexTupleTypeEV& trg_e_v = index_trg_e_v[trg_e];
139 const IndexTupleTypeEV& src_e_v = index_src_e_v[i];
142 TargetIndexMappingType tim(trg_e_v, src_e_v, target_set_v);
145 Index& e_0 = target_set_out[offset + 2*i + 0];
146 Index& e_1 = target_set_out[offset + 2*i + 1];
149 e_0 = ioe + 2*trg_e + tim.map(0);
150 e_1 = ioe + 2*trg_e + tim.map(1);
162 struct StandardTargetRefiner<Shape::Simplex<2>, 0>
164 typedef Shape::Simplex<2> ShapeType;
165 typedef TargetSet TargetSetType;
166 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
167 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
173 const TargetSetHolderType& ,
174 const IndexSetHolderType& ,
175 const IndexSetHolderType& )
187 struct StandardTargetRefiner<Shape::Simplex<2>, 1>
189 typedef Shape::Simplex<2> ShapeType;
190 typedef TargetSet TargetSetType;
191 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
192 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
195 TargetSetType& target_set_out,
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)
202 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
205 const Index ioe = index_offsets[2];
208 typedef IndexSet<3> IndexSetTypeTV;
211 typedef IndexSetTypeTV::IndexTupleType IndexTupleTypeTV;
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>();
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();
223 FEAT_PRAGMA_OMP(parallel
for)
224 for(Index i = 0; i < num_cells; ++i)
227 const Index trg_t = target_set_t[i];
230 const IndexTupleTypeTV& trg_t_v = index_trg_t_v[trg_t];
233 const IndexTupleTypeTV& src_t_v = index_src_t_v[i];
236 TargetIndexMappingType tim(trg_t_v, src_t_v, target_set_v);
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];
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);
258 struct StandardTargetRefiner<Shape::Simplex<2>, 2>
260 typedef Shape::Simplex<2> ShapeType;
261 typedef TargetSet TargetSetType;
262 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
263 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
266 TargetSetType& target_set_out,
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)
273 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
276 const Index iot = index_offsets[2];
279 typedef IndexSet<3> IndexSetTypeTV;
282 typedef IndexSetTypeTV::IndexTupleType IndexTupleTypeTV;
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>();
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();
294 FEAT_PRAGMA_OMP(parallel
for)
295 for(Index i = 0; i < num_cells; ++i)
298 const Index trg_t = target_set_t[i];
301 const IndexTupleTypeTV& trg_t_v = index_trg_t_v[trg_t];
304 const IndexTupleTypeTV& src_t_v = index_src_t_v[i];
307 TargetIndexMappingType tim(trg_t_v, src_t_v, target_set_v);
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];
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;
331 template<
int cell_dim_>
332 struct StandardTargetRefiner<Shape::Simplex<3>, cell_dim_>
334 typedef Shape::Simplex<3> ShapeType;
335 typedef TargetSet TargetSetType;
336 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
337 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
343 const TargetSetHolderType& target_set_holder_in,
344 const IndexSetHolderType& ,
345 const IndexSetHolderType& )
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");
368 struct StandardTargetRefiner<Shape::Simplex<3>,0>
370 typedef Shape::Simplex<3> ShapeType;
371 typedef TargetSet TargetSetType;
372 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
373 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
379 const TargetSetHolderType& ,
380 const IndexSetHolderType& ,
381 const IndexSetHolderType& )
391 template<
int shape_dim_>
392 struct StandardTargetRefiner<Shape::Hypercube<shape_dim_>, 0>
394 typedef Shape::Hypercube<shape_dim_> ShapeType;
395 typedef TargetSet TargetSetType;
396 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
397 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
400 TargetSetType& target_set_out,
402 const Index* index_offsets,
403 const TargetSetHolderType& target_set_holder_in,
404 const IndexSetHolderType& ,
405 const IndexSetHolderType& )
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();
412 FEAT_PRAGMA_OMP(parallel
for)
413 for(Index i = 0; i < num_cells; ++i)
415 target_set_out[offset + i] = index_offsets[shape_dim_] + target_set_in[i];
428 struct StandardTargetRefiner<Shape::Hypercube<1>, 1>
430 typedef Shape::Hypercube<1> ShapeType;
431 typedef TargetSet TargetSetType;
432 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
433 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
436 TargetSetType& target_set_out,
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)
443 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
446 const Index ioe = index_offsets[1];
449 typedef IndexSet<2> IndexSetTypeEV;
452 typedef IndexSetTypeEV::IndexTupleType IndexTupleTypeEV;
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>();
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();
464 FEAT_PRAGMA_OMP(parallel
for)
465 for(Index i = 0; i < num_cells; ++i)
468 const Index trg_e = target_set_e[i];
471 const IndexTupleTypeEV& trg_e_v = index_trg_e_v[trg_e];
474 const IndexTupleTypeEV& src_e_v = index_src_e_v[i];
477 TargetIndexMappingType tim(trg_e_v, src_e_v, target_set_v);
480 Index& e_0 = target_set_out[offset + 2*i + 0];
481 Index& e_1 = target_set_out[offset + 2*i + 1];
484 e_0 = ioe + 2*trg_e + tim.map(0);
485 e_1 = ioe + 2*trg_e + tim.map(1);
499 struct StandardTargetRefiner<Shape::Hypercube<2>, 1>
501 typedef Shape::Hypercube<2> ShapeType;
502 typedef TargetSet TargetSetType;
503 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
504 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
507 TargetSetType& target_set_out,
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)
514 typedef TargetIndexMapping<ShapeType, 1> TargetIndexMappingType;
517 const Index ioe = index_offsets[2];
520 typedef IndexSet<4> IndexSetTypeQV;
523 typedef IndexSetTypeQV::IndexTupleType IndexTupleTypeQV;
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>();
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();
535 FEAT_PRAGMA_OMP(parallel
for)
536 for(Index i = 0; i < num_cells; ++i)
539 const Index trg_q = target_set_q[i];
542 const IndexTupleTypeQV& trg_q_v = index_trg_q_v[trg_q];
545 const IndexTupleTypeQV& src_q_v = index_src_q_v[i];
548 TargetIndexMappingType tim(trg_q_v, src_q_v, target_set_v);
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];
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);
573 struct StandardTargetRefiner<Shape::Hypercube<2>, 2>
575 typedef Shape::Hypercube<2> ShapeType;
576 typedef TargetSet TargetSetType;
577 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
578 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
581 TargetSetType& target_set_out,
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)
588 typedef TargetIndexMapping<ShapeType, 0> TargetIndexMappingType;
591 const Index ioe = index_offsets[2];
594 typedef IndexSet<4> IndexSetTypeQV;
597 typedef IndexSetTypeQV::IndexTupleType IndexTupleTypeQV;
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>();
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();
609 FEAT_PRAGMA_OMP(parallel
for)
610 for(Index i = 0; i < num_cells; ++i)
613 const Index trg_q = target_set_q[i];
616 const IndexTupleTypeQV& trg_q_v = index_trg_q_v[trg_q];
619 const IndexTupleTypeQV& src_q_v = index_src_q_v[i];
622 TargetIndexMappingType tim(trg_q_v, src_q_v, target_set_v);
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];
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);
646 template<
int cell_dim_>
647 struct StandardTargetRefiner<Shape::Hypercube<3>, cell_dim_>
649 typedef Shape::Hypercube<3> ShapeType;
650 typedef TargetSet TargetSetType;
651 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
652 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
658 const TargetSetHolderType& target_set_holder_in,
659 const IndexSetHolderType& ,
660 const IndexSetHolderType& )
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");
683 struct StandardTargetRefiner<Shape::Hypercube<3>,0>
685 typedef Shape::Hypercube<3> ShapeType;
686 typedef TargetSet TargetSetType;
687 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
688 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
694 const TargetSetHolderType& ,
695 const IndexSetHolderType& ,
696 const IndexSetHolderType& )
711 int shape_dim_ = Shape_::dimension>
712 class TargetRefineShapeWrapper
715 typedef Shape_ ShapeType;
716 typedef TargetSet TargetSetType;
717 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
718 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
722 return "TargetRefineShapeWrapper<" + Shape_::name() +
"," +
stringify(cell_dim_)
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)
734 typedef typename Shape::FaceTraits<ShapeType, shape_dim_ - 1>::ShapeType FacetType;
735 Index offset = TargetRefineShapeWrapper<FacetType, cell_dim_>::refine(
738 target_set_holder_in,
739 index_set_holder_src,
740 index_set_holder_trg);
743 StandardTargetRefiner<ShapeType, cell_dim_>::refine(
747 target_set_holder_in,
748 index_set_holder_src,
749 index_set_holder_trg);
752 return offset + Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count *
753 target_set_holder_in.get_num_entities(shape_dim_);
760 class TargetRefineShapeWrapper<Shape_, cell_dim_, cell_dim_>
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;
771 return "TargetRefineShapeWrapper<" + Shape_::name() +
"," +
stringify(cell_dim_)
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)
783 StandardTargetRefiner<ShapeType, cell_dim_>::refine(
787 target_set_holder_in,
788 index_set_holder_src,
789 index_set_holder_trg);
792 return Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count
793 * target_set_holder_in.get_num_entities(cell_dim_);
797 template<
int cell_dim_>
798 class TargetRefineShapeWrapper<Shape::Vertex, cell_dim_, cell_dim_>
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;
809 return "TargetRefineShapeWrapper<Vertex," +
stringify(cell_dim_) +
"," +
stringify(cell_dim_) +
">";
813 TargetSetType& target_set_out,
814 const Index index_offsets[],
815 const TargetSetHolderType& target_set_holder_in,
816 const IndexSetHolderType& ,
817 const IndexSetHolderType& )
820 StandardTargetRefiner<ShapeType, cell_dim_>
821 ::refine(target_set_out, 0, index_offsets, target_set_holder_in);
824 return Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count
825 * target_set_holder_in.get_num_entities(cell_dim_);
833 int cell_dim_ = Shape_::dimension>
834 class TargetRefineWrapper
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;
846 return "TargetRefineWrapper<" + Shape_::name() +
"," +
stringify(cell_dim_) +
">";
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)
857 TargetRefineWrapper<ShapeType, cell_dim_ - 1>::refine(
858 target_set_holder_out,
860 target_set_holder_in,
861 index_set_holder_src,
862 index_set_holder_trg);
865 Index index_offsets[Shape_::dimension+1];
866 Intern::EntityCounter<Intern::StandardRefinementTraits, ShapeType, cell_dim_>
867 ::offset(index_offsets, num_entities_trg);
870 TargetRefineShapeWrapper<ShapeType, cell_dim_>::refine(
871 target_set_holder_out.template get_target_set<cell_dim_>(),
873 target_set_holder_in,
874 index_set_holder_src,
875 index_set_holder_trg);
879 template<
typename Shape_>
880 class TargetRefineWrapper<Shape_, 0>
883 typedef Shape_ ShapeType;
884 typedef TargetSet TargetSetType;
885 typedef TargetSetHolder<Shape::Vertex> TargetSetHolderTypeOut;
886 typedef TargetSetHolder<ShapeType> TargetSetHolderTypeIn;
887 typedef IndexSetHolder<ShapeType> IndexSetHolderType;
891 return "TargetRefineWrapper<" + Shape_::name() +
",0>";
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)
902 Index index_offsets[Shape_::dimension+1];
903 Intern::EntityCounter<Intern::StandardRefinementTraits, ShapeType, 0>::offset(index_offsets, num_entities_trg);
906 TargetRefineShapeWrapper<ShapeType, 0>::refine(
907 target_set_holder_out.template get_target_set<0>(),
909 target_set_holder_in,
910 index_set_holder_src,
911 index_set_holder_trg);
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.