-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTaylorGreenVortex3D.jl
77 lines (64 loc) · 1.79 KB
/
TaylorGreenVortex3D.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
# # Taylor-Green vortex - 3D
#
# In this example we consider the Taylor-Green vortex.
#md using CairoMakie
using GLMakie #!md
using IncompressibleNavierStokes
# Floating point precision
T = Float64
# ## Backend
#
# Running in 3D is heavier than in 2D.
# If you are running this on a CPU, consider using multiple threads by
# starting Julia with `julia -t auto`, or
# add `"julia.NumThreads": "auto"` to the settings in VSCode.
backend = CPU()
## using CUDA; backend = CUDABackend()
# ## Setup
n = 32
r = range(T(0), T(1), n + 1)
setup = Setup(; x = (r, r, r), Re = T(1e3), backend);
psolver = psolver_spectral(setup);
# Initial conditions
U(dim, x, y, z) =
if dim == 1
sinpi(2x) * cospi(2y) * sinpi(2z) / 2
elseif dim == 2
-cospi(2x) * sinpi(2y) * sinpi(2z) / 2
else
zero(x)
end
ustart = velocityfield(setup, U, psolver);
# ## Solve unsteady problem
state, outputs = solve_unsteady(;
setup,
ustart,
tlims = (T(0), T(1.0)),
Δt = T(1e-3),
processors = (
## rtp = realtimeplotter(; setup, plot = fieldplot, nupdate = 10),
ehist = realtimeplotter(;
setup,
plot = energy_history_plot,
nupdate = 1,
displayfig = false,
),
espec = realtimeplotter(; setup, plot = energy_spectrum_plot, nupdate = 10),
## anim = animator(; setup, path = "$outdir/solution.mkv", nupdate = 20),
## vtk = vtk_writer(; setup, nupdate = 10, dir = outdir, filename = "solution"),
log = timelogger(; nupdate = 100),
),
psolver,
);
# ## Post-process
# 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 # ```