Skip to content

Commit

Permalink
Put examples back
Browse files Browse the repository at this point in the history
  • Loading branch information
agdestein committed Dec 1, 2023
1 parent 7dd6b47 commit e16b2a5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
20 changes: 10 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ bib = CitationBibliography(joinpath(@__DIR__, "references.bib"))
examples = [
"Tutorial: Lid-Driven Cavity (2D)" => "LidDrivenCavity2D",
"Convergence: Taylor-Green Vortex (2D)" => "TaylorGreenVortex2D",
# "Unsteady inflow: Actuator (2D)" => "Actuator2D",
# # "Actuator (3D)" => "Actuator3D",
# "Walls: Backward Facing Step (2D)" => "BackwardFacingStep2D",
# # "Backward Facing Step (3D)" => "BackwardFacingStep3D",
# "Decaying Turbulunce (2D)" => "DecayingTurbulence2D",
# # "Decaying Turbulunce (3D)" => "DecayingTurbulence3D",
# # "Lid-Driven Cavity (3D)" => "LidDrivenCavity3D",
# "Planar Mixing (2D)" => "PlanarMixing2D",
# # "Shear Layer (2D)" => "ShearLayer2D",
# # "Taylor-Green Vortex (3D)" => "TaylorGreenVortex3D",
"Unsteady inflow: Actuator (2D)" => "Actuator2D",
# "Actuator (3D)" => "Actuator3D",
"Walls: Backward Facing Step (2D)" => "BackwardFacingStep2D",
# "Backward Facing Step (3D)" => "BackwardFacingStep3D",
"Decaying Turbulunce (2D)" => "DecayingTurbulence2D",
# "Decaying Turbulunce (3D)" => "DecayingTurbulence3D",
# "Lid-Driven Cavity (3D)" => "LidDrivenCavity3D",
"Planar Mixing (2D)" => "PlanarMixing2D",
# "Shear Layer (2D)" => "ShearLayer2D",
# "Taylor-Green Vortex (3D)" => "TaylorGreenVortex3D",
]

output = "generated"
Expand Down
4 changes: 2 additions & 2 deletions examples/BackwardFacingStep2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ plotgrid(x, y)
# Build setup and assemble operators
setup = Setup(x, y; Re, boundary_conditions, ArrayType);

pressure_solver = CGPressureSolver(setup);
pressure_solver = DirectPressureSolver(setup);

# Initial conditions (extend inflow)
u₀, p₀ =
Expand All @@ -69,7 +69,7 @@ u₀, p₀ =
## u, p = solve_steady_state(setup, u₀, p₀);

# Solve unsteady problem
u, p, outputs = solve_unsteady(
state, outputs = solve_unsteady(
setup,
u₀,
p₀,
Expand Down
2 changes: 1 addition & 1 deletion examples/PlanarMixing2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ boundary_conditions = (
(DirichletBC(U, dUdt), PressureBC()),

## y rear, y front
(SymmetricBC(), SymmetricBC()),
(PressureBC(), PressureBC()),
)

# A 2D grid is a Cartesian product of two vectors
Expand Down
43 changes: 21 additions & 22 deletions examples/PlaneJets2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,31 @@ u₀, p₀ = create_initial_conditions(
);

# Real time plot: Streamwise average and spectrum
function meanplot(; setup, state)
(; Ip) = setup.grid

umean = @lift begin
(; u, p, t) = $state
up = IncompressibleNavierStokes.interpolate_u_p(u, setup)
u1 = u[1]
reshape(sum(u1[Ip]; dims = 1), :) ./ size(u1, 1) ./ V()
function meanplot(state; setup)
(; xp, Iu, Ip, Nu, N) = setup.grid

umean = lift(state) do (; u, p, t)
reshape(sum(u[1][Iu[1]]; dims = 1), :) ./ Nu[1][1] ./ V()
end

K = size(Ip, 1) ÷ 2
K = Nu[1][2] ÷ 2
k = 1:(K-1)

# Find energy spectrum where y = 0
n₀ = size(Ip, 2) ÷ 2
E₀ = @lift begin
(; u, p, t) = $state
n₀ = findmin(abs, xp[2])[2]
E₀ = lift(state) do (; u, p, t)
u_y = u[1][:, n₀]
abs.(fft(u_y .^ 2))[k.+1]
end
y₀ = xp[2][n₀]

# Find energy spectrum where y = 1
n₁ = argmin(n -> abs(yin[n] .- 1), 1:Nuy_in)
E₁ = @lift begin
(; V, p, t) = $state
u = V[indu]
u_y = reshape(u, size(yu))[:, n₁]
n₁ = findmin(y -> abs(y - 1), xp[2])[2]
E₁ = lift(state) do (; u, p, t)
u_y = u[1][:, n₁]
abs.(fft(u_y .^ 2))[k.+1]
end
y₁ = xp[2][n₁]

fig = Figure()
ax = Axis(
Expand All @@ -142,7 +138,7 @@ function meanplot(; setup, state)
xlabel = "y",
ylabel = L"\langle u \rangle / U_0",
)
lines!(ax, yu[1, :], umean)
lines!(ax, xp[2][2:end-1], umean)
ax = Axis(
fig[1, 2];
title = "Streamwise energy spectrum",
Expand All @@ -153,11 +149,12 @@ function meanplot(; setup, state)
)
# ylims!(ax, (10^(0.0), 10^4.0))
ksub = k[10:end]
lines!(ax, ksub, 1000 .* ksub .^ (-3 / 5); label = L"k^{-3/5}")
# lines!(ax, ksub, 1000 .* ksub .^ (-5 / 3); label = L"k^{-5/3}")
lines!(ax, ksub, 1e7 .* ksub .^ -3; label = L"k^{-3}")
scatter!(ax, k, E₀; label = "y = $(yin[n₀])")
scatter!(ax, k, E₁; label = "y = $(yin[n₁])")
scatter!(ax, k, E₀; label = "y = $y₀")
scatter!(ax, k, E₁; label = "y = $y₁")
axislegend(ax; position = :lb)
# on(_ -> autolimits!(ax), E₁)

fig
end
Expand Down Expand Up @@ -199,8 +196,10 @@ save_vtk(setup, state.u, state.p, "$output/solution")
# Plot pressure
fieldplot(state; setup, fieldname = :pressure)

# Plot velocity
# Plot initial velocity
fieldplot((; u = u₀, p = p₀, t = T(0)); setup, fieldname = :velocity)

# Plot final velocity
fieldplot(state; setup, fieldname = :velocity)

# Plot vorticity
Expand Down

0 comments on commit e16b2a5

Please sign in to comment.