Oceananigans.jl
Oceananigans.jl copied to clipboard
Need interpretable error if `LagrangianParticles` are initialized with invalid positions
Right now if we do this, we get an obscure error from calc_correct_velocity_u (which is already a confusing name --- what's the "incorrect" velocity?)
nested task error: BoundsError: attempt to access 608-element OffsetArray(::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, -3:604) with eltype Float64 with indices -3:604 at index [-58]
Stacktrace:
[1] throw_boundserror(A::OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, I::Tuple{Int64})
@ Base ./abstractarray.jl:691
[2] checkbounds
@ ./abstractarray.jl:656 [inlined]
[3] getindex
@ ~/.julia/packages/OffsetArrays/80Lkc/src/OffsetArrays.jl:435 [inlined]
[4] calc_correct_velocity_u
@ ~/.julia/packages/Oceananigans/HYqGf/src/LagrangianParticleTracking/update_particle_properties.jl:104 [inlined]
[5] update_particle_position!
@ ~/.julia/packages/Oceananigans/HYqGf/src/LagrangianParticleTracking/update_particle_properties.jl:72 [inlined]
This probably has to be checked in model constructors, since LagrangianParticles doesn't know about grid.
Future work on the particles module is also to write some tests for immersed boundary particle tracking
We should also decide whether to automatically convert particle arrays to CuArray for GPU architectures. I think probably yes.