TTK
Loading...
Searching...
No Matches
ImplicitPreconditions.cpp
Go to the documentation of this file.
2
4
5 vertexPositions_.resize(this->vertexNumber_);
6 vertexCoords_.resize(this->vertexNumber_);
7
8 if(this->dimensionality_ == 1) {
9 vertexPositions_[0] = VertexPosition::LEFT_CORNER_1D;
10#ifdef TTK_ENABLE_OPENMP
11#pragma omp parallel for num_threads(this->threadNumber_)
12#endif // TTK_ENABLE_OPENMP
13 for(SimplexId i = 1; i < this->vertexNumber_ - 1; ++i) {
14 vertexPositions_[i] = VertexPosition::CENTER_1D;
15 }
16 vertexPositions_[this->vertexNumber_ - 1] = VertexPosition::RIGHT_CORNER_1D;
17
18 } else if(this->dimensionality_ == 2) {
19#ifdef TTK_ENABLE_OPENMP
20#pragma omp parallel for num_threads(this->threadNumber_)
21#endif // TTK_ENABLE_OPENMP
22 for(SimplexId i = 0; i < this->vertexNumber_; ++i) {
23 auto &p = vertexCoords_[i];
24 this->vertexToPosition2d(i, p.data());
25
26 if(0 < p[0] and p[0] < this->nbvoxels_[this->Di_]) {
27 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
28 vertexPositions_[i] = VertexPosition::CENTER_2D;
29 else if(p[1] == 0)
30 vertexPositions_[i] = VertexPosition::TOP_EDGE_2D; // ab
31 else
32 vertexPositions_[i] = VertexPosition::BOTTOM_EDGE_2D; // cd
33 } else if(p[0] == 0) {
34 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
35 vertexPositions_[i] = VertexPosition::LEFT_EDGE_2D; // ac
36 else if(p[1] == 0)
37 vertexPositions_[i] = VertexPosition::TOP_LEFT_CORNER_2D; // a
38 else
39 vertexPositions_[i] = VertexPosition::BOTTOM_LEFT_CORNER_2D; // c
40 } else {
41 if(0 < p[1] and p[1] < this->nbvoxels_[this->Dj_])
42 vertexPositions_[i] = VertexPosition::RIGHT_EDGE_2D; // bd
43 else if(p[1] == 0)
44 vertexPositions_[i] = VertexPosition::TOP_RIGHT_CORNER_2D; // b
45 else
46 vertexPositions_[i] = VertexPosition::BOTTOM_RIGHT_CORNER_2D; // d
47 }
48 }
49
50 } else if(this->dimensionality_ == 3) {
51#ifdef TTK_ENABLE_OPENMP
52#pragma omp parallel for num_threads(this->threadNumber_)
53#endif // TTK_ENABLE_OPENMP
54 for(SimplexId i = 0; i < this->vertexNumber_; ++i) {
55 auto &p = vertexCoords_[i];
56 this->vertexToPosition(i, p.data());
57
58 if(0 < p[0] and p[0] < this->nbvoxels_[0]) {
59 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
60 if(0 < p[2] and p[2] < this->nbvoxels_[2])
61 vertexPositions_[i] = VertexPosition::CENTER_3D;
62 else if(p[2] == 0)
63 vertexPositions_[i] = VertexPosition::FRONT_FACE_3D; // abcd
64 else
65 vertexPositions_[i] = VertexPosition::BACK_FACE_3D; // efgh
66 } else if(p[1] == 0) {
67 if(0 < p[2] and p[2] < this->nbvoxels_[2])
68 vertexPositions_[i] = VertexPosition::TOP_FACE_3D; // abef
69 else if(p[2] == 0)
70 vertexPositions_[i] = VertexPosition::TOP_FRONT_EDGE_3D; // ab
71 else
72 vertexPositions_[i] = VertexPosition::TOP_BACK_EDGE_3D; // ef
73 } else {
74 if(0 < p[2] and p[2] < this->nbvoxels_[2])
75 vertexPositions_[i] = VertexPosition::BOTTOM_FACE_3D; // cdgh
76 else if(p[2] == 0)
77 vertexPositions_[i] = VertexPosition::BOTTOM_FRONT_EDGE_3D; // cd
78 else
79 vertexPositions_[i] = VertexPosition::BOTTOM_BACK_EDGE_3D; // gh
80 }
81 } else if(p[0] == 0) {
82 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
83 if(0 < p[2] and p[2] < this->nbvoxels_[2])
84 vertexPositions_[i] = VertexPosition::LEFT_FACE_3D; // aceg
85 else if(p[2] == 0)
86 vertexPositions_[i] = VertexPosition::LEFT_FRONT_EDGE_3D; // ac
87 else
88 vertexPositions_[i] = VertexPosition::LEFT_BACK_EDGE_3D; // eg
89 } else if(p[1] == 0) {
90 if(0 < p[2] and p[2] < this->nbvoxels_[2])
91 vertexPositions_[i] = VertexPosition::TOP_LEFT_EDGE_3D; // ae
92 else if(p[2] == 0)
93 vertexPositions_[i] = VertexPosition::TOP_LEFT_FRONT_CORNER_3D; // a
94 else
95 vertexPositions_[i] = VertexPosition::TOP_LEFT_BACK_CORNER_3D; // e
96 } else {
97 if(0 < p[2] and p[2] < this->nbvoxels_[2])
98 vertexPositions_[i] = VertexPosition::BOTTOM_LEFT_EDGE_3D; // cg
99 else if(p[2] == 0)
100 vertexPositions_[i]
102 else
103 vertexPositions_[i]
105 }
106 } else {
107 if(0 < p[1] and p[1] < this->nbvoxels_[1]) {
108 if(0 < p[2] and p[2] < this->nbvoxels_[2])
109 vertexPositions_[i] = VertexPosition::RIGHT_FACE_3D; // bdfh
110 else if(p[2] == 0)
111 vertexPositions_[i] = VertexPosition::RIGHT_FRONT_EDGE_3D; // bd
112 else
113 vertexPositions_[i] = VertexPosition::RIGHT_BACK_EDGE_3D; // fh
114 } else if(p[1] == 0) {
115 if(0 < p[2] and p[2] < this->nbvoxels_[2])
116 vertexPositions_[i] = VertexPosition::TOP_RIGHT_EDGE_3D; // bf
117 else if(p[2] == 0)
118 vertexPositions_[i]
120 else
121 vertexPositions_[i] = VertexPosition::TOP_RIGHT_BACK_CORNER_3D; // f
122 } else {
123 if(0 < p[2] and p[2] < this->nbvoxels_[2])
124 vertexPositions_[i] = VertexPosition::BOTTOM_RIGHT_EDGE_3D; // dh
125 else if(p[2] == 0)
126 vertexPositions_[i]
128 else
129 vertexPositions_[i]
131 }
132 }
133 }
134 }
135
136 return 0;
137}
138
140 edgePositions_.resize(this->edgeNumber_);
141 edgeCoords_.resize(this->edgeNumber_);
142
143 if(this->dimensionality_ == 3) {
144#ifdef TTK_ENABLE_OPENMP
145#pragma omp parallel for num_threads(this->threadNumber_)
146#endif // TTK_ENABLE_OPENMP
147 for(SimplexId i = 0; i < this->edgeNumber_; ++i) {
148 auto &p = edgeCoords_[i];
149
150 if(i < this->esetshift_[0]) {
151 this->edgeToPosition(i, 0, p.data());
152 if(p[1] > 0 and p[1] < this->nbvoxels_[1]) {
153 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
154 edgePositions_[i] = EdgePosition::L_xnn_3D;
155 else if(p[2] == 0)
156 edgePositions_[i] = EdgePosition::L_xn0_3D;
157 else
158 edgePositions_[i] = EdgePosition::L_xnN_3D;
159 } else if(p[1] == 0) {
160 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
161 edgePositions_[i] = EdgePosition::L_x0n_3D;
162 else if(p[2] == 0)
163 edgePositions_[i] = EdgePosition::L_x00_3D;
164 else
165 edgePositions_[i] = EdgePosition::L_x0N_3D;
166 } else {
167 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
168 edgePositions_[i] = EdgePosition::L_xNn_3D;
169 else if(p[2] == 0)
170 edgePositions_[i] = EdgePosition::L_xN0_3D;
171 else
172 edgePositions_[i] = EdgePosition::L_xNN_3D;
173 }
174
175 } else if(i < this->esetshift_[1]) {
176 this->edgeToPosition(i, 1, p.data());
177 if(p[0] > 0 and p[0] < this->nbvoxels_[0]) {
178 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
179 edgePositions_[i] = EdgePosition::H_nyn_3D;
180 else if(p[2] == 0)
181 edgePositions_[i] = EdgePosition::H_ny0_3D;
182 else
183 edgePositions_[i] = EdgePosition::H_nyN_3D;
184 } else if(p[0] == 0) {
185 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
186 edgePositions_[i] = EdgePosition::H_0yn_3D;
187 else if(p[2] == 0)
188 edgePositions_[i] = EdgePosition::H_0y0_3D;
189 else
190 edgePositions_[i] = EdgePosition::H_0yN_3D;
191 } else {
192 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
193 edgePositions_[i] = EdgePosition::H_Nyn_3D;
194 else if(p[2] == 0)
195 edgePositions_[i] = EdgePosition::H_Ny0_3D;
196 else
197 edgePositions_[i] = EdgePosition::H_NyN_3D;
198 }
199
200 } else if(i < this->esetshift_[2]) {
201 this->edgeToPosition(i, 2, p.data());
202 if(p[0] > 0 and p[0] < this->nbvoxels_[0]) {
203 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
204 edgePositions_[i] = EdgePosition::P_nnz_3D;
205 else if(p[1] == 0)
206 edgePositions_[i] = EdgePosition::P_n0z_3D;
207 else
208 edgePositions_[i] = EdgePosition::P_nNz_3D;
209 } else if(p[0] == 0) {
210 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
211 edgePositions_[i] = EdgePosition::P_0nz_3D;
212 else if(p[1] == 0)
213 edgePositions_[i] = EdgePosition::P_00z_3D;
214 else
215 edgePositions_[i] = EdgePosition::P_0Nz_3D;
216 } else {
217 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
218 edgePositions_[i] = EdgePosition::P_Nnz_3D;
219 else if(p[1] == 0)
220 edgePositions_[i] = EdgePosition::P_N0z_3D;
221 else
222 edgePositions_[i] = EdgePosition::P_NNz_3D;
223 }
224
225 } else if(i < this->esetshift_[3]) {
226 this->edgeToPosition(i, 3, p.data());
227 if(p[2] > 0 and p[2] < this->nbvoxels_[2])
228 edgePositions_[i] = EdgePosition::D1_xyn_3D;
229 else if(p[2] == 0)
230 edgePositions_[i] = EdgePosition::D1_xy0_3D;
231 else
232 edgePositions_[i] = EdgePosition::D1_xyN_3D;
233
234 } else if(i < this->esetshift_[4]) {
235 this->edgeToPosition(i, 4, p.data());
236 if(p[0] > 0 and p[0] < this->nbvoxels_[0])
237 edgePositions_[i] = EdgePosition::D2_nyz_3D;
238 else if(p[0] == 0)
239 edgePositions_[i] = EdgePosition::D2_0yz_3D;
240 else
241 edgePositions_[i] = EdgePosition::D2_Nyz_3D;
242
243 } else if(i < this->esetshift_[5]) {
244 this->edgeToPosition(i, 5, p.data());
245 if(p[1] > 0 and p[1] < this->nbvoxels_[1])
246 edgePositions_[i] = EdgePosition::D3_xnz_3D;
247 else if(p[1] == 0)
248 edgePositions_[i] = EdgePosition::D3_x0z_3D;
249 else
250 edgePositions_[i] = EdgePosition::D3_xNz_3D;
251
252 } else if(i < this->esetshift_[6]) {
253 this->edgeToPosition(i, 6, p.data());
254 edgePositions_[i] = EdgePosition::D4_3D;
255 }
256 }
257
258 } else if(this->dimensionality_ == 2) {
259#ifdef TTK_ENABLE_OPENMP
260#pragma omp parallel for num_threads(this->threadNumber_)
261#endif // TTK_ENABLE_OPENMP
262 for(SimplexId i = 0; i < this->edgeNumber_; ++i) {
263 auto &p = edgeCoords_[i];
264
265 if(i < this->esetshift_[0]) {
266 this->edgeToPosition2d(i, 0, p.data());
267 if(p[1] > 0 and p[1] < this->nbvoxels_[this->Dj_])
268 edgePositions_[i] = EdgePosition::L_xn_2D;
269 else if(p[1] == 0)
270 edgePositions_[i] = EdgePosition::L_x0_2D;
271 else
272 edgePositions_[i] = EdgePosition::L_xN_2D;
273
274 } else if(i < this->esetshift_[1]) {
275 this->edgeToPosition2d(i, 1, p.data());
276 if(p[0] > 0 and p[0] < this->nbvoxels_[this->Di_])
277 edgePositions_[i] = EdgePosition::H_ny_2D;
278 else if(p[0] == 0)
279 edgePositions_[i] = EdgePosition::H_0y_2D;
280 else
281 edgePositions_[i] = EdgePosition::H_Ny_2D;
282
283 } else if(i < this->esetshift_[2]) {
284 this->edgeToPosition2d(i, 2, p.data());
285 edgePositions_[i] = EdgePosition::D1_2D;
286 }
287 }
288
289 } else if(this->dimensionality_ == 1) {
290 edgePositions_[0] = EdgePosition::FIRST_EDGE_1D;
291#ifdef TTK_ENABLE_OPENMP
292#pragma omp parallel for num_threads(this->threadNumber_)
293#endif // TTK_ENABLE_OPENMP
294 for(SimplexId i = 1; i < this->edgeNumber_ - 1; ++i) {
295 edgePositions_[i] = EdgePosition::CENTER_1D;
296 }
297 edgePositions_[this->edgeNumber_ - 1] = EdgePosition::LAST_EDGE_1D;
298 }
299
300 return 0;
301}
302
304
305 trianglePositions_.resize(this->triangleNumber_);
306 triangleCoords_.resize(this->triangleNumber_);
307 if(this->dimensionality_ == 3) {
308#ifdef TTK_ENABLE_OPENMP
309#pragma omp parallel for num_threads(this->threadNumber_)
310#endif // TTK_ENABLE_OPENMP
311 for(SimplexId i = 0; i < this->triangleNumber_; ++i) {
312 if(i < this->tsetshift_[0]) {
313 this->triangleToPosition(i, 0, triangleCoords_[i].data());
314 trianglePositions_[i] = TrianglePosition::F_3D;
315 } else if(i < this->tsetshift_[1]) {
316 this->triangleToPosition(i, 1, triangleCoords_[i].data());
317 trianglePositions_[i] = TrianglePosition::H_3D;
318 } else if(i < this->tsetshift_[2]) {
319 this->triangleToPosition(i, 2, triangleCoords_[i].data());
320 trianglePositions_[i] = TrianglePosition::C_3D;
321 } else if(i < this->tsetshift_[3]) {
322 this->triangleToPosition(i, 3, triangleCoords_[i].data());
323 trianglePositions_[i] = TrianglePosition::D1_3D;
324 } else if(i < this->tsetshift_[4]) {
325 this->triangleToPosition(i, 4, triangleCoords_[i].data());
326 trianglePositions_[i] = TrianglePosition::D2_3D;
327 } else if(i < this->tsetshift_[5]) {
328 this->triangleToPosition(i, 5, triangleCoords_[i].data());
329 trianglePositions_[i] = TrianglePosition::D3_3D;
330 }
331 }
332
333 } else if(this->dimensionality_ == 2) {
334#ifdef TTK_ENABLE_OPENMP
335#pragma omp parallel for num_threads(this->threadNumber_)
336#endif // TTK_ENABLE_OPENMP
337 for(SimplexId i = 0; i < this->triangleNumber_; ++i) {
338 this->triangleToPosition2d(i, triangleCoords_[i].data());
339 if(i % 2 == 0) {
340 trianglePositions_[i] = TrianglePosition::TOP_2D;
341 } else {
342 trianglePositions_[i] = TrianglePosition::BOTTOM_2D;
343 }
344 }
345 }
346
347 return 0;
348}
349
351
352 if(this->dimensionality_ != 3) {
353 return 1;
354 }
355 tetrahedronCoords_.resize(this->tetrahedronNumber_);
356
357#ifdef TTK_ENABLE_OPENMP
358#pragma omp parallel for num_threads(this->threadNumber_)
359#endif // TTK_ENABLE_OPENMP
360 for(SimplexId i = 0; i < this->tetrahedronNumber_; ++i) {
361 this->tetrahedronToPosition(i, tetrahedronCoords_[i].data());
362 }
363
364 return 0;
365}
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