Fields interpolation on lagrangian particle trajectories #3297
-
Hi, I am using the LagrangianParticles() function in Oceananigans. I am wondering if there is a way to interpolate the fields (e.g. u, v, w, b) onto particle trajectories and save the fields for each particle. Many thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Hi Roger, You could do this by making a custom particle, using tracked fields to set the particle properties, and saving the particles the normal way. For example: using Oceananigans
using Oceananigans.Fields: VelocityFields
using StructArrays
struct TrackingParticle{FT}
x :: FT
y :: FT
z :: FT
u :: FT
v :: FT
w :: FT
b :: FT
end
grid = RectilinearGrid(; size = (128, 128, 128), extent = (100, 100, 100))
n = 100
x₀, y₀, z₀, u₀, v₀, w₀, b₀ = [zeros(n) for i in 1:7]
particles = StructArray{TrackingParticle}((x₀, y₀, z₀, u₀, v₀, w₀, b₀))
u, v, w = VelocityFields(grid)
b = CenterField(grid)
lagrangian_particles = LagrangianParticles(particles, tracked_fields = (; u, v, w, b))
model = NonhydrostaticModel(; grid, velocities = (; u, v, w), particles = lagrangian_particles, buoyancy = BuoyancyTracer(), tracers = (; b))
simulation = Simulation(model, Δt = 1, stop_iteration = 100)
simulation.output_writers[:particles] = JLD2OutputWriter(model, (particles=model.particles,), filename="particles", schedule=IterationInterval(1)) |
Beta Was this translation helpful? Give feedback.
-
I don't think they're used in kernels. I don't know why we would need particles to have their own fields that can't just be part of the model. Wouldn't adding in that way require a materialisation step in the model setup also? |
Beta Was this translation helpful? Give feedback.
-
You can make an abstract operation and track that, e.g. |
Beta Was this translation helpful? Give feedback.
Hi Roger,
You could do this by making a custom particle, using tracked fields to set the particle properties, and saving the particles the normal way. For example: