Replies: 2 comments 1 reply
-
This line: ui = [interpolate((x,y,0.5),model.velocities.u) for x in xi, y in yi] # Ocean u velocity at Subzero grid locations creates an array on the CPU. I suspect that's not what you want. If you have a @inline subzero_interp(x, y, u) = interpolate((x, y, zero(x)), u)
ui = subzero_interp.(xi, yi, Ref(u)) That works if PS don't forget spaces after commas and also be careful about hard coding A good example of using Oceananigans.jl/src/Fields/interpolate.jl Lines 328 to 372 in 37d0e29 |
Beta Was this translation helpful? Give feedback.
-
Thanks, as always, for your patience. In any case, I still receive the same error when trying the inline function/broadcasting:
(if I try instead to make I'll try to understand more about KernalAbstractions and see if I can solve my issues that way. |
Beta Was this translation helpful? Give feedback.
-
Summary and context
Is there a good method for interpolating fields between grids on a GPU? (or a smarter approach than this type of interpolation?)
I am trying to run two-way-coupled simulations with Oceananigans, and the Subzero.jl sea ice discrete element model. The ice model responds to ocean currents and produces surface stress fields that affect the ocean, so those fields must be passed back and forth (also see #3892). I've realized that there is an offset in the grid definitions between the two models---in the sea ice model, the currents/stresses/etc are defined at effectively the 'corners' of the Oceananigans gridcells (see Caltech-OCTO/Subzero.jl#30).
For now, I've tried to interpolate the ocean currents onto the sea ice grid using
interpolate
fromOceananigans.Fields
. When running on CPU, this seems to work, but on GPU it produces errors (the message in the errors seems to include a work-around, but also suggests avoiding it). I've seen that other interpolation functions in Julia (Interpolations.jl) also aren't GPU compatible.Are there other steps I need to take, or an approach that would be better suited (perhaps somehow avoiding the interpolation issue)? Additionally, are there any suggestions for using built-in functions for interpolating stresses (
τx
,τy
) back onto the Oceananigans grid?Note, this seems to be related to #2565, but it's not clear if there was a resolution to that question (and one of the responses includes a broken link)
Minimal(-ish) working example
This example reproduces the error:
Error
Beta Was this translation helpful? Give feedback.
All reactions