-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathKolmogorov2D.jl
84 lines (72 loc) · 1.66 KB
/
Kolmogorov2D.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# # Kolmogorov flow (2D)
#
# The Kolmogorov flow in a periodic box ``\Omega = [0, 1]^2`` is initiated
# via the force field
#
# ```math
# f(x, y) =
# \begin{pmatrix}
# \sin(\pi k y) \\
# 0
# \end{pmatrix}
# ```
#
# where `k` is the wavenumber where energy is injected.
# ## Packages
#
# We just need the `IncompressibleNavierStokes` and a Makie plotting package.
#md using CairoMakie
using GLMakie #!md
using IncompressibleNavierStokes
# ## Setup
#
# Define a uniform grid with a steady body force field.
n = 256
axis = range(0.0, 1.0, n + 1)
setup = Setup(;
x = (axis, axis),
Re = 2e3,
bodyforce = (dim, x, y, t) -> (dim == 1) * 5 * sinpi(8 * y),
issteadybodyforce = true,
);
ustart = random_field(setup, 0.0; A = 1e-2);
# ## Plot body force
#
# Since the force is steady, it is just stored as a field.
heatmap(setup.bodyforce[:, :, 1])
# ## Solve unsteady problem
state, outputs = solve_unsteady(;
setup,
ustart,
tlims = (0.0, 2.0),
Δt = 1e-3,
processors = (
rtp = realtimeplotter(; setup, nupdate = 100),
ehist = realtimeplotter(;
setup,
plot = energy_history_plot,
nupdate = 10,
displayfig = false,
),
espec = realtimeplotter(;
setup,
plot = energy_spectrum_plot,
nupdate = 10,
displayfig = false,
),
log = timelogger(; nupdate = 100),
),
);
# Field plot
outputs.rtp
# Energy history
outputs.ehist
# Energy spectrum
outputs.espec
#md # ## Copy-pasteable code
#md #
#md # Below is the full code for this example stripped of comments and output.
#md #
#md # ```julia
#md # CODE_CONTENT
#md # ```