Skip to content

Commit

Permalink
Drafting a lid-driven cavity verification
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ramadhan committed Oct 14, 2019
1 parent 2e24c2f commit 9b22bc9
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions examples/lid_driven_cavity.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Oceananigans, PyPlot, Printf
using Oceananigans: NoPenetrationBC, NonDimensionalModel

Nx, Ny, Nz = 1, 64, 64
Lx, Ly, Lz = 1, 1, 1

vbcs = ChannelBCs(top = BoundaryCondition(Value, 1),
bottom = BoundaryCondition(Value, 0),
north = NoPenetrationBC(),
south = NoPenetrationBC())

wbcs = ChannelBCs(top = NoPenetrationBC(),
bottom = NoPenetrationBC(),
north = BoundaryCondition(Value, 0),
south = BoundaryCondition(Value, 0))

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

Re = 400
model = NonDimensionalModel(N=(Nx, Ny, Nz), L=(Lx, Ly, Lz), Re=Re, Ri=0, Pr=Inf, Ro=Inf, boundary_conditions=bcs)

fig, ax = subplots(nrows=1, ncols=1, figsize=(10, 10))

螖t = 1e-3
= max(model.grid.螖y, model.grid.螖z)
CFL = 螖t /
dCFL = (1/Re) * 螖t /^2
@show CFL
@show dCFL

while model.clock.time < 5
time_step!(model; 螖t=螖t, Nt=100, init_with_euler=model.clock.time == 0 ? true : false)
@printf("Time: %.4f\n", model.clock.time)

y = collect(model.grid.yC)
z = collect(model.grid.zC)
v = model.velocities.v.data[1, :, :]
w = model.velocities.w.data[1, :, :]

螖y, 螖z = model.grid.螖y, model.grid.螖z
dvdz = (v[1:Ny, 2:Nz+1] - v[1:Ny, 1:Nz])/ 螖z
dwdy = (w[1:Ny, 1:Nz] - w[2:Ny+1, 1:Nz])/ 螖y
= dwdy - dvdz
= reverse(log10.(abs.(味)), dims=1)

# ax.streamplot(y, z, v, w)
pcolormesh(y, z, 味, vmin=1e-2, cmap="inferno")
# fig.colorbar(im, ax=ax)

ax.set_title(@sprintf("Time: %.4f", model.clock.time))
ax.set_xlabel("\$y\$"); ax.set_ylabel("\$z\$");
ax.set_xlim([0, 1]); ax.set_ylim([-1, 0]);
ax.set_aspect(1)
gcf();
end

0 comments on commit 9b22bc9

Please sign in to comment.