Wall-normal velocities can depend on model_fields:
and wall-normal velocities are updated _after_ an RK3 substep, but _before_ the pressure solve:
Thus for some problems the wall-normal velocity fields are updated based on the predictor model fields (both the predictor velocity and the updated tracer fields) that result from an RK3 substep.
This devious bug can be avoided simply by _not updating wall-normal velocity components on the boundary_ in the RK3 substep by changing the indexing in the rk3 substep as well as the worksize here:
Then we don't have to fill halo regions before performing the pressure correction. The resulting algorithm is both more correct and computationally less expensive.
Note that doing this could require a bit of gymnastics to get the indexing right in the rk3 substep kernel:
Some context: @kburns and I encountered this issue when trying to use an Ekman pumping boundary condition, which prescribes
w = k * om
at the bottom boundary, where om is the vertical vorticity and k is a constant:
""" Returns the vertical component of vorticity. """
@inline function ζᶠᶠᶜ(i, j, k, grid, u, v)
∂x_v = δxᶠᵃᵃ(i, j, k, grid, v) / grid.Δx
∂y_u = δyᵃᶠᵃ(i, j, k, grid, u) / grid.Δy
return ∂x_v - ∂y_u
end
@inline pumping_velocity(ζ, κᵖ) = κᵖ * ζ
@inline function pumping_velocity(i, j, grid, clock, model_fields, κᵖ)
ζʷ = ℑxyᶜᶜᵃ(i, j, 1, grid, ζᶠᶠᶜ, model_fields.u, model_fields.v)
return pumping_velocity(ζʷ, κᵖ)
end
pumping_bc = BoundaryCondition(NormalFlow, pumping_velocity, discrete_form=true, parameters=kp)
Most helpful comment
Some context: @kburns and I encountered this issue when trying to use an Ekman pumping boundary condition, which prescribes
at the bottom boundary, where
omis the vertical vorticity andkis a constant: