-
Notifications
You must be signed in to change notification settings - Fork 195
/
velocity_and_tracer_tendencies.jl
236 lines (196 loc) · 9.91 KB
/
velocity_and_tracer_tendencies.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using Oceananigans.Advection
using Oceananigans.Buoyancy
using Oceananigans.Coriolis
using Oceananigans.Operators
using Oceananigans.StokesDrift
using Oceananigans.TurbulenceClosures: ∂ⱼ_2ν_Σ₁ⱼ, ∂ⱼ_2ν_Σ₂ⱼ, ∂ⱼ_2ν_Σ₃ⱼ, ∇_κ_∇c
"""
u_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
hydrostatic_pressure,
clock)
Return the tendency for the horizontal velocity in the x-direction, or the east-west
direction, ``u``, at grid point `i, j, k`.
The tendency for ``u`` is called ``G_u`` and defined via
``∂_t u = G_u - ∂_x ϕ_n``
where ∂_x ϕ_n is the non-hydrostatic pressure gradient in the x-direction.
`coriolis`, `stokes_drift`, and `closure` are types encoding information about Coriolis
forces, surface waves, and the prescribed turbulence closure.
`background_fields` is a `NamedTuple` containing background velocity and tracer
`FunctionFields`.
The arguments `velocities`, `tracers`, and `diffusivities` are `NamedTuple`s with the three
velocity components, tracer fields, and precalculated diffusivities where applicable.
`forcings` is a named tuple of forcing functions. `hydrostatic_pressure` is the hydrostatic
pressure anomaly.
`clock` keeps track of `clock.time` and `clock.iteration`.
"""
@inline function u_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
hydrostatic_pressure,
clock)
return ( - div_Uu(i, j, k, grid, advection, velocities, velocities.u)
- div_Uu(i, j, k, grid, advection, background_fields.velocities, velocities.u)
- div_Uu(i, j, k, grid, advection, velocities, background_fields.velocities.u)
- x_f_cross_U(i, j, k, grid, coriolis, velocities)
- ∂xᶠᵃᵃ(i, j, k, grid, hydrostatic_pressure)
+ ∂ⱼ_2ν_Σ₁ⱼ(i, j, k, grid, clock, closure, velocities, diffusivities)
+ x_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time)
+ ∂t_uˢ(i, j, k, grid, stokes_drift, clock.time)
+ forcings.u(i, j, k, grid, clock, merge(velocities, tracers)))
end
"""
v_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
hydrostatic_pressure,
clock)
Return the tendency for the horizontal velocity in the y-direction, or the north-south
direction, ``v``, at grid point `i, j, k`.
The tendency for ``v`` is called ``G_v`` and defined via
``∂_t v = G_v - ∂_y ϕ_n``
where ∂_y ϕ_n is the non-hydrostatic pressure gradient in the y-direction.
`coriolis`, `stokes_drift`, and `closure` are types encoding information about Coriolis
forces, surface waves, and the prescribed turbulence closure.
`background_fields` is a `NamedTuple` containing background velocity and tracer
`FunctionFields`.
The arguments `velocities`, `tracers`, and `diffusivities` are `NamedTuple`s with the three
velocity components, tracer fields, and precalculated diffusivities where applicable.
`forcings` is a named tuple of forcing functions. `hydrostatic_pressure` is the hydrostatic
pressure anomaly.
`clock` keeps track of `clock.time` and `clock.iteration`.
"""
@inline function v_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
hydrostatic_pressure,
clock)
return ( - div_Uv(i, j, k, grid, advection, velocities, velocities.v)
- div_Uv(i, j, k, grid, advection, background_fields.velocities, velocities.v)
- div_Uv(i, j, k, grid, advection, velocities, background_fields.velocities.v)
- y_f_cross_U(i, j, k, grid, coriolis, velocities)
- ∂yᵃᶠᵃ(i, j, k, grid, hydrostatic_pressure)
+ ∂ⱼ_2ν_Σ₂ⱼ(i, j, k, grid, clock, closure, velocities, diffusivities)
+ y_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time)
+ ∂t_vˢ(i, j, k, grid, stokes_drift, clock.time)
+ forcings.v(i, j, k, grid, clock, merge(velocities, tracers)))
end
"""
w_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
clock)
Return the tendency for the vertical velocity ``w`` at grid point `i, j, k`.
The tendency for ``w`` is called ``G_w`` and defined via
``∂_t w = G_w - ∂_z ϕ_n``
where ∂_z ϕ_n is the non-hydrostatic pressure gradient in the z-direction.
`coriolis`, `stokes_drift`, and `closure` are types encoding information about Coriolis
forces, surface waves, and the prescribed turbulence closure.
`background_fields` is a `NamedTuple` containing background velocity and tracer
`FunctionFields`.
The arguments `velocities`, `tracers`, and `diffusivities` are `NamedTuple`s with the three
velocity components, tracer fields, and precalculated diffusivities where applicable.
`forcings` is a named tuple of forcing functions.
`clock` keeps track of `clock.time` and `clock.iteration`.
"""
@inline function w_velocity_tendency(i, j, k, grid,
advection,
coriolis,
stokes_drift,
closure,
background_fields,
velocities,
tracers,
diffusivities,
forcings,
clock)
return ( - div_Uw(i, j, k, grid, advection, velocities, velocities.w)
- div_Uw(i, j, k, grid, advection, background_fields.velocities, velocities.w)
- div_Uw(i, j, k, grid, advection, velocities, background_fields.velocities.w)
- z_f_cross_U(i, j, k, grid, coriolis, velocities)
+ ∂ⱼ_2ν_Σ₃ⱼ(i, j, k, grid, clock, closure, velocities, diffusivities)
+ z_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time)
+ ∂t_wˢ(i, j, k, grid, stokes_drift, clock.time)
+ forcings.w(i, j, k, grid, clock, merge(velocities, tracers)))
end
"""
tracer_tendency(i, j, k, grid,
val_tracer_index::Val{tracer_index},
advection,
closure,
buoyancy,
background_fields,
velocities,
tracers,
diffusivities,
forcing,
clock)
Return the tendency for a tracer field with index `tracer_index`
at grid point `i, j, k`.
The tendency is called ``G_c`` and defined via
``∂_t c = G_c``
where `c = C[tracer_index]`.
`closure` and `buoyancy` are types encoding information about the prescribed
turbulence closure and buoyancy model.
`background_fields` is a `NamedTuple` containing background velocity and tracer
`FunctionFields`.
The arguments `velocities`, `tracers`, and `diffusivities` are `NamedTuple`s with the three
velocity components, tracer fields, and precalculated diffusivities where applicable.
`forcings` is a named tuple of forcing functions.
`clock` keeps track of `clock.time` and `clock.iteration`.
"""
@inline function tracer_tendency(i, j, k, grid,
val_tracer_index::Val{tracer_index},
advection,
closure,
buoyancy,
background_fields,
velocities,
tracers,
diffusivities,
forcing,
clock) where tracer_index
@inbounds c = tracers[tracer_index]
@inbounds background_fields_c = background_fields.tracers[tracer_index]
return ( - div_Uc(i, j, k, grid, advection, velocities, c)
- div_Uc(i, j, k, grid, advection, background_fields.velocities, c)
- div_Uc(i, j, k, grid, advection, velocities, background_fields_c)
+ ∇_κ_∇c(i, j, k, grid, clock, closure, c, val_tracer_index, diffusivities, tracers, buoyancy)
+ forcing(i, j, k, grid, clock, merge(velocities, tracers)))
end