-
Notifications
You must be signed in to change notification settings - Fork 13
/
Actuator3D.jl
106 lines (88 loc) · 3.04 KB
/
Actuator3D.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
# # Unsteady actuator case - 3D
#
# In this example, an unsteady inlet velocity profile at encounters a wind
# turbine blade in a wall-less domain. The blade is modeled as a uniform body
# force on a short cylinder.
# We start by loading packages.
# A [Makie](https://github.com/JuliaPlots/Makie.jl) plotting backend is needed
# for plotting. `GLMakie` creates an interactive window (useful for real-time
# plotting), but does not work when building this example on GitHub.
# `CairoMakie` makes high-quality static vector-graphics plots.
#md using CairoMakie
using GLMakie #!md
using IncompressibleNavierStokes
# Output directory
outdir = joinpath(@__DIR__, "output", "Actuator3D")
# Floating point type
T = Float64
# Backend
backend = CPU()
## using CUDA; backend = CUDABackend()
# Reynolds number
Re = T(100)
# A 3D grid is a Cartesian product of three vectors
x = LinRange(0.0, 6.0, 31), LinRange(-2.0, 2.0, 41), LinRange(-2.0, 2.0, 41)
plotgrid(x...)
# Boundary conditions: Unsteady BC requires time derivatives
boundary_conditions = (
## x left, x right
(
DirichletBC(
(dim, x, y, z, t) ->
dim == 1 ? cos(π / 6 * sin(π / 6 * t)) :
dim == 2 ? sin(π / 6 * sin(π / 6 * t)) : zero(x),
),
PressureBC(),
),
## y rear, y front
(PressureBC(), PressureBC()),
## z rear, z front
(PressureBC(), PressureBC()),
)
# Actuator body force: A thrust coefficient `Cₜ` distributed over a short cylinder
cx, cy, cz = T(2), T(0), T(0) # Disk center
D = T(1) # Disk diameter
δ = T(0.11) # Disk thickness
Cₜ = T(0.2) # Thrust coefficient
cₜ = Cₜ / (π * (D / 2)^2 * δ)
inside(x, y, z) = abs(x - cx) ≤ δ / 2 && (y - cy)^2 + (z - cz)^2 ≤ (D / 2)^2
bodyforce(dim, x, y, z) = dim == 1 ? -cₜ * inside(x, y, z) : zero(x)
# Build setup and assemble operators
setup = Setup(; x, Re, boundary_conditions, bodyforce, backend);
# Initial conditions (extend inflow)
ustart = velocityfield(setup, (dim, x, y, z) -> dim == 1 ? one(x) : zero(x));
# Solve unsteady problem
(; u, t), outputs = solve_unsteady(;
setup,
ustart,
tlims = (T(0), T(3)),
method = RKMethods.RK44P2(),
Δt = T(0.05),
processors = (
rtp = realtimeplotter(;
setup,
plot = fieldplot,
## plot = energy_history_plot,
## plot = energy_spectrum_plot,
nupdate = 1,
),
## anim = animator(; setup, path = "$outdir/vorticity.mkv", nupdate = 20),
## vtk = vtk_writer(; setup, nupdate = 10, dir = "$outdir", filename = "solution"),
## field = fieldsaver(; setup, nupdate = 10),
log = timelogger(; nupdate = 1),
),
);
# ## Post-process
#
# We may visualize or export the computed fields `(V, p)`
# Field plot
outputs.rtp
# Export to VTK
save_vtk(state; setup, filename = joinpath(outdir, "solution"))
#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 # ```