-
Notifications
You must be signed in to change notification settings - Fork 6
/
TwoD_Ellipse.jl
38 lines (33 loc) · 1.24 KB
/
TwoD_Ellipse.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
using WaterLily,StaticArrays
using ParametricBodies # New package
function make_sim(;L=64,Re=1e3,St=0.3,U=1,n=8,m=4,Λ=5,T=Float64,mem=Array)
# Map from simulation coordinate x to surface coordinate ξ
b = T(1/Λ); h₀=T(L÷4); ω=T(π*St*U/h₀)
ellipse(θ,t) = 0.5f0L*SA[1+cos(θ),b*sin(θ)] # define parametric curve
map(x,t) = x-SA[n*L÷4,m*L÷2-h₀*sin(ω*t)]
body = HashedBody(ellipse,(0,2π);T,map) # automatically finds closest point
# make a sim
Simulation((n*L,m*L),(U,0),L;ν=U*L/Re,body,T,mem)
end
using CUDA
include("viz.jl");
# set -up simulations time and time-step for ploting
sim = make_sim(;mem=Array,T=Float32)
t₀ = round(sim_time(sim))
duration = 10; tstep = 0.1
p,ν = [],[]
# run
@gif for tᵢ in range(t₀,t₀+duration;step=tstep)
# update until time tᵢ in the background
sim_step!(sim,tᵢ,remeasure=true)
# flood plot
get_omega!(sim);
plot_vorticity(sim.flow.σ, limit=10)
plot!(sim.body,WaterLily.time(sim))
push!(p,WaterLily.pressure_force(sim)[1])
push!(ν,WaterLily.viscous_force(sim)[1])
# print time step
println("tU/L=",round(tᵢ,digits=4),", Δt=",round(sim.flow.Δt[end],digits=3))
end
plot(p,label="Pressure force")
plot!(ν,label="Viscous force")