Skip to content

Commit

Permalink
changes...
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-silvestri committed Oct 6, 2023
1 parent 923030b commit 74dbc06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/IceOceanModel/model_utils.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using Oceananigans
using Oceananigans.Utils: Time
using Oceananigans.Grids: architecture
using Oceananigans.Models: AbstractModel
import Oceananigans.Grids: launch!

launch!(model::AbstractModel, args...; kwargs...) = launch!(architecture(model.grid), model.grid, args...; kwargs...)

@inline getflux(::Nothing, f::Function, i, j, grid, clock, fields) = f(i, j, grid, clock, fields)
@inline getflux(::Nothing, f::AbstractArray{<:Any, 2}, i, j, grid, args...) = @inbounds f[i, j]
@inline getflux(::Nothing, f::AbstractField, i, j, grid, args...) = @inbounds f[i, j, 1]
@inline getflux(::Nothing, f::FieldTimeSeries, i, j, grid, clock, args...) = @inbounds f[i, j, Time(clock.time)]

@inline getflux(f::Function, i, j, grid, clock, fields) = f(i, j, grid, clock, fields)

# If we have ice, do not compute fluxes!
@inline function get_flux(ice_thickness, f, i, j, args...)
h = @inbounds ice_thickness[i, j, 1]
return ifelse(h > 0, getflux(nothing, f, i, j, args...), 0)
end
4 changes: 3 additions & 1 deletion src/IceOceanModel/only_ocean_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ function compute_air_sea_fluxes!(coupled_model::OnlyOceanModel)
= S.boundary_conditions.top.condition
τˣ = u.boundary_conditions.top.condition
τʸ = v.boundary_conditions.top.condition

ε = coupled_model.ocean_emissivity

launch!(ocean, :xy, _calculate_air_sea_fluxes!, Qˢ, Fˢ, τˣ, τʸ, grid, clock, fields, forcing)
launch!(ocean, :xy, _calculate_air_sea_fluxes!, Qˢ, Fˢ, τˣ, τʸ, ε, grid, clock, fields, forcing, nothing)

return nothing
end

0 comments on commit 74dbc06

Please sign in to comment.