Index guesses aren't updated in sample kernel
Closed this issue · 0 comments
angus-g commented
Parcels JIT particles have xi
, yi
, zi
, and ti
variables, which are the index of the cell containing the particle. These are used as guesses during interpolation, to amortise a linear scan down to something closer to constant-time. The JITParticle
class asks for the spatial indices to be initialised to -1, after which they should be updated in search_indices_rectilinear()
:
while (*xi < xdim-1 && x > xvals[*xi+1]) ++(*xi);
while (*xi > 0 && x < xvals[*xi]) --(*xi);
*xsi = (x - xvals[*xi]) / (xvals[*xi+1] - xvals[*xi]);
However, we seem to be hitting a case in the sample-only kernel (where particles are initialised on gridpoints, and don't move), where indices aren't being updated:
spatial_interpolation_bilinear: Assertion `xi > 0' failed.