LoadError: MethodError: no method matching record in ThreeD_donut although another package (ThreeD_TaylorGreenVortex) with “record” works
maeckha opened this issue · comments
Markus Eckhardt commented
First package
using WaterLily
using LinearAlgebra: norm2
using Makie
function donut_sim(p=6,Re=1e3)
# Define simulation size, velocity, viscosity
n,U = 2^p, [1, 0, 0]
center,R,r = [n/2,n/2,n/2], n/4, n/16
ν = norm2(U)*R/Re
# Apply signed distance function for a torus
c = BDIM_coef(2n+2,n+2,n+2,3) do xyz #
x,y,z = xyz - center
norm2([x,norm2([y,z])-R])-r
end
# Initialize Flow, Poisson and make struct
u = zeros(2n+2,n+2,n+2,3)
a = Flow(u,c,U,ν=ν)
b = MultiLevelPoisson(c)
Simulation(norm2(U),R,a,b),center
end
function flowdata(sim)
@inside sim.flow.σ[I] = WaterLily.ω_θ(I,[1,0,0],center,sim.flow.u)*sim.L/sim.U
@view sim.flow.σ[2:end-1,2:end-1,2:end-1]
end
function geomdata(sim)
@inside sim.flow.σ[I] = sum(sim.flow.μ₀[I,i]+sim.flow.μ₀[I+δ(i,I),i] for i=1:3)
@view sim.flow.σ[2:end-1,2:end-1,2:end-1]
end
function make_video!(sim::Simulation;name="file.mp4",verbose=true,t₀=0.0,Δprint=0.1,nprint=24*3)
# plot the geometry and flow
scene = contour(geomdata(sim),levels=[0.5])
scene = contour!(scene,flowdata(sim),levels=[-7,7],
colormap=:balance,alpha=0.2,colorrange=[-7,7])
scene_data = scene[end]
# Plot flow evolution
tprint = t₀+WaterLily.sim_time(sim)
record(scene,name,1:nprint,compression=5) do i
tprint+=Δprint
sim_step!(sim,tprint;verbose)
println("video ",round(Int,i*100/nprint),"% complete")
scene_data[1] = flowdata(sim)
end
return scene
end
donut,center = donut_sim();
scene = make_video!(donut);
Second Package:
using WaterLily
using LinearAlgebra: norm2
using Makie
function flowdata(sim)
@inside sim.flow.σ[I] = WaterLily.ω_mag(I,sim.flow.u)*sim.L/sim.U
return @view sim.flow.σ[2:end-1,2:end-1,2:end-1]
end
function TGV_video(p=6,Re=1e5,Δprint=0.1,nprint=100)
# Define vortex size, velocity, viscosity
L = 2^p; U = 1; ν = U*L/Re
# Taylor-Green-Vortex initial velocity field
u = apply(L+2,L+2,L+2,3) do i,vx
x,y,z = @. (vx-1.5)*π/L # scaled coordinates
i==1 && return -U*sin(x)*cos(y)*cos(z) # u_x
i==2 && return U*cos(x)*sin(y)*cos(z) # u_y
return 0. # u_z
end
# Initialize simulation
c = ones(L+2,L+2,L+2,3) # no immersed solids
a = Flow(u,c,zeros(3),ν=ν)
b = MultiLevelPoisson(c)
sim = Simulation(U,L,a,b)
# plot the vorticity modulus
scene = Scene(backgroundcolor = :black)
scene = volume!(scene,flowdata(sim),colorrange=(π,4π),algorithm = :absorption)
vol_plot = scene[end]
# Plot flow evolution
tprint = 0.0
record(scene,"file.mp4",1:nprint,framerate=24,compression=5) do i
tprint += Δprint
sim_step!(sim,tprint)
println("video ",round(Int,i/nprint*100),"% complete")
vol_plot[1] = flowdata(sim)
end
return sim,scene
end
The first package throws the error concerning the record method, the second package does fine and has the record method as well.
ERROR: LoadError: MethodError: no method matching record(::var"#134#135"{Bool,Float64,Int64,Simulation,Contour{...}}, ::Scene, ::String, ::UnitRange{Int64}; compression=5)
Closest candidates are:
record(::Any, ::Any, ::Any, ::Any; framerate) at /home/meck/.julia/packages/AbstractPlotting/rWoon/src/display.jl:463 got unsupported keyword argument "compression"
record(::Any, ::Any, ::Any; framerate) at /home/meck/.julia/packages/AbstractPlotting/rWoon/src/display.jl:443 got unsupported keyword argument "compression"
Stacktrace:
[1] kwerr(::NamedTuple{(:compression,),Tuple{Int64}}, ::Function, ::Function, ::Scene, ::String, ::UnitRange{Int64}) at ./error.jl:157
[2] make_video!(::Simulation; name::String, verbose::Bool, t₀::Float64, Δprint::Float64, nprint::Int64) at /home/meck/Documents/Bachelor Arbeit/WaterLily/examples/ThreeD_donut.jl:42
[3] make_video!(::Simulation) at /home/meck/Documents/Bachelor Arbeit/WaterLily/examples/ThreeD_donut.jl:35
[4] top-level scope at /home/meck/Documents/Bachelor Arbeit/WaterLily/examples/ThreeD_donut.jl:52
in expression starting at /home/meck/Documents/Bachelor Arbeit/WaterLily/examples/ThreeD_donut.jl:52
I am confused because those functions reside in the same folder.
Gabriel Weymouth commented
Sorry for sleeping on this for so long, I was working on a big code fix. Makie has changed substantially in the last months and the 3D examples were both out of date. I've fixed those now and tested both and had no problems.
Please pull the latest version and try it out.