TTK
Loading...
Searching...
No Matches
PeriodicPreconditions.cpp
Go to the documentation of this file.
2
4 vertexCoords_.resize(vertexNumber_);
5
6 if(dimensionality_ == 1) {
7#ifdef TTK_ENABLE_OPENMP
8#pragma omp parallel for num_threads(threadNumber_)
9#endif // TTK_ENABLE_OPENMP
10 for(SimplexId i = 0; i < vertexNumber_; ++i) {
11 vertexCoords_[i][0] = i;
12 }
13 } else if(dimensionality_ == 2) {
14#ifdef TTK_ENABLE_OPENMP
15#pragma omp parallel for num_threads(threadNumber_)
16#endif // TTK_ENABLE_OPENMP
17 for(SimplexId i = 0; i < vertexNumber_; ++i) {
18 auto &p = vertexCoords_[i];
19 vertexToPosition2d(i, p.data());
20 }
21 } else if(dimensionality_ == 3) {
22#ifdef TTK_ENABLE_OPENMP
23#pragma omp parallel for num_threads(threadNumber_)
24#endif // TTK_ENABLE_OPENMP
25 for(SimplexId i = 0; i < vertexNumber_; ++i) {
26 auto &p = vertexCoords_[i];
27 vertexToPosition(i, p.data());
28 }
29 }
30
31 return 0;
32}
33
35 edgePositions_.resize(edgeNumber_);
36 edgeCoords_.resize(edgeNumber_);
37
38 if(dimensionality_ == 3) {
39#ifdef TTK_ENABLE_OPENMP
40#pragma omp parallel for num_threads(threadNumber_)
41#endif // TTK_ENABLE_OPENMP
42 for(SimplexId i = 0; i < edgeNumber_; ++i) {
43 auto &p = edgeCoords_[i];
44 if(i < esetshift_[0]) {
45 edgeToPosition(i, 0, p.data());
46 edgePositions_[i] = EdgePosition::L_3D;
47 } else if(i < esetshift_[1]) {
48 edgeToPosition(i, 1, p.data());
49 edgePositions_[i] = EdgePosition::H_3D;
50 } else if(i < esetshift_[2]) {
51 edgeToPosition(i, 2, p.data());
52 edgePositions_[i] = EdgePosition::P_3D;
53 } else if(i < esetshift_[3]) {
54 edgeToPosition(i, 3, p.data());
55 edgePositions_[i] = EdgePosition::D1_3D;
56 } else if(i < esetshift_[4]) {
57 edgeToPosition(i, 4, p.data());
58 edgePositions_[i] = EdgePosition::D2_3D;
59 } else if(i < esetshift_[5]) {
60 edgeToPosition(i, 5, p.data());
61 edgePositions_[i] = EdgePosition::D3_3D;
62 } else if(i < esetshift_[6]) {
63 edgeToPosition(i, 6, p.data());
64 edgePositions_[i] = EdgePosition::D4_3D;
65 }
66 }
67
68 } else if(this->dimensionality_ == 2) {
69#ifdef TTK_ENABLE_OPENMP
70#pragma omp parallel for num_threads(threadNumber_)
71#endif // TTK_ENABLE_OPENMP
72 for(SimplexId i = 0; i < edgeNumber_; ++i) {
73 auto &p = edgeCoords_[i];
74 if(i < esetshift_[0]) {
75 edgeToPosition2d(i, 0, p.data());
76 edgePositions_[i] = EdgePosition::L_2D;
77 } else if(i < esetshift_[1]) {
78 edgeToPosition2d(i, 1, p.data());
79 edgePositions_[i] = EdgePosition::H_2D;
80 } else if(i < esetshift_[2]) {
81 edgeToPosition2d(i, 2, p.data());
82 edgePositions_[i] = EdgePosition::D1_2D;
83 }
84 }
85 }
86
87 else if(this->dimensionality_ == 1) {
88 edgePositions_[0] = EdgePosition::FIRST_EDGE_1D;
89#ifdef TTK_ENABLE_OPENMP
90#pragma omp parallel for num_threads(threadNumber_)
91#endif // TTK_ENABLE_OPENMP
92 for(SimplexId i = 1; i < edgeNumber_ - 1; ++i) {
93 edgePositions_[i] = EdgePosition::CENTER_1D;
94 }
95 edgePositions_[edgeNumber_ - 1] = EdgePosition::LAST_EDGE_1D;
96 }
97
98 edgeVertexAccelerated_.resize(edgeNumber_);
99
100 if(isAccelerated_) {
101#ifdef TTK_ENABLE_OPENMP
102#pragma omp parallel for num_threads(threadNumber_)
103#endif // TTK_ENABLE_OPENMP
104 for(SimplexId i = 0; i < edgeNumber_; ++i) {
105 const auto &p = edgeCoords_[i];
106 edgeVertexAccelerated_[i] = (p[1] << div_[0]) + (p[2] << div_[1]);
107 }
108 } else {
109#ifdef TTK_ENABLE_OPENMP
110#pragma omp parallel for num_threads(threadNumber_)
111#endif // TTK_ENABLE_OPENMP
112 for(SimplexId i = 0; i < edgeNumber_; ++i) {
113 const auto &p = edgeCoords_[i];
114 edgeVertexAccelerated_[i] = p[1] * vshift_[0] + p[2] * vshift_[1];
115 }
116 }
117
118 return 0;
119}
120
122 if(this->dimensionality_ != 3 && this->dimensionality_ != 2) {
123 return 1;
124 }
125
126 trianglePositions_.resize(triangleNumber_);
127 triangleCoords_.resize(triangleNumber_);
128
129 if(dimensionality_ == 3) {
130#ifdef TTK_ENABLE_OPENMP
131#pragma omp parallel for num_threads(threadNumber_)
132#endif // TTK_ENABLE_OPENMP
133 for(SimplexId i = 0; i < triangleNumber_; ++i) {
134 if(i < tsetshift_[0]) {
135 triangleToPosition(i, 0, triangleCoords_[i].data());
136 trianglePositions_[i] = TrianglePosition::F_3D;
137 } else if(i < tsetshift_[1]) {
138 triangleToPosition(i, 1, triangleCoords_[i].data());
139 trianglePositions_[i] = TrianglePosition::H_3D;
140 } else if(i < tsetshift_[2]) {
141 triangleToPosition(i, 2, triangleCoords_[i].data());
142 trianglePositions_[i] = TrianglePosition::C_3D;
143 } else if(i < tsetshift_[3]) {
144 triangleToPosition(i, 3, triangleCoords_[i].data());
145 trianglePositions_[i] = TrianglePosition::D1_3D;
146 } else if(i < tsetshift_[4]) {
147 triangleToPosition(i, 4, triangleCoords_[i].data());
148 trianglePositions_[i] = TrianglePosition::D2_3D;
149 } else if(i < tsetshift_[5]) {
150 triangleToPosition(i, 5, triangleCoords_[i].data());
151 trianglePositions_[i] = TrianglePosition::D3_3D;
152 }
153 }
154
155 } else if(dimensionality_ == 2) {
156#ifdef TTK_ENABLE_OPENMP
157#pragma omp parallel for num_threads(threadNumber_)
158#endif // TTK_ENABLE_OPENMP
159 for(SimplexId i = 0; i < triangleNumber_; ++i) {
160 triangleToPosition2d(i, triangleCoords_[i].data());
161 if(i % 2 == 0) {
162 trianglePositions_[i] = TrianglePosition::TOP_2D;
163 } else {
164 trianglePositions_[i] = TrianglePosition::BOTTOM_2D;
165 }
166 }
167 }
168
169 return 0;
170}
171
173
174 if(this->dimensionality_ != 3) {
175 return 1;
176 }
177 tetrahedronCoords_.resize(this->tetrahedronNumber_);
178
179#ifdef TTK_ENABLE_OPENMP
180#pragma omp parallel for num_threads(this->threadNumber_)
181#endif // TTK_ENABLE_OPENMP
182 for(SimplexId i = 0; i < this->tetrahedronNumber_; ++i) {
183 this->tetrahedronToPosition(i, tetrahedronCoords_[i].data());
184 }
185 return 0;
186}
187
190
191 std::array<SimplexId, 3> p{};
192 if(this->dimensionality_ == 3) {
193 if(e < esetshift_[0]) {
194 edgeToPosition(e, 0, p.data());
195 return EdgePosition::L_3D;
196 } else if(e < esetshift_[1]) {
197 edgeToPosition(e, 1, p.data());
198 return EdgePosition::H_3D;
199 } else if(e < esetshift_[2]) {
200 edgeToPosition(e, 2, p.data());
201 return EdgePosition::P_3D;
202 } else if(e < esetshift_[3]) {
203 edgeToPosition(e, 3, p.data());
204 return EdgePosition::D1_3D;
205 } else if(e < esetshift_[4]) {
206 edgeToPosition(e, 4, p.data());
207 return EdgePosition::D2_3D;
208 } else if(e < esetshift_[5]) {
209 edgeToPosition(e, 5, p.data());
210 return EdgePosition::D3_3D;
211 } else if(e < esetshift_[6]) {
212 edgeToPosition(e, 6, p.data());
213 return EdgePosition::D4_3D;
214 }
215 } else if(this->dimensionality_ == 2) {
216 if(e < esetshift_[0]) {
217 edgeToPosition2d(e, 0, p.data());
218 return EdgePosition::L_2D;
219 } else if(e < esetshift_[1]) {
220 edgeToPosition2d(e, 1, p.data());
221 return EdgePosition::H_2D;
222 } else if(e < esetshift_[2]) {
223 edgeToPosition2d(e, 2, p.data());
224 return EdgePosition::D1_2D;
225 }
226 } else if(this->dimensionality_ == 1) {
227 if(e == 0) {
228 return EdgePosition::FIRST_EDGE_1D;
229 } else if(e == this->edgeNumber_ - 1)
230 return EdgePosition::CENTER_1D;
231 } else {
232 return EdgePosition::LAST_EDGE_1D;
233 }
234
235 return EdgePosition::CENTER_1D;
236}
237
238std::array<ttk::SimplexId, 3>
240 std::array<SimplexId, 3> p{};
241 if(this->dimensionality_ == 3) {
242 if(e < this->esetshift_[0]) {
243 this->edgeToPosition(e, 0, p.data());
244 } else if(e < this->esetshift_[1]) {
245 this->edgeToPosition(e, 1, p.data());
246 } else if(e < this->esetshift_[2]) {
247 this->edgeToPosition(e, 2, p.data());
248 } else if(e < this->esetshift_[3]) {
249 this->edgeToPosition(e, 3, p.data());
250 } else if(e < this->esetshift_[4]) {
251 this->edgeToPosition(e, 4, p.data());
252 } else if(e < this->esetshift_[5]) {
253 this->edgeToPosition(e, 5, p.data());
254 } else if(e < this->esetshift_[6]) {
255 this->edgeToPosition(e, 6, p.data());
256 }
257
258 } else if(this->dimensionality_ == 2) {
259 if(e < this->esetshift_[0]) {
260 this->edgeToPosition2d(e, 0, p.data());
261 } else if(e < this->esetshift_[1]) {
262 this->edgeToPosition2d(e, 1, p.data());
263 } else if(e < this->esetshift_[2]) {
264 this->edgeToPosition2d(e, 2, p.data());
265 }
266 }
267 return p;
268}
269
272 if(this->dimensionality_ == 2) {
273 if(t % 2 == 0) {
274 return TrianglePosition::TOP_2D;
275 } else {
276 return TrianglePosition::BOTTOM_2D;
277 }
278 } else if(this->dimensionality_ == 3) {
279 if(t < this->tsetshift_[0]) {
280 return TrianglePosition::F_3D;
281 } else if(t < this->tsetshift_[1]) {
282 return TrianglePosition::H_3D;
283 } else if(t < this->tsetshift_[2]) {
284 return TrianglePosition::C_3D;
285 } else if(t < this->tsetshift_[3]) {
286 return TrianglePosition::D1_3D;
287 } else if(t < this->tsetshift_[4]) {
288 return TrianglePosition::D2_3D;
289 } else if(t < this->tsetshift_[5]) {
290 return TrianglePosition::D3_3D;
291 }
292 }
293 return TrianglePosition::C_3D;
294}
295
296std::array<ttk::SimplexId, 3>
298 std::array<SimplexId, 3> p{};
299 if(this->dimensionality_ == 2) {
300 this->triangleToPosition2d(t, p.data());
301 } else if(this->dimensionality_ == 3) {
302 if(t < this->tsetshift_[0]) {
303 this->triangleToPosition(t, 0, p.data());
304 } else if(t < this->tsetshift_[1]) {
305 this->triangleToPosition(t, 1, p.data());
306 } else if(t < this->tsetshift_[2]) {
307 this->triangleToPosition(t, 2, p.data());
308 } else if(t < this->tsetshift_[3]) {
309 this->triangleToPosition(t, 3, p.data());
310 } else if(t < this->tsetshift_[4]) {
311 this->triangleToPosition(t, 4, p.data());
312 } else if(t < this->tsetshift_[5]) {
313 this->triangleToPosition(t, 5, p.data());
314 }
315 }
316 return p;
317}
EdgePosition getEdgePosition(const SimplexId e) const
std::array< SimplexId, 3 > getEdgeCoords(const SimplexId e) const
TrianglePosition getTrianglePosition(const SimplexId t) const
std::array< SimplexId, 3 > getTriangleCoords(const SimplexId t) const
virtual void vertexToPosition(const SimplexId vertex, SimplexId p[3]) const =0
virtual void vertexToPosition2d(const SimplexId vertex, SimplexId p[2]) const =0
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22