You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that in the Periodic directions, particles that have coordinates within the last cell at the end of the domain get moved into the first cell when I think it should not be. Here's a MWE:
using Oceananigans
using Oceananigans.Units
using StructArrays
using Printf
using Random
using Statistics
grid =RectilinearGrid(CPU(), Float64,
size = (2, 2, 2),
halo = (5, 5, 5),
x = (0, 1),
y = (0, 1),
z = (-1, 0),
topology = (Periodic, Periodic, Bounded))
struct SimpleParticle{X}
x ::X
y ::X
z ::Xend
n_particles =5
x_particle =collect(range(0, stop=1, length=n_particles))
y_particle =collect(range(0, stop=1, length=n_particles))
z_particle =collect(fill(-0.5, n_particles))
particles =StructArray{SimpleParticle}((x_particle, y_particle, z_particle))
lagrangian_particles =LagrangianParticles(particles)
model =NonhydrostaticModel(;
grid = grid,
timestepper =:RungeKutta3,
advection =WENO(order=9),
particles = lagrangian_particles
)
u, v, w = model.velocities
simulation =Simulation(model, Δt=0.1seconds, stop_iteration=2)
wall_clock = [time_ns()]
functionprint_progress(sim)
@printf("i: %d, t: %s, wall time: %s, max(u): (%6.3e, %6.3e, %6.3e) m/s, next Δt: %s\n",
sim.model.clock.iteration,
prettytime(sim.model.clock.time),
prettytime(1e-9* (time_ns() - wall_clock[1])),
maximum(abs, sim.model.velocities.u),
maximum(abs, sim.model.velocities.v),
maximum(abs, sim.model.velocities.w),
prettytime(sim.Δt))
@info"x(particle): $(round.(lagrangian_particles.properties.x, digits=2)), y(particle): $(round.(lagrangian_particles.properties.y, digits=2)), z(particle): $(round.(lagrangian_particles.properties.z, digits=2))\n"
wall_clock[1] =time_ns()
returnnothingend
simulation.callbacks[:print_progress] =Callback(print_progress, IterationInterval(1))
run!(simulation)
This seems correct for Periodic topologies but wouldn't it be the case for Bounded too. Do particles get bounced if you put them just to the right of the N'th face in a Bounded direction?
This seems correct for Periodic topologies but wouldn't it be the case for Bounded too. Do particles get bounced if you put them just to the right of the N'th face in a Bounded direction?
I've put up a similar test script in the PR: #3416 (comment)
Let me know if you think that is the expected behaviour, and what else should I test.
I noticed that in the
Periodic
directions, particles that have coordinates within the last cell at the end of the domain get moved into the first cell when I think it should not be. Here's a MWE:Here's the output log of the script:
We see that the particles with x- and y- coordinates larger than 0.5 get moved after the first time step when I think it shouldn't be.
This is because of the following lines:
https://github.com/CliMA/Oceananigans.jl/blob/3e2650373e9c73231681535aadb5b720a830dc97/src/Models/LagrangianParticleTracking/lagrangian_particle_advection.jl#L102C4-L104C27
Instead of
I think it should be
The change gives an output log of
This then ensures that we are only moving particles in the periodic direction only if they are truly outside of the rightmost cell.
The text was updated successfully, but these errors were encountered: