Decaying Homogeneous Isotropic Turbulence - 2D
In this example we consider decaying homogeneous isotropic turbulence, similar to the cases considered in [1] and [2]. The initial velocity field is created randomly, but with a specific energy spectrum. Due to viscous dissipation, the turbulent features eventually group to form larger visible eddies.
using CairoMakie
using IncompressibleNavierStokes
Output directory
output = "output/DecayingTurbulence2D"
"output/DecayingTurbulence2D"
Floating point precision
T = Float64
Float64
Array type
ArrayType = Array
# using CUDA; ArrayType = CuArray
# using AMDGPU; ArrayType = ROCArray
# using oneAPI; ArrayType = oneArray
# using Metal; ArrayType = MtlArray
Array
Viscosity model
Re = T(10_000)
10000.0
A 2D grid is a Cartesian product of two vectors
n = 256
lims = T(0), T(1)
x = LinRange(lims..., n + 1), LinRange(lims..., n + 1)
(LinRange{Float64}(0.0, 1.0, 257), LinRange{Float64}(0.0, 1.0, 257))
Build setup and assemble operators
setup = Setup(x...; Re, ArrayType);
Create random initial conditions
ustart = random_field(setup, T(0));
Solve unsteady problem
state, outputs = solve_unsteady(;
setup,
ustart,
tlims = (T(0), T(1)),
Δt = T(1e-3),
processors = (
# rtp = realtimeplotter(; setup, nupdate = 1),
ehist = realtimeplotter(;
setup,
plot = energy_history_plot,
nupdate = 10,
displayfig = false,
),
espec = realtimeplotter(; setup, plot = energy_spectrum_plot, nupdate = 10),
# anim = animator(; setup, path = "$output/solution.mkv", nupdate = 20),
# vtk = vtk_writer(; setup, nupdate = 10, dir = output, filename = "solution"),
# field = fieldsaver(; setup, nupdate = 10),
log = timelogger(; nupdate = 100),
),
);
Iteration 100 t = 0.1 Δt = 0.001 umax = 3.39444
Iteration 200 t = 0.2 Δt = 0.001 umax = 3.21724
Iteration 300 t = 0.3 Δt = 0.001 umax = 2.96
Iteration 400 t = 0.4 Δt = 0.001 umax = 2.73372
Iteration 500 t = 0.5 Δt = 0.001 umax = 2.98374
Iteration 600 t = 0.6 Δt = 0.001 umax = 2.78184
Iteration 700 t = 0.7 Δt = 0.001 umax = 2.78671
Iteration 800 t = 0.8 Δt = 0.001 umax = 3.32722
Iteration 900 t = 0.9 Δt = 0.001 umax = 3.37924
Iteration 1000 t = 1 Δt = 0.001 umax = 3.40912
Post-process
We may visualize or export the computed fields (u, p)
Energy history
outputs.ehist
Energy spectrum
outputs.espec
Export to VTK
save_vtk(setup, state.u, state.t, "$output/solution")
1-element Vector{String}:
"output/DecayingTurbulence2D/solution.vtr"
Plot field
fieldplot(state; setup)
This page was generated using Literate.jl.