Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2039a97

Browse files
committedDec 14, 2019
Clean up lid-driven cavity and switch to vorticity computation
1 parent aa1ea98 commit 2039a97

File tree

1 file changed

+13
-46
lines changed

1 file changed

+13
-46
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using Oceananigans
21
using Plots, Printf
32

4-
using Oceananigans: NoPenetrationBC
3+
using Oceananigans
54
using Oceananigans.Diagnostics
5+
using Oceananigans.AbstractOperations
6+
7+
using Oceananigans: Face, Cell, NoPenetrationBC
68

79
# Workaround for plotting many frames.
810
# See: https://github.com/JuliaPlots/Plots.jl/issues/1723
@@ -40,29 +42,6 @@ wbcs = ChannelBCs(top = NoPenetrationBC(),
4042

4143
bcs = ChannelSolutionBCs(v=vbcs, w=wbcs)
4244

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-
6645
grid = RegularCartesianGrid(size=(Nx, Ny, Nz), x=(0, Lx), y=(0, Ly), z=(0, Lz))
6746

6847
Re = 100
@@ -73,10 +52,11 @@ model = NonDimensionalModel(grid=grid, Re=Re, Pr=Inf, Ro=Inf,
7352
nan_checker = NaNChecker(model; frequency=10, fields=Dict(:w => model.velocities.w))
7453
push!(model.diagnostics, nan_checker)
7554

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, ζ)
7859

79-
Δ = max(model.grid.Δy, model.grid.Δz)
8060

8161
y = collect(model.grid.yC)
8262
z = collect(model.grid.zC)
@@ -87,37 +67,24 @@ z = collect(model.grid.zC)
8767
wizard = TimeStepWizard(cfl=0.1, Δt=1e-6, max_change=1.1, max_Δt=1e-5)
8868
cfl = AdvectiveCFL(wizard)
8969

90-
v_top(t) = min(1, t)
91-
9270
while model.clock.time < 4e-3
9371
t = model.clock.time
9472

9573
update_Δt!(wizard, model)
9674

97-
model.boundary_conditions.solution.v.z.top = BoundaryCondition(Value, v_top(t))
98-
9975
time_step!(model; Δt=wizard.Δt, Nt=10, init_with_euler = t == 0 ? true : false)
10076

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)
10978

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)
11380
# heatmap!(p, y, z, interior(v)[1, :, :], color=:viridis, show=true)
11481

11582
v_max = maximum(abs, interior(v))
11683
w_max = maximum(abs, interior(w))
84+
ζ_max = maximum(abs, interior(ζ))
11785
CFL = cfl(model)
11886
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(ζ))
12187

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)
12390
end

0 commit comments

Comments
 (0)
Please sign in to comment.