diff --git a/examples/TwoD_MultipleBodies.jl b/examples/TwoD_MultipleBodies.jl deleted file mode 100644 index 67791c6..0000000 --- a/examples/TwoD_MultipleBodies.jl +++ /dev/null @@ -1,26 +0,0 @@ -using WaterLily -using StaticArrays - -function circle(n,m;Re=550,U=1,mem=Array,T=Float32) - radius, center = m/16, m/2+1 - # first circle - body1 = AutoBody((x,t)->√sum(abs2, x .- center) - radius) - # second circle 1.5 units to the right - body2 = AutoBody((x,t)->√sum(abs2, x .- SA[1.5center,center]) - radius) - body = Bodies([body1,body2], [+]) # I want to add them together - Simulation((n,m), (U,0), radius; ν=U*radius/Re, body, mem, T) -end -using CUDA - - -include("TwoD_plots.jl") -sim = circle(3*2^7,2^8,mem=CUDA.CuArray) -sim_gif!(sim,duration=10,clims=(-5,5),plotbody=true) - -# # get force on first body -# f1 = WaterLily.∮nds(sim.flow.p,sim.body.bodies[1],WaterLily.time(sim)) -# flood(sim.flow.f[:,:,1],clims=(-1,1)) # check that this is only non-zero near the first body - -# # force on the second -# f2 = WaterLily.∮nds(sim.flow.p,sim.body.bodies[2],WaterLily.time(sim)) -# flood(sim.flow.f[:,:,1],clims=(-1,1)) # check that this is only non-zero near the first body diff --git a/examples/TwoD_Square.jl b/examples/TwoD_Square.jl deleted file mode 100644 index 2845232..0000000 --- a/examples/TwoD_Square.jl +++ /dev/null @@ -1,50 +0,0 @@ -using WaterLily -using StaticArrays -using Plots - -function make_sim(;L=2^5,U=1,Re=250,mem=Array) - - # plane sdf - function plane(x,t,center,normal) - normal = normal/√sum(abs2,normal) - sum((x .- center).*normal) - end - map(x,t) = x-SA[2L,2L] - - # multiple bodies - body = AutoBody((x,t)->plane(x,t,SA[-L/2,0],SA[-1, 0]),map) ∩ - AutoBody((x,t)->plane(x,t,SA[ 0,L/2],SA[ 0, 1]),map) ∩ - AutoBody((x,t)->plane(x,t,SA[L/2, 0],SA[ 1, 0]),map) ∩ - AutoBody((x,t)->plane(x,t,SA[0,-L/2],SA[ 0,-1]),map) - - # make a simulation - Simulation((8L,4L),(U,0),L;U,ν=U*L/Re,body,T=Float64,mem) -end - - -# intialize -sim = make_sim()#mem=CuArray); -t₀,duration,tstep = sim_time(sim),10,0.1; - -# run -anim = @animate for tᵢ in range(t₀,t₀+duration;step=tstep) - - # update until time tᵢ in the background - t = sum(sim.flow.Δt[1:end-1]) - while t < tᵢ*sim.L/sim.U - measure!(sim,t) - mom_step!(sim.flow,sim.pois) # evolve Flow - t += sim.flow.Δt[end] - end - - # flood plot - @inside sim.flow.σ[I] = WaterLily.curl(3,I,sim.flow.u) * sim.L / sim.U - contourf(clamp.(sim.flow.σ,-10,10)',dpi=300, - color=palette(:RdBu_11), clims=(-10,10), linewidth=0, - aspect_ratio=:equal, legend=false, border=:none) - - # print time step - println("tU/L=",round(tᵢ,digits=4),", Δt=",round(sim.flow.Δt[end],digits=3)) -end -# save gif -gif(anim, "/tmp/tmp.gif", fps=24) \ No newline at end of file diff --git a/examples/TwoD_Triangle.jl b/examples/TwoD_Triangle.jl deleted file mode 100644 index bc3e511..0000000 --- a/examples/TwoD_Triangle.jl +++ /dev/null @@ -1,52 +0,0 @@ -using WaterLily -using StaticArrays -using Plots - -norm(x) = √sum(abs2,x) -function make_sim(;L=2^5,U=1,Re=250,mem=Array) - - # triangle sdf - function triangle(p,t) - r,k = L/2,sqrt(3.0) - x = abs(p[1]) - r - y = p[2] + r/k - p = SA[clamp(x,-2r,2),y] - if x+k*y>0.0 - p = SA[clamp(x-k*y,-2r,2),-k*x-y]./2.0 - end - return -norm(p)*sign(p[2]) - end - map(x,t) = x-SA[2L,2L] - body = AutoBody(triangle,map) - - # make a simulation - Simulation((8L,4L),(U,0),L;U,ν=U*L/Re,body,T=Float64,mem) -end - - -# intialize -sim = make_sim()#mem=CuArray); -t₀,duration,tstep = sim_time(sim),10,0.1; - -# run -anim = @animate for tᵢ in range(t₀,t₀+duration;step=tstep) - - # update until time tᵢ in the background - t = sum(sim.flow.Δt[1:end-1]) - while t < tᵢ*sim.L/sim.U - measure!(sim,t) - mom_step!(sim.flow,sim.pois) # evolve Flow - t += sim.flow.Δt[end] - end - - # flood plot - @inside sim.flow.σ[I] = WaterLily.curl(3,I,sim.flow.u) * sim.L / sim.U - contourf(clamp.(sim.flow.σ,-10,10)',dpi=300, - color=palette(:RdBu_11), clims=(-10,10), linewidth=0, - aspect_ratio=:equal, legend=false, border=:none) - - # print time step - println("tU/L=",round(tᵢ,digits=4),", Δt=",round(sim.flow.Δt[end],digits=3)) -end -# save gif -gif(anim, "/tmp/tmp.gif", fps=24) \ No newline at end of file