robynsb / interactive-track-and-trace

BSD 2-Clause "Simplified" License
0 stars 3 forks source link

particle beaching #21

Closed djairoh closed 6 months ago

djairoh commented 6 months ago

A particle is beached when it has reached mainland; In code this can be checked by testing the velocity of the particle - if u==v==0, the particle is beached. Beached particles need to remain in the vtkPolydata (we still want to render them), but must not be passed to the advection function (waste of computation).

Straightforward solution is an array of booleans in the vtkPolydata tracking whether a given particle index is beached or not. Then we only pass non-beached particles to the advection function.

djairoh commented 6 months ago

also note that just checking if u==v==0 might lead to some false positives; I haven't checked this, but a particle might end up with zero velocity as a quirk of interpolation and/or the water being particularly calm in a given spot.

If it turns out we get some false positives (easily tested by simulating a bunch of particles i'd say), we can replace the boolean array with an integer one; then increment the value for the particle whenever u==v==0, and reset it whenever the velocity is not zero.

In this case we can use a heuristic like if particleNotMoved > 5 to weed out false positives.

djairoh commented 6 months ago

some particles which are ostensibly beached will still show very small changes in velocities; this leads to images like below - note the line of white (non-beached) particles along the scandinavian coastline.

image

I'm not sure whether to mark these particles as beached or not however - some of these might very well end up in the open sea if the velocities work out right.

If we do want these particles marked as beached, we can work with epsilon values when comparing the new and old positions of a particle: instead of

if (oldX == point[0] and oldY == point[1]) {

we can check for

double eps = 0.01;
if (std::abs(oldX - point[0]) < eps and std::abs(oldY - point[1])) < eps {