Monday, March 3, 2014

Data.Array.Accelerate And Katy Perry, Part II: Convection and Stencils

This time we'll take a really simple convection model (See e.g. Step 5 here) and use it to let our subject flow. We're using grayscale blackness as density and finding derivatives using a Stencil object and the simplest central difference approximation (naturally we can generalise this to higher orders without much difficulty by using a larger stencil and the new coefficients given in the link).

Starting from the same original image as  the previous post we obtain the following:
(The line used to produce the animation was $ convert -loop 0 lol1*1.bmp convect2.gif, with the 1*1 just matching every tenth frame so that the file isn't too big.)

Watch out for the filamentation on either side of Katy's head and the funny thing happening in the top left at the end. This is a pretty simple model, and I haven't been careful with making it make sense, but the dynamics are already starting to look interesting and with any luck we'll get something more realistic going in the next post.

Here's the code (takes a couple of seconds to run on my GeForce GTX 650 Ti, using much larger timesteps causes numerical errors, but it definitely could be made faster):



No comments:

Post a Comment