forked from agdestein/IncompressibleNavierStokes.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRayleighTaylor3D.jl
114 lines (101 loc) · 2.66 KB
/
RayleighTaylor3D.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# # Rayleigh-Taylor instability in 2D
#
# Two fluids with different temperatures start mixing.
#md using CairoMakie
using GLMakie #!md
using IncompressibleNavierStokes
# Hardware
ArrayType = Array
## using CUDA, CUDSS
## ArrayType = CuArray
# Precision
T = Float64
# Output directory
outdir = joinpath(@__DIR__, "output", "RayleighTaylor3D")
# Temperature equation
temperature = temperature_equation(;
Pr = T(0.71),
Ra = T(1e6),
Ge = T(1.0),
dodissipation = true,
boundary_conditions = (
(SymmetricBC(), SymmetricBC()),
(SymmetricBC(), SymmetricBC()),
(SymmetricBC(), SymmetricBC()),
),
gdir = 3,
nondim_type = 1,
)
# Setup
n = 80
x = LinRange(T(0), T(1), n + 1)
y = LinRange(T(0), T(1), n + 1)
z = LinRange(T(0), T(2), 2n + 1)
setup = Setup(
x,
y,
z;
boundary_conditions = (
(DirichletBC(), DirichletBC()),
(DirichletBC(), DirichletBC()),
(DirichletBC(), DirichletBC()),
),
Re = 1 / temperature.α1,
temperature,
ArrayType,
);
# This will factorize the Laplace matrix
@time psolver = psolver_direct(setup)
# Initial conditions
ustart = create_initial_conditions(setup, (dim, x, y, z) -> zero(x); psolver);
(; xp) = setup.grid;
xx = xp[1];
xy = reshape(xp[2], 1, :);
xz = reshape(xp[3], 1, 1, :);
tempstart = @. $(T(1)) * (1 + sin($(T(1.05 * π)) / 20 * xx) * sin($(T(π)) * xy) > xz);
fieldplot(
(; u = ustart, temp = tempstart, t = T(0));
## state;
setup,
levels = LinRange{T}(0.8, 1, 5),
## levels = LinRange(-T(5), T(1), 10),
## fieldname = :eig2field,
fieldname = :temperature,
size = (400, 600),
)
# Solve equation
state, outputs = solve_unsteady(;
setup,
ustart,
tempstart,
tlims = (T(0), T(40)),
Δt = T(1e-2),
psolver,
processors = (;
## anim = animator(;
## path = "$outdir/RT3D.mp4",
rtp = realtimeplotter(;
setup,
nupdate = 20,
fieldname = :eig2field,
levels = LinRange(-T(5), T(1), 10),
## fieldname = :temperature,
## levels = LinRange{T}(0, 1, 10),
size = (400, 600),
),
## vtk = vtk_writer(;
## setup,
## nupdate = 10,
## dir = outdir,
## fieldnames = (:velocity, :pressure, :temperature),
## psolver,
## ),
log = timelogger(; nupdate = 400),
),
);
# Check distribution of vortex structures
# for choosing plot levels
field = IncompressibleNavierStokes.eig2field(state.u, setup)[setup.grid.Ip]
hist(vec(Array(log.(max.(eps(T), .-field)))))
# Plot temperature field
fieldplot(state; setup, fieldname = :temperature)