FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
simple_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/target_set.hpp>
10#include <kernel/geometry/intern/entity_counter.hpp>
11#include <kernel/geometry/intern/standard_refinement_traits.hpp>
12
13namespace FEAT
14{
15 namespace Geometry
16 {
18 namespace Intern
19 {
20 template<
21 typename Shape_,
22 int cell_dim_>
23 struct SimpleTargetRefiner
24 {
25 typedef Shape_ ShapeType;
26 typedef TargetSet TargetSetType;
27
28 static Index refine(
29 TargetSetType& target_set_out,
30 const Index offset,
31 const Index index_offsets[],
32 const TargetSetType& target_set_in)
33 {
34 // fetch number of cells
35 Index num_cells = target_set_in.get_num_entities();
36 static constexpr int shape_dim = ShapeType::dimension;
37 static constexpr int num_children = StandardRefinementTraits<ShapeType,cell_dim_>::count;
38
39 FEAT_PRAGMA_OMP(parallel for)
40 for(Index i = 0; i < num_cells; ++i)
41 {
42 for(int j(0); j < num_children; ++j)
43 {
44 target_set_out[offset + i*Index(num_children) + Index(j)] =
45 index_offsets[shape_dim] + target_set_in[i]*Index(num_children) + Index(j);
46 }
47 }
48
49 return num_cells*Index(num_children);
50 }
51 };
52
53 template<
54 typename Shape_,
55 int cell_dim_,
56 int shape_dim_ = Shape_::dimension>
57 struct SimpleTargetRefineShapeWrapper
58 {
59 typedef Shape_ ShapeType;
60 typedef TargetSet TargetSetType;
61 typedef TargetSetHolder<ShapeType> TargetSetHolderType;
62
63 static Index refine(
64 TargetSetType& target_set_out,
65 const Index index_offsets[],
66 const TargetSetHolderType& target_set_holder_in)
67 {
68 // recursive call of SubSetRefineShapeWrapper
69 typedef typename Shape::FaceTraits<ShapeType, shape_dim_ - 1>::ShapeType FacetType;
70 Index offset = SimpleTargetRefineShapeWrapper<FacetType, cell_dim_>::refine(
71 target_set_out,
72 index_offsets,
73 target_set_holder_in);
74
75 // get input target set
76 const TargetSetType& target_set_in = target_set_holder_in.template get_target_set<shape_dim_>();
77
78 // call subset refiner
79 SimpleTargetRefiner<ShapeType, cell_dim_>::refine(
80 target_set_out,
81 offset,
82 index_offsets,
83 target_set_in);
84
85 // return new offset
86 return offset + Intern::StandardRefinementTraits<ShapeType, cell_dim_>::count *
87 target_set_holder_in.get_num_entities(shape_dim_);
88 }
89 };
90
91 template<
92 typename Shape_,
93 int cell_dim_>
94 struct SimpleTargetRefineShapeWrapper<Shape_, cell_dim_, cell_dim_>
95 {
96 typedef Shape_ ShapeType;
97 typedef TargetSet TargetSetType;
98 typedef typename Shape::FaceTraits<Shape_, cell_dim_>::ShapeType CellType;
99 typedef TargetSetHolder<CellType> TargetSetHolderType;
100
101 static Index refine(
102 TargetSetType& target_set_out,
103 const Index index_offsets[],
104 const TargetSetHolderType& target_set_holder_in)
105 {
106 // get input target set
107 const TargetSetType& target_set_in = target_set_holder_in.template get_target_set<cell_dim_>();
108
109 // call subset refiner
110 SimpleTargetRefiner<ShapeType, cell_dim_>::refine(
111 target_set_out,
112 0,
113 index_offsets,
114 target_set_in);
115
116 // return new offset
117 return StandardRefinementTraits<ShapeType, cell_dim_>::count *
118 target_set_holder_in.get_num_entities(cell_dim_);
119 }
120 };
121
122 template<
123 typename Shape_,
124 int cell_dim_ = Shape_::dimension>
125 struct SimpleTargetRefineWrapper
126 {
127 typedef Shape_ ShapeType;
128 typedef TargetSet TargetSetType;
129 typedef typename Shape::FaceTraits<Shape_, cell_dim_>::ShapeType CellType;
130 typedef TargetSetHolder<CellType> TargetSetHolderTypeOut;
131 typedef TargetSetHolder<ShapeType> TargetSetHolderTypeIn;
132
133 static void refine(
134 TargetSetHolderTypeOut& target_set_holder_out,
135 const Index num_entities_trg[],
136 const TargetSetHolderTypeIn& target_set_holder_in)
137 {
138 // recursive call of SubSetRefineWrapper
139 SimpleTargetRefineWrapper<ShapeType, cell_dim_ - 1>::refine(
140 target_set_holder_out,
141 num_entities_trg,
142 target_set_holder_in);
143
144 // calculate index offsets
145 Index index_offsets[Shape_::dimension + 1];
146 EntityCounter<StandardRefinementTraits, ShapeType, cell_dim_>::offset(index_offsets, num_entities_trg);
147
148 // get output target set
149 TargetSet& target_set_out = target_set_holder_out.template get_target_set<cell_dim_>();
150
151 // call shape wrapper
152 SimpleTargetRefineShapeWrapper<ShapeType, cell_dim_>::refine(
153 target_set_out,
154 index_offsets,
155 target_set_holder_in);
156 }
157 };
158
159 template<typename Shape_>
160 struct SimpleTargetRefineWrapper<Shape_, 0>
161 {
162 typedef Shape_ ShapeType;
163 typedef TargetSet TargetSetType;
164 typedef typename Shape::FaceTraits<Shape_, 0>::ShapeType CellType;
165 typedef TargetSetHolder<CellType> TargetSetHolderTypeOut;
166 typedef TargetSetHolder<ShapeType> TargetSetHolderTypeIn;
167
168 static void refine(
169 TargetSetHolderTypeOut& target_set_holder_out,
170 const Index num_entities_trg[],
171 const TargetSetHolderTypeIn& target_set_holder_in)
172 {
173 // calculate index offsets
174 Index index_offsets[Shape_::dimension + 1];
175 EntityCounter<StandardRefinementTraits, ShapeType, 0>::offset(index_offsets, num_entities_trg);
176
177 // get output target set
178 TargetSet& target_set_out = target_set_holder_out.template get_target_set<0>();
179
180 // call shape wrapper
181 SimpleTargetRefineShapeWrapper<ShapeType, 0>::refine(
182 target_set_out,
183 index_offsets,
184 target_set_holder_in);
185 }
186 };
187 } // namespace Intern
189 } // namespace Geometry
190} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.