Open tomchor opened 2 years ago
CC @simone-silvestri
The out-of-bounds error comes from the precomputation of stretched coefficients:
The order is not preserved in Bounded directions, so halos larger than 1 are not necessary when time-stepping. This is why also with (1, 1, 1) would be fine if directions are not stretched.
If the direction is stretched, the stretched coefficients are precomputed on every grid point. The error you see there comes from the coefficients near the boundary (which, indeed are not used) that require halo cells to be computed. Note that a 7th order WENO would require 4 halos in Periodic directions
We could remove the pre-computation of boundary coefficients in case of Bounded directions...
We could remove the pre-computation of boundary coefficients in case of Bounded directions...
As long as it doesn't make the code slower, I'm okay with that. I don't really know enough to have an informed opinion about how to fix it and will defer to whatever you guys think is best :)
We need halos larger than 1 in Bounded
directions, because we should not use short-circuiting logic in GPU kernels.
Can't we use something like inflate_grid_halo_size
inside the WENO constructors?
still an issue?
still an issue?
Yes. I just tested this on main
I do not really like the idea to inflate the grid inside the advection scheme though, if you want you can issue an error message
Agree --- the issue here is just that we would need halo (4, 4, 4)?
yep
The out-of-bounds error comes from the precomputation of stretched coefficients:
The order is not preserved in Bounded directions, so halos larger than 1 are not necessary when time-stepping. This is why also with (1, 1, 1) would be fine if directions are not stretched.
If the direction is stretched, the stretched coefficients are precomputed on every grid point. The error you see there comes from the coefficients near the boundary (which, indeed are not used) that require halo cells to be computed. Note that a 7th order WENO would require 4 halos in Periodic directions
We could remove the pre-computation of boundary coefficients in case of Bounded directions...
Edit: this is wrong, high order halos are always required (also in Bounded directions) because we use ifelse
statement to discriminate between low and high order. ifelse
executes both branches so we need the halos for the branch that we eventually discard
Right so just to clarify we should throw an error in the WENO constructor when the halo isn't big enough. This is fine:
using Oceananigans
H = 4
grid = RectilinearGrid(topology=(Bounded, Bounded, Bounded),
size = (10, 10, 10),
x = (0, 1),
y =(0, 1),
z = k -> k,
halo = (H, H, H))
advection = WENO(grid=grid, order=7)
I get a
BoundsError
when running the following MWE using the latest version of Oceananigans:The error I get is:
Some useful notes:
z
direction the error disappears. Interestingly this code runs even withhalo=(1,1,4)
. (Is the WENO order decreasing as you approach the boundary? Should we throw a warning about this?)z
direction, as expected.z=(0,1)
) the error disappears, which seems to point to a bug.If this isn't a bug and is instead expected behavior, maybe a more useful error would be helpful here?