Asynchronous Makie

For @tyfdzt: here are the basic components extracted from my code with Makie streamplots.
Note that it is not a MWE. I hope it can help you. If not I can try to write a MWE.

#The Cartesian axis :
x = range(0,stop=lx,length=nx+1); hx = lx/nx;
y = range(0,stop=ly,length=ny+1); hy = ly/ny;
#Arrays for x and y velocity arrays that evolve via CFD simulation
Ue=zeros(nx+2,ny+2)
Ve=zeros(nx+2,ny+2)
.....
#Declare a Makie Node (once) for storing velocity arrays
uvn=Node([rand(size(Ue)...),rand(size(Ve)...)])
.....
#Update the velocity uvn Node for each video frames
# Note that this is not done for each time steps but only for each video frames
push!(uvn,copy!(to_value(uvn),[Ue,Ve]))
.....
#Helper function : the Makie streamplot! function take a function 
# for its first argument (not an array)
function make_velocity(uv)
     f_vx=interpolate(uv[1],BSpline(Quadratic(Reflect(OnCell()))))
     f_vy=interpolate(uv[2],BSpline(Quadratic(Reflect(OnCell()))))
  function velocity(x,y)
     nx,ny=size(uv[1])
     xi=1+x*(nx-1)
     yi=1+y*(ny-1)
     Point2f0(f_vx(xi,yi),f_vy(xi,yi))
  end
  return velocity
end

# The call to the Makie streamplot! function : 
#      this function is called each time the uvn Node is updated 
streamplot!(scene,lift(a->make_velocity(to_value(a)),uvn),
       x,y, colormap = :magma, arrow_size=0.02, gridsize=(20,20))

Let me know if this helps.

1 Like