How to get z-coordinate in discrete forcing term? #4388
-
Hi all, I encountered a basic problem but I cannot manage to overcome it. I am using the discrete forcing term in the following way: function forcing_func(i, j, k, grid, clock, model_fields)
@inbounds begin
dτxzdx = (-model_fields.τxz[i+2,j,k] + 8*model_fields.τxz[i+1,j,k] - 8*model_fields.τxz[i-1,j,k] + model_fields.τxz[i-2,j,k]) / (12 * dx)
dτzzdz = (-model_fields.τzz[i,j,k+2] + 8*model_fields.τzz[i,j,k+1] - 8*model_fields.τzz[i,j,k-1] + model_fields.τzz[i,j,k-2]) / (12 * dz)
buoyancy = Ri*model_fields.ρ[i,j,k]
return (1-β)/Re * (dτxzdx + dτzzdz) + buoyancy # + Ri/2 *(z + 1), I want to add this extra term
end
end The code currently works, but now I want to add an extra term: Ri/2 * (z + 1). I have noticed that znodes may help, but I can not find such an example using it to get z-coordinate with k-index in the discrete forcing term. Many thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Leezhard! I think you're looking for the Oceananigans.jl/src/Grids/vertical_discretization.jl Lines 128 to 129 in a84b3f8 where It's not exported so you'll have to do |
Beta Was this translation helpful? Give feedback.
Hi @Leezhard! I think you're looking for the
znode
function defined here for example:Oceananigans.jl/src/Grids/vertical_discretization.jl
Lines 128 to 129 in a84b3f8
where
ℓz
is the location in the z-direction, e.g.Face()
orCenter()
.It's not exported so you'll have to do
using Oceananigans.Grids: znode
but then you can use it in forcing functions.