@@ -19,24 +19,13 @@ using Plots
19
19
using ArgParse
20
20
21
21
using Oceananigans
22
- using Oceananigans. Advection
23
- using Oceananigans. Grids
24
- using Oceananigans. Fields
25
- using Oceananigans. BuoyancyModels
26
- using Oceananigans. BoundaryConditions
27
- using Oceananigans. Diagnostics
28
- using Oceananigans. OutputWriters
29
- using Oceananigans. Utils
30
-
31
- using LESbrary
32
-
22
+ using Oceananigans. Units
33
23
using Oceananigans. BuoyancyModels: g_Earth
34
- using Oceananigans. Fields: PressureField
35
- using Oceananigans. BuoyancyModels: BuoyancyTracer
36
- using Oceananigans. SurfaceWaves: UniformStokesDrift
37
24
38
- using LESbrary. TurbulenceStatistics: TurbulentKineticEnergy, ShearProduction, ViscousDissipation
25
+ using LESbrary
26
+ using LESbrary. TurbulenceStatistics: TurbulentKineticEnergy, ViscousDissipation
39
27
using LESbrary. TurbulenceStatistics: first_through_second_order, turbulent_kinetic_energy_budget
28
+ using Oceanostics. TKEBudgetTerms: ZShearProduction
40
29
41
30
" Returns a dictionary of command line arguments."
42
31
function parse_command_line_arguments ()
@@ -121,16 +110,16 @@ uˢ(z) = Uˢ * exp(2wavenumber * z)
121
110
# #### Grid
122
111
# ####
123
112
124
- grid = RegularRectilinearGrid ( size= (Nh, Nh, Nz), extent= (Lh, Lh, Lz))
113
+ grid = RectilinearGrid ( CPU (), size= (Nh, Nh, Nz), extent= (Lh, Lh, Lz))
125
114
126
115
# ####
127
116
# #### Boundary conditions
128
117
# ####
129
118
130
- u_bcs = UVelocityBoundaryConditions (grid, top = BoundaryCondition (Flux, Qᵘ))
119
+ u_bcs = FieldBoundaryConditions ( top = FluxBoundaryCondition ( Qᵘ))
131
120
132
- b_bcs = TracerBoundaryConditions (grid, top = BoundaryCondition (Flux, Qᵇ),
133
- bottom = BoundaryCondition (Gradient, N²))
121
+ b_bcs = FieldBoundaryConditions ( top = FluxBoundaryCondition ( Qᵇ),
122
+ bottom = GradientBoundaryCondition ( N²))
134
123
135
124
# ####
136
125
# #### Sponge layer
@@ -150,19 +139,15 @@ b_sponge = Relaxation(rate = 1/hour,
150
139
151
140
advection = eval (args[" advection-scheme" ])()
152
141
153
- model = IncompressibleModel (
154
- architecture = GPU (),
155
- timestepper = :RungeKutta3 ,
156
- advection = advection,
157
- grid = grid,
158
- tracers = :b ,
159
- buoyancy = BuoyancyTracer (),
160
- coriolis = FPlane (f= f),
161
- closure = AnisotropicMinimumDissipation (),
162
- surface_waves = UniformStokesDrift (∂z_uˢ= ∂z_uˢ),
163
- boundary_conditions = (u= u_bcs, b= b_bcs),
164
- forcing = (u= u_sponge, v= v_sponge, w= w_sponge, b= b_sponge),
165
- )
142
+ model = NonhydrostaticModel (; advection, grid,
143
+ timestepper = :RungeKutta3 ,
144
+ tracers = :b ,
145
+ buoyancy = BuoyancyTracer (),
146
+ coriolis = FPlane (f= f),
147
+ closure = AnisotropicMinimumDissipation (),
148
+ stokes_drift = UniformStokesDrift (∂z_uˢ= ∂z_uˢ),
149
+ boundary_conditions = (u= u_bcs, b= b_bcs),
150
+ forcing = (u= u_sponge, v= v_sponge, w= w_sponge, b= b_sponge))
166
151
167
152
# ####
168
153
# #### Initial conditions: Stokes drift + stratification + noise
@@ -182,23 +167,26 @@ set!(model, u=uᵢ, w=wᵢ, b=bᵢ)
182
167
# #### Simulation setup
183
168
# ####
184
169
185
- wizard = TimeStepWizard (cfl = 1.0 , Δt= 1.0 , max_change = 1.1 , max_Δt = 30.0 )
170
+ simulation = Simulation (model; Δt= 1.0 , stop_time )
186
171
187
- umax = FieldMaximum (abs, model. velocities. u)
188
- vmax = FieldMaximum (abs, model. velocities. v)
189
- wmax = FieldMaximum (abs, model. velocities. w)
172
+ wizard = TimeStepWizard (cfl= 1.0 , max_change= 1.1 , max_Δt= 30.0 )
173
+ simulation. callbacks[:wizard ] = Callback (wizard, IterationInterval (10 ))
190
174
191
175
wall_clock = [time_ns ()]
192
176
193
177
function print_progress (simulation)
194
178
model = simulation. model
195
179
180
+ umax = maximum (abs, model. velocities. u)
181
+ vmax = maximum (abs, model. velocities. v)
182
+ wmax = maximum (abs, model. velocities. w)
183
+
196
184
# # Print a progress message
197
185
msg = @sprintf (" i: %04d, t: %s, Δt: %s, umax = (%.1e, %.1e, %.1e) ms⁻¹, wall time: %s\n " ,
198
- model . clock . iteration,
199
- prettytime (model . clock . time ),
200
- prettytime (wizard . Δt),
201
- umax () , vmax () , wmax () ,
186
+ iteration (simulation) ,
187
+ prettytime (simulation ),
188
+ prettytime (simulation . Δt),
189
+ umax, vmax, wmax,
202
190
prettytime (1e-9 * (time_ns () - wall_clock[1 ]))
203
191
)
204
192
@@ -209,10 +197,7 @@ function print_progress(simulation)
209
197
return nothing
210
198
end
211
199
212
- simulation = Simulation (model, iteration_interval = 10 ,
213
- Δt = wizard,
214
- stop_time = stop_time,
215
- progress = print_progress)
200
+ simulation. callbacks[:progress ] = Callback (print_progress, IterationInterval (10 ))
216
201
217
202
# ####
218
203
# #### Output setup
@@ -224,9 +209,9 @@ data_directory = joinpath(@__DIR__, "..", "data", prefix) # save data in /data/p
224
209
# "Primitive" statistics
225
210
226
211
b = BuoyancyField (model)
227
- p = PressureField ( model)
228
- w_scratch = ZFaceField (model. architecture, model . grid)
229
- c_scratch = CenterField (model. architecture, model . grid)
212
+ p = model. pressures . pHY′ + model . pressures . pNHS
213
+ w_scratch = ZFaceField (model. grid)
214
+ c_scratch = CenterField (model. grid)
230
215
231
216
primitive_statistics = first_through_second_order (model, b= b, p= p, w_scratch= w_scratch, c_scratch= c_scratch)
232
217
@@ -236,23 +221,26 @@ V = primitive_statistics[:v]
236
221
# Turbulent kinetic energy budget terms
237
222
238
223
e = TurbulentKineticEnergy (model, U= U, V= V)
239
- shear_production = ShearProduction (model, data = c_scratch . data , U= U, V= V)
240
- dissipation = ViscousDissipation (model, data = c_scratch . data )
224
+ shear_production = ZShearProduction (model, U= U, V= V)
225
+ dissipation = ViscousDissipation (model)
241
226
242
227
tke_budget_statistics = turbulent_kinetic_energy_budget (model, b= b, p= p, U= U, V= V, e= e,
243
228
shear_production= shear_production, dissipation= dissipation)
244
229
245
230
statistics_to_output = merge (primitive_statistics, tke_budget_statistics)
246
231
247
232
fields_to_output = merge (model. velocities, model. tracers,
248
- (νₑ= model. diffusivities. νₑ, e= e, sp= shear_production, ϵ= dissipation))
233
+ (νₑ = model. diffusivity_fields. νₑ,
234
+ e = Field (e),
235
+ sp = Field (shear_production),
236
+ ϵ = Field (dissipation)))
249
237
250
238
# Output configured for pickup
251
239
252
240
pickup = args[" pickup" ]
253
241
force = pickup ? false : true
254
242
255
- k_xy_slice = searchsortedfirst (grid. zF[:] , - slice_depth)
243
+ k_xy_slice = searchsortedfirst (znodes (Face, grid) , - slice_depth)
256
244
257
245
simulation. output_writers[:checkpointer ] =
258
246
Checkpointer (model, schedule = TimeInterval (26 hour), prefix = prefix * " _checkpointer" , dir = data_directory)
@@ -418,8 +406,9 @@ pressure_flux = statistics_file["timeseries/tke_pressure_flux/$last_iteration"][
418
406
419
407
close (statistics_file)
420
408
421
- pressure_flux_divergence = @. (pressure_flux[2 : end ] - pressure_flux[1 : end - 1 ]) ./ grid. Δz
422
- advective_flux_divergence = @. (advective_flux[2 : end ] - advective_flux[1 : end - 1 ]) ./ grid. Δz
409
+ Δz = grid. Δzᵃᵃᶜ
410
+ pressure_flux_divergence = @. (pressure_flux[2 : end ] - pressure_flux[1 : end - 1 ]) ./ Δz
411
+ advective_flux_divergence = @. (advective_flux[2 : end ] - advective_flux[1 : end - 1 ]) ./ Δz
423
412
424
413
tendency = @. - pressure_flux_divergence - advective_flux_divergence + shear_production + buoyancy_flux - dissipation
425
414
0 commit comments