@@ -9,7 +9,7 @@ using Oceananigans.Models: seawater_density
99using Oceananigans. Models: model_geopotential_height
1010using Oceananigans. Grids: Center, Face
1111using Oceananigans. BuoyancyModels: Buoyancy, BuoyancyTracer, SeawaterBuoyancy, LinearEquationOfState
12- using Oceananigans. BuoyancyModels: buoyancy_perturbationᶜᶜᶜ
12+ using Oceananigans. BuoyancyModels: buoyancy_perturbationᶜᶜᶜ, Zᶜᶜᶜ
1313using Oceananigans. Models: ShallowWaterModel
1414using Oceanostics: validate_location
1515using SeawaterPolynomials: BoussinesqEquationOfState
@@ -19,9 +19,6 @@ const BuoyancyTracerModel = Buoyancy{<:BuoyancyTracer, g} where g
1919const BuoyancyLinearEOSModel = Buoyancy{<: SeawaterBuoyancy{FT, <:LinearEquationOfState, T, S} } where {FT, T, S}
2020const BuoyancyBoussinesqEOSModel = Buoyancy{<: SeawaterBuoyancy{FT, <:BoussinesqEquationOfState, T, S} } where {FT, T, S}
2121
22- linear_eos_buoyancy (model) = linear_eos_buoyancy (model. grid, model. buoyancy. model, model. tracers)
23- linear_eos_buoyancy (grid, buoyancy, tracers) = KernelFunctionOperation {Center, Center, Center} (buoyancy_perturbationᶜᶜᶜ, grid, buoyancy, tracers)
24-
2522"""
2623 $(SIGNATURES)
2724
@@ -152,33 +149,33 @@ end
152149
153150 grid = model. grid
154151 b = model. tracers. b
155- Z = model_geopotential_height (model)
156152
157- return KernelFunctionOperation {Center, Center, Center} (bz_ccc, grid, b, Z )
153+ return KernelFunctionOperation {Center, Center, Center} (bz_ccc, grid, b)
158154end
159155
156+ @inline bz_ccc (i, j, k, grid, b) = b[i, j, k] * Zᶜᶜᶜ (i, j, k, grid)
157+
160158@inline function PotentialEnergy (model, buoyancy_model:: BuoyancyLinearEOSModel , geopotential_height)
161159
162160 grid = model. grid
163- b = linear_eos_buoyancy ( model)
164- Z = model_geopotential_height ( model)
161+ C = model. tracers
162+ b = buoyancy_model . model
165163
166- return KernelFunctionOperation {Center, Center, Center} (bz_ccc, grid, b, Z )
164+ return KernelFunctionOperation {Center, Center, Center} (bz_ccc, grid, b, C )
167165end
168166
169- @inline bz_ccc (i, j, k, grid, b, Z ) = b[ i, j, k] * Z[ i, j, k]
167+ @inline bz_ccc (i, j, k, grid, b, C ) = buoyancy_perturbationᶜᶜᶜ ( i, j, k, grid, b, C) * Zᶜᶜᶜ ( i, j, k, grid)
170168
171169@inline function PotentialEnergy (model, buoyancy_model:: BuoyancyBoussinesqEOSModel , geopotential_height)
172170
173171 grid = model. grid
174172 ρ = seawater_density (model; geopotential_height)
175- Z = model_geopotential_height (model)
176173 parameters = (g = model. buoyancy. model. gravitational_acceleration,
177174 ρ₀ = model. buoyancy. model. equation_of_state. reference_density)
178175
179176 return KernelFunctionOperation {Center, Center, Center} (g′z_ccc, grid, ρ, Z, parameters)
180177end
181178
182- @inline g′z_ccc (i, j, k, grid, ρ, Z, p) = (p. g / p. ρ₀) * ρ[i, j, k] * Z[ i, j, k]
179+ @inline g′z_ccc (i, j, k, grid, ρ, p) = (p. g / p. ρ₀) * ρ[i, j, k] * Zᶜᶜᶜ ( i, j, k, grid)
183180
184181end # module
0 commit comments