Skip to content

Commit

Permalink
Add inlines for general interpolation (#3653)
Browse files Browse the repository at this point in the history
* add inlines

* correct documentation

* another correction

* another correction
  • Loading branch information
simone-silvestri authored Jul 22, 2024
1 parent d6e63e5 commit f2f7e0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Operators/interpolation_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ for LX in (:Center, :Face), LY in (:Center, :Face), LZ in (:Center, :Face)
to = (eval(IX), eval(IY), eval(IZ))
interp_func = Symbol(interpolation_operator(from, to))
@eval begin
ℑxyz(i, j, k, grid, from::F, to::T, c) where {F<:Tuple{<:$LX, <:$LY, <:$LZ}, T<:Tuple{<:$IX, <:$IY, <:$IZ}} =
$interp_func(i, j, k, grid, c)
@inline ℑxyz(i, j, k, grid, from::F, to::T, c) where {F<:Tuple{<:$LX, <:$LY, <:$LZ}, T<:Tuple{<:$IX, <:$IY, <:$IZ}} =
$interp_func(i, j, k, grid, c)

ℑxyz(i, j, k, grid, from::F, to::T, f, args...) where {F<:Tuple{<:$LX, <:$LY, <:$LZ}, T<:Tuple{<:$IX, <:$IY, <:$IZ}} =
$interp_func(i, j, k, grid, f, args...)
@inline ℑxyz(i, j, k, grid, from::F, to::T, f, args...) where {F<:Tuple{<:$LX, <:$LY, <:$LZ}, T<:Tuple{<:$IX, <:$IY, <:$IZ}} =
$interp_func(i, j, k, grid, f, args...)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ value of keyword argument `discrete_form`, the constructor expects:
a `LatitudeLongitudeGrid`.
* `discrete_form = true`:
- with `loc = (nothing, nothing, nothing)` (default):
functions of `(i, j, k, grid, ℓx, ℓy, ℓz)` with `ℓx`, `ℓy`,
- with `loc = (nothing, nothing, nothing)` and `parameters = nothing` (default):
functions of `(i, j, k, grid, ℓx, ℓy, ℓz, clock, fields)` with `ℓx`, `ℓy`,
and `ℓz` either `Face()` or `Center()`.
- with `loc = (ℓx, ℓy, ℓz)` with `ℓx`, `ℓy`, and `ℓz` either
`Face()` or `Center()`: functions of `(i, j, k, grid)`.
`Face()` or `Center()` and `parameters = nothing`: functions of `(i, j, k, grid, clock, fields)`.
- with `loc = (nothing, nothing, nothing)` and specified `parameters`:
functions of `(i, j, k, grid, ℓx, ℓy, ℓz, clock, fields, parameters)`.
- with `loc = (ℓx, ℓy, ℓz)` and specified `parameters`:
functions of `(i, j, k, grid, clock, fields, parameters)`.
* `parameters`: `NamedTuple` with parameters used by the functions
that compute viscosity and/or diffusivity; default: `nothing`.
Expand Down Expand Up @@ -85,7 +89,7 @@ ScalarDiffusivity{ExplicitTimeDiscretization}(ν=ν (generic function with 1 met
```jldoctest ScalarDiffusivity
julia> using Oceananigans.Grids: znode
julia> @inline function κ(i, j, k, grid, ℓx, ℓy, ℓz)
julia> @inline function κ(i, j, k, grid, ℓx, ℓy, ℓz, clock, fields)
z = znode(i, j, k, grid, ℓx, ℓy, ℓz)
return 2000 * exp(z / depth_scale)
end
Expand All @@ -96,8 +100,8 @@ ScalarDiffusivity{ExplicitTimeDiscretization}(ν=0.0, κ=Oceananigans.Turbulence
```
```jldoctest ScalarDiffusivity
julia> @inline function another_κ(i, j, k, grid, p)
z = znode(i, j, k, grid)
julia> @inline function another_κ(i, j, k, grid, clock, fields, p)
z = znode(i, j, k, grid, Center(), Center(), Face())
return 2000 * exp(z / p.depth_scale)
end
another_κ (generic function with 1 method)
Expand Down

0 comments on commit f2f7e0b

Please sign in to comment.