1
- using Oceananigans
2
1
using Plots, Printf
3
2
4
- using Oceananigans: NoPenetrationBC
3
+ using Oceananigans
5
4
using Oceananigans. Diagnostics
5
+ using Oceananigans. AbstractOperations
6
+
7
+ using Oceananigans: Face, Cell, NoPenetrationBC
6
8
7
9
# Workaround for plotting many frames.
8
10
# See: https://github.com/JuliaPlots/Plots.jl/issues/1723
@@ -40,29 +42,6 @@ wbcs = ChannelBCs(top = NoPenetrationBC(),
40
42
41
43
bcs = ChannelSolutionBCs (v= vbcs, w= wbcs)
42
44
43
- # @inline Fv(i, j, k, grid, time, U, C, p) =
44
- # @inbounds ifelse(k == 1, - 2/grid.Δz^2 * U.v[i, j, 1], 0)
45
-
46
- @inline function Fv (i, j, k, grid, time, U, C, p)
47
- if k == 1
48
- return @inbounds - 2 / grid. Δz^ 2 * U. v[i, j, 1 ]
49
- else
50
- return 0
51
- end
52
- end
53
-
54
- @inline function Fw (i, j, k, grid, time, U, C, p)
55
- if j == 1
56
- return @inbounds - 2 / grid. Δy^ 2 * U. w[i, 1 , k]
57
- elseif j == grid. Ny
58
- return @inbounds - 2 / grid. Δy^ 2 * U. w[i, grid. Ny, k]
59
- else
60
- return 0
61
- end
62
- end
63
-
64
- forcing = ModelForcing (v= Fv, w= Fw)
65
-
66
45
grid = RegularCartesianGrid (size= (Nx, Ny, Nz), x= (0 , Lx), y= (0 , Ly), z= (0 , Lz))
67
46
68
47
Re = 100
@@ -73,10 +52,11 @@ model = NonDimensionalModel(grid=grid, Re=Re, Pr=Inf, Ro=Inf,
73
52
nan_checker = NaNChecker (model; frequency= 10 , fields= Dict (:w => model. velocities. w))
74
53
push! (model. diagnostics, nan_checker)
75
54
76
- ε (x, y, z) = 1e-2 * randn ()
77
- set! (model, v= ε, w= ε)
55
+ u, v, w = model. velocities
56
+ ζ_op = ∂y (w) - ∂z (v)
57
+ ζ = Field (Face, Face, Cell, model. architecture, model. grid)
58
+ ζ_comp = Computation (ζ_op, ζ)
78
59
79
- Δ = max (model. grid. Δy, model. grid. Δz)
80
60
81
61
y = collect (model. grid. yC)
82
62
z = collect (model. grid. zC)
@@ -87,37 +67,24 @@ z = collect(model.grid.zC)
87
67
wizard = TimeStepWizard (cfl= 0.1 , Δt= 1e-6 , max_change= 1.1 , max_Δt= 1e-5 )
88
68
cfl = AdvectiveCFL (wizard)
89
69
90
- v_top (t) = min (1 , t)
91
-
92
70
while model. clock. time < 4e-3
93
71
t = model. clock. time
94
72
95
73
update_Δt! (wizard, model)
96
74
97
- model. boundary_conditions. solution. v. z. top = BoundaryCondition (Value, v_top (t))
98
-
99
75
time_step! (model; Δt= wizard. Δt, Nt= 10 , init_with_euler = t == 0 ? true : false )
100
76
101
- v = model. velocities. v. data[1 , :, :]
102
- w = model. velocities. w. data[1 , :, :]
103
-
104
- Δy, Δz = model. grid. Δy, model. grid. Δz
105
- dvdz = (v[1 : Ny, 2 : Nz+ 1 ] - v[1 : Ny, 1 : Nz]) / Δz
106
- dwdy = (w[2 : Ny+ 1 , 1 : Nz] - w[1 : Ny, 1 : Nz]) / Δy
107
- ζ = dwdy - dvdz
108
- ζ = log10 .(abs .(ζ))
77
+ compute! (ζ_comp)
109
78
110
- u, v, w = model. velocities
111
-
112
- # heatmap!(p, y, z, ζ, color=:viridis, show=true)
79
+ # heatmap!(p, y, z, interior(ζ)[1, :, :], color=:viridis, show=true)
113
80
# heatmap!(p, y, z, interior(v)[1, :, :], color=:viridis, show=true)
114
81
115
82
v_max = maximum (abs, interior (v))
116
83
w_max = maximum (abs, interior (w))
84
+ ζ_max = maximum (abs, interior (ζ))
117
85
CFL = cfl (model)
118
86
dCFL = (1 / Re) * wizard. Δt / Δ^ 2
119
- @printf (" Time: %1.2e, Δt: %1.2e CFL: %1.2e, dCFL: %1.2e, max (v, w, ζ): %1.2e, %1.2e, %1.2e\n " ,
120
- model. clock. time, wizard. Δt, CFL, dCFL, v_max, w_max, 10 ^ maximum (ζ))
121
87
122
- @show model. boundary_conditions. solution. v. z. top. condition
88
+ @printf (" Time: %1.2e, Δt: %1.2e CFL: %1.2e, dCFL: %1.2e, max (v, w, ζ): %1.2e, %1.2e, %1.2e\n " ,
89
+ model. clock. time, wizard. Δt, CFL, dCFL, v_max, w_max, ζ_max)
123
90
end
0 commit comments