Skip to content

Commit 1a82e66

Browse files
glwagnernavidcy
andauthored
Refactor vertical vorticity to return operation rather than Field (#3340)
* Refactor vertical vorticity to return operation rather than Field * Update src/Models/HydrostaticFreeSurfaceModels/vertical_vorticity.jl Co-authored-by: Navid C. Constantinou <navidcy@users.noreply.github.com> * vertical_vorticity_field.jl -> vertical_vorticity.jl * Update test * Bugfix --------- Co-authored-by: Navid C. Constantinou <navidcy@users.noreply.github.com>
1 parent 875a06a commit 1a82e66

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

src/Models/HydrostaticFreeSurfaceModels/HydrostaticFreeSurfaceModels.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@ include("slice_ensemble_model_mode.jl")
151151
##### Some diagnostics
152152
#####
153153

154-
include("vertical_vorticity_field.jl")
154+
include("vertical_vorticity.jl")
155155

156156
end # module
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Oceananigans.Grids: Face, Face, Center
2+
using Oceananigans.Operators: ζ₃ᶠᶠᶜ
3+
using Oceananigans.AbstractOperations: KernelFunctionOperation
4+
5+
"""
6+
vertical_vorticity(model::HydrostaticFreeSurfaceModel)
7+
8+
Return a `KernelFunctionOperation` that represents vertical vorticity for the
9+
`HydrostaticFreeSurfaceModel`. The kernel function is `Oceananigans.Operators.ζ₃ᶠᶠᶜ`,
10+
and thus computed consistently with the `VectorInvariant` momentum advection scheme
11+
for curvilinear grids.
12+
"""
13+
function vertical_vorticity(model::HydrostaticFreeSurfaceModel)
14+
u, v, w = model.velocities
15+
return KernelFunctionOperation{Face, Face, Center}(ζ₃ᶠᶠᶜ, model.grid, u, v)
16+
end
17+

src/Models/HydrostaticFreeSurfaceModels/vertical_vorticity_field.jl

-23
This file was deleted.

test/test_vertical_vorticity_field.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Oceananigans.Models.HydrostaticFreeSurfaceModels: VerticalVorticityField, VectorInvariant
1+
using Oceananigans.Models.HydrostaticFreeSurfaceModels: vertical_vorticity, VectorInvariant
22

33
@testset "VerticalVorticityField with HydrostaticFreeSurfaceModel" begin
44

@@ -16,10 +16,10 @@ using Oceananigans.Models.HydrostaticFreeSurfaceModels: VerticalVorticityField,
1616
ψᵢ(λ, φ, z) = rand()
1717
set!(model, u=ψᵢ, v=ψᵢ)
1818

19-
ζ = VerticalVorticityField(model)
20-
19+
ζ = vertical_vorticity(model)
20+
@test ζ isa KernelFunctionOperation
21+
ζ = Field(ζ)
2122
compute!(ζ)
22-
2323
@test all(isfinite.(ζ.data))
2424
end
2525
end

0 commit comments

Comments
 (0)