Skip to content
Discussion options

You must be logged in to vote

You can use the derivative operators in the discrete form like:

using Oceananigans.Operators: ∂xᶠᶜᶜ, ∂zᶠᶜᶜ

function τxx_forcing_func(i, j, k, grid, clock, F)
    @inbounds begin
        dudx = ∂zᶠᶜᶜ(i, j, k, grid, F.τxx)
        dudz = ∂xᶠᶜᶜ(i, j, k, grid, F.τxz)
        return 2/W * dudx - F.τxx[i, j, k]/W + 2*(F.τxx[i, j, k]*dudx + F.τxz[i, j, k]*dudz)
    end
end
τxx_forcing = Forcing(τxx_forcing_func, discrete_form=true)

If you wanted to wrap this up to make the functions a bit more compact, the only other way that comes to mind is to make fields of the derivatives and then put them into the model as auxiliary fields, something like:

u, v, w = VelocityFields(grid)

τxx = ...

∂x_τxx = 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Leezhard
Comment options

@glwagner
Comment options

Answer selected by Leezhard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants