Peano 4
Loading...
Searching...
No Matches
MultiscaleTransitionsTest.cpp
Go to the documentation of this file.
2
3#include "TestParticle.h"
5
6
8 "toolbox::particles::tests::MultiscaleTransitionsTest"
9);
10
11#ifdef UseTestSpecificCompilerSettings
12#pragma optimize("", off)
13#endif
14
16 TestCase("toolbox::particles::tests::MultiscaleTransitionsTest") {}
17
19#if Dimensions == 2
20 TestParticle particle({0.721487, 0.624479}, 0.0001);
22
23 marker._cellCentre = {0.685185, 0.648148};
24 marker._h = {0.037037, 0.037037};
25 marker._isHanging = 0;
26 marker._select = 1;
27 marker._isAdjacentCellLocal.set();
28
30 marker._cellCentre(0) + 0.5 * marker._h(0), marker._cellCentre(1) - 0.5 * marker._h(1)};
31 // (debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232)
32 // into
33 // ([0.685185,0.648148],[0.037037,0.037037],hanging=0000,select=1)
34
36 toolbox::particles::sieveParticle(particle, marker),
37 marker.toString(),
38 particle._x,
39 cornerVertex1,
40 marker._h / 2.0,
41 tarch::la::abs(marker._cellCentre - particle._x),
42 tarch::la::abs(cornerVertex1 - particle._x)
43 );
44
45 /*
46
47 cannot confirm (yet) that particle is local on tree 1:
48 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
49 cell=(x=[0.833333,0.833333],h=[0.333333,0.333333],has-been-refined=1,will-be-refined=1,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[2,2],has-been-enclave=0,will-be-enclave=0)
50 cannot confirm (yet) that particle is local on tree 1:
51 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
52 cell=(x=[0.722222,0.722222],h=[0.111111,0.111111],has-been-refined=1,will-be-refined=1,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[0,0],has-been-enclave=0,will-be-enclave=0)
53 cannot confirm (yet) that particle is local on tree 1:
54 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
55 cell=(x=[0.611111,0.722222],h=[0.111111,0.111111],has-been-refined=1,will-be-refined=1,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[2,0],has-been-enclave=0,will-be-enclave=0)
56 cannot confirm (yet) that particle is local on tree 0:
57 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
58 cell=(x=[0.685185,0.648148],h=[0.037037,0.037037],has-been-refined=0,will-be-refined=0,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[0,2],has-been-enclave=0,will-be-enclave=0)
59 cannot confirm (yet) that particle is local on tree 0:
60 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
61 cell=(x=[0.722222,0.648148],h=[0.037037,0.037037],has-been-refined=0,will-be-refined=0,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[1,2],has-been-enclave=0,will-be-enclave=0)
62 cannot confirm (yet) that particle is local on tree 1:
63 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
64 cell=(x=[0.611111,0.611111],h=[0.111111,0.111111],has-been-refined=1,will-be-refined=1,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[2,2],has-been-enclave=0,will-be-enclave=0)
65 cannot confirm (yet) that particle is local on tree 0:
66 particle=(debugX=[0.75,0.5],debugH=[0,0],x=[0.721487,0.624479],ParallelState=Local,searchRadius=0.0001,MoveState=Moved,CellHasUpdatedParticle=0,v=[-0.728231,1.39488],a=[-7.97473,-4.38055],energyKin=1.23859,energyPot=2.3109,energyTot=1.07232),
67 cell=(x=[0.685185,0.611111],h=[0.037037,0.037037],has-been-refined=0,will-be-refined=0,is-local=1,one-vertex-hanging=0,one-vertex-destroyed/created=0,all-vertices-inside-domain=0,no-lb=1,rel-pos=[0,1],has-been-enclave=0,will-be-enclave=0)
68
69 */
70#endif
71}
72
74 #if Dimensions==2
75 const int select = 0;
77
78 const double meshSize = 0.111111;
79
80 marker._cellCentre = {0.611111, 0.166667};
81 marker._h = {meshSize, meshSize};
82 marker._isHanging = 0;
83 marker._hasBeenRefined = 1+2+4+8;
84 marker._willBeRefined = 1+2+4+8;
85 marker._isParentVertexLocal = 1+2+4+8;
86 marker._isParentCellLocal = true;
87 marker._relativePositionOfCellWithinFatherCell = {0,0};
88 marker._isAdjacentCellLocal.set();
89
90 tarch::la::Vector<Dimensions,double> x = {0.554725,0.166678};
91 const double searchRadius = 0.0185185;
93 bool drop;
94
95 // bottom left vertex owns particle
96 marker._select = 0;
98 true, // ParallelState=Local
99 searchRadius,
100 x,
101 marker
102 );
104 searchRadius,
105 x,
106 marker
107 );
108
109/*
110 validateWithParams7(
111 liftInstruction==0, // that means we lift
112 marker.toString(),
113 x,
114 liftInstruction, drop,
115 (x-marker.x()),
116 searchRadius,
117 tarch::la::NUMERICAL_ZERO_DIFFERENCE
118 );
119*/
121 not drop, // but we do not drop
122 marker.toString(),
123 x,
124 liftInstruction, drop,
125 (x-marker.x()),
126 searchRadius
127 );
128
129 // top left vertex owns particle
130 marker._select = 2;
132 true, // ParallelState=Local
133 searchRadius,
134 x,
135 marker
136 );
138 searchRadius,
139 x,
140 marker
141 );
142
144 liftInstruction==ParticleReassociationInstruction_Keep, // keep it
145 marker.toString(),
146 x,
147 liftInstruction, drop,
148 (x-marker.x()),
149 searchRadius
150 );
152 drop, // but please drop
153 marker.toString(),
154 x,
155 liftInstruction, drop,
156 (x-marker.x()),
157 searchRadius
158 );
159 #endif
160}
161
163 testMethod(testSievePredicate);
164 testMethod(testLiftDropOfParticleAssociatedWithVertex01);
165 testMethod(testLiftDropOfParticleAssociatedWithVertex02);
166 testMethod(testLiftDropOfParticleAssociatedWithVertex03);
167 testMethod(testLiftDropOfParticleAssociatedWithVertex04);
168}
169
171 #if Dimensions==2
172 const int select = 0;
174
175 const double meshSize = 0.037037;
176
177 marker._cellCentre = {0.537037,0.12963};
178 marker._h = {meshSize, meshSize};
179 marker._isHanging = 0;
180 marker._hasBeenRefined = 0;
181 marker._willBeRefined = 0;
182 marker._isParentVertexLocal = 1+2+4+8;
183 marker._isParentCellLocal = true;
184 marker._relativePositionOfCellWithinFatherCell = {2,0};
185 marker._select = 2;
186 marker._isAdjacentCellLocal.set();
187
188 tarch::la::Vector<Dimensions,double> x = {0.504975,0.1667};
189 const double searchRadius = 0.0185185;
191 bool drop;
192
193 // top left vertex owns particle, but it is even further left up than the
194 // owning vertex. So lift.
196 true, // ParallelState=Local
197 searchRadius,
198 x,
199 marker
200 );
202 searchRadius,
203 x,
204 marker
205 );
206
208 liftInstruction==3, // that means we lift if we don't reassociate within a vertex
209 marker.toString(),
210 x,
211 marker.x(),
212 liftInstruction, drop,
213 (x-marker.x()),
214 searchRadius
215 );
217 not drop, // but we do not drop
218 marker.toString(),
219 x,
220 liftInstruction, drop,
221 (x-marker.x()),
222 searchRadius
223 );
224 #endif
225}
226
227
229 #if Dimensions==2
231
232 const double meshSize = 1.0/3.0/3.0;
233
234 marker._cellCentre = {0.5 * meshSize, 3.5 * meshSize};
235 marker._h = {meshSize, meshSize};
236 marker._isLocal = 0b1111;
237 marker._isHanging = 0b0000;
238 marker._hasBeenRefined = 0b0000;
239 marker._willBeRefined = 0b0000;
240 marker._isParentVertexLocal = 0b1111;
241 marker._isParentCellLocal = true;
242 marker._relativePositionOfCellWithinFatherCell = {0,0};
243 marker._isAdjacentCellLocal = 0b110110000;
244
245 double searchRadius = 0.00555556;
246 tarch::la::Vector<Dimensions,double> x = {0.0555708, 0.322228};
248
249 // Vertex 0 should trigger a lift globally => we see this in the trace
250 marker._select = 0;
251 liftInstruction = liftParticleAssociatedWithVertex(true, searchRadius, x, marker);
253
254 // Vertex 1 would have kept particle => consistency check (not observed, but will arise later)
255 marker._select = 1;
256 liftInstruction = liftParticleAssociatedWithVertex(true, searchRadius, x, marker);
259 internal::fitsIntoLevel(searchRadius, marker),
261 2.0 * searchRadius,
263 marker.toString()
264 );
265
266 // Vertex 0 should not drop
267 marker._select = 0;
269 not dropParticle(searchRadius,x,marker),
270 liftParticleAssociatedWithVertex(true, searchRadius, x, marker),
271 internal::fitsIntoLevel(searchRadius, marker),
274 marker.toString()
275 );
276
277 // Vertex 1 should not drop
278 marker._select = 1;
280 dropParticle(searchRadius,x,marker),
281 liftParticleAssociatedWithVertex(true, searchRadius, x, marker),
282 internal::fitsIntoLevel(searchRadius, marker),
285 marker.toString()
286 );
287
288 // And now we study the same thing from the boundary cell below on the other
289 // rank
290 marker._cellCentre(1) -= meshSize;
291 marker._isAdjacentCellLocal.flip();
292
293 // Vertex 2 should not drop
294 marker._select = 2;
295 validateWithParams1(not dropParticle(searchRadius,x,marker), marker.toString());
296
297 // Vertex 3 should not drop
298 marker._select = 3;
299 validateWithParams1(dropParticle(searchRadius,x,marker), marker.toString());
300
301
302 // Roll back and see if sieving works
303 marker._cellCentre(0) -= meshSize;
304 searchRadius = 0.0555556;
305
306 // Vertex 0 should trigger a lift globally - this time due to the size of the
307 // particle and the distance
308 marker._select = 0;
309 liftInstruction = liftParticleAssociatedWithVertex(true, searchRadius, x, marker);
311
312 // Vertex 1 would not keep particle either as it is too big
313 marker._select = 1;
314 liftInstruction = liftParticleAssociatedWithVertex(true, searchRadius, x, marker);
317 internal::fitsIntoLevel(searchRadius, marker),
319 2.0 * searchRadius,
321 marker.toString()
322 );
323
324 // Next coarser mesh level
325 marker._cellCentre = {1.5*meshSize, 1.5*meshSize};
326 marker._select = 2;
327 marker._h = {3.0*meshSize, 3.0*meshSize};
328
330 sieveParticle(searchRadius, x, marker),
331 internal::fitsIntoLevel(searchRadius, marker),
333 2.0 * searchRadius,
335 marker.toString()
336 );
337
338 #endif
339}
340
341
342
344 #if Dimensions==2
345 const int select = 0;
347
348 const double meshSize = 1.0/3.0;
349
350 marker._cellCentre = {0.166667,0.5};
351 marker._h = {meshSize, meshSize};
352 marker._isHanging = 0;
353 marker._hasBeenRefined = 0;
354 marker._willBeRefined = 0;
355 marker._isParentVertexLocal = 0b1011;
356 marker._isParentCellLocal = true;
357 marker._relativePositionOfCellWithinFatherCell = {2,0};
358 marker._select = 2;
359 marker._isAdjacentCellLocal = 0b000100110;
360
361 tarch::la::Vector<Dimensions,double> x = {4.99999996463071805231e-01, 5.00000003548028204570e-01};
362 const double searchRadius = 0.15;
364 bool drop;
365
366 // Vertex 1 triggers a global lift
367 marker._select = 1;
368 liftInstruction = liftParticleAssociatedWithVertex(true, searchRadius, x, marker);
370
372 not sieveParticle(searchRadius, x, marker),
373 internal::fitsIntoLevel(searchRadius, marker),
375 2.0 * searchRadius,
377 marker.toString()
378 );
379
380 marker._select = 3;
382 sieveParticle(searchRadius, x, marker),
383 internal::fitsIntoLevel(searchRadius, marker),
385 2.0 * searchRadius,
387 marker.toString()
388 );
389
390 // look into cell to the right
391 marker._cellCentre(0) += meshSize;
392 marker._isAdjacentCellLocal = 0b000110111;
393
394 marker._select = 0;
396 not sieveParticle(searchRadius, x, marker),
397 internal::fitsIntoLevel(searchRadius, marker),
399 2.0 * searchRadius,
401 marker.toString()
402 );
403
404 marker._select = 2;
406 sieveParticle(searchRadius, x, marker),
407 internal::fitsIntoLevel(searchRadius, marker),
409 2.0 * searchRadius,
411 marker.toString()
412 );
413
414 // study diagonal right top cell
415 marker._cellCentre(1) += meshSize;
416 marker._isAdjacentCellLocal = 0b000000110;
417
418 marker._select = 0;
420 sieveParticle(searchRadius, x, marker),
421 internal::fitsIntoLevel(searchRadius, marker),
423 2.0 * searchRadius,
425 marker.toString()
426 );
427
428
429 // Same overall test on other rank: start with left cell
430 marker._cellCentre = {0.166667,0.5};
431 marker._isAdjacentCellLocal = 0b000100110;
432 marker._isAdjacentCellLocal.flip();
433
434 marker._select = 1;
436 not sieveParticle(searchRadius, x, marker),
437 internal::fitsIntoLevel(searchRadius, marker),
439 2.0 * searchRadius,
441 marker.toString()
442 );
443
444 marker._select = 3;
446 sieveParticle(searchRadius, x, marker),
447 internal::fitsIntoLevel(searchRadius, marker),
449 2.0 * searchRadius,
451 marker.toString()
452 );
453
454 // study diagonal right top cell
455 marker._cellCentre(0) += meshSize;
456 marker._cellCentre(1) += meshSize;
457 marker._isAdjacentCellLocal = 0b000000110;
458 marker._isAdjacentCellLocal.flip();
459
460 marker._select = 0;
462 sieveParticle(searchRadius, x, marker),
463 internal::fitsIntoLevel(searchRadius, marker),
465 2.0 * searchRadius,
467 marker.toString()
468 );
469 #endif
470}
471
472#ifdef UseTestSpecificCompilerSettings
473#pragma optimize("", on)
474#endif
#define validateWithParams5(booleanExpr, param0, param1, param2, param3, param4)
Definition TestMacros.h:105
#define validateWithParams7(booleanExpr, param0, param1, param2, param3, param4, param5, param6)
Definition TestMacros.h:135
#define validateEqualsWithParams1(actualValue, validValue, param0)
Definition TestMacros.h:318
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateEqualsWithParams5(actualValue, validValue, param0, param1, param2, param3, param4)
Definition TestMacros.h:359
#define validateWithParams1(booleanExpr, param0)
Definition TestMacros.h:59
#define validateWithParams6(booleanExpr, param0, param1, param2, param3, param4, param5)
Definition TestMacros.h:119
Log Device.
Definition Log.h:516
virtual void run() override
This routine is triggered by the TestCaseCollection.
void testSievePredicate()
Test setup from the Swift test case:
void testLiftDropOfParticleAssociatedWithVertex01()
Test the instructions indicatring whether to lift a particle.
constexpr double NUMERICAL_ZERO_DIFFERENCE
Definition Scalar.h:17
double abs(double value)
Returns the absolute value of a type by redirecting to std::abs.
double relativeGrabOwnershipSpatialSortingTolerance(const ::peano4::datamanagement::VertexMarker &marker)
double relativeReleaseOwnershipSpatialSortingTolerance(const ::peano4::datamanagement::VertexMarker &marker)
bool fitsIntoLevel(double searchRadius, const ::peano4::datamanagement::CellMarker &marker)
constexpr int ParticleReassociationInstruction_SieveGlobally
bool sieveParticle(const Particle &particle, const peano4::datamanagement::VertexMarker &marker)
A particle is to be sieved into a vertex if.
bool dropParticle(const Particle &particle, const peano4::datamanagement::VertexMarker &marker)
ParticleReassociationInstruction liftParticleAssociatedWithVertex(const Particle &p, const peano4::datamanagement::VertexMarker marker)
Take particle from current vertex and lift it or keep it local.
constexpr int ParticleReassociationInstruction_Keep
Vertex marker to provide information about selected vertex.
Simple vector class.
Definition Vector.h:134