Swirl


Scalar advection problem with swirling velocity field.


Run code in serial mode (will work, even if code is compiled with MPI)


In [ ]:
!swirl

Or, run code in parallel mode (command may need to be customized, depending your on MPI installation.)


In [ ]:
!mpirun -n 4 swirl

Create PNG files for web-browser viewing, or animation.


In [ ]:
%run make_plots.py

View PNG files in browser, using URL above, or create an animation of all PNG files, using code below.


In [ ]:
%pylab inline

In [ ]:
import glob
from matplotlib import image
from clawpack.visclaw.JSAnimation import IPython_display
from matplotlib import animation

figno = 0
fname = '_plots/*fig' + str(figno) + '.png'
filenames=sorted(glob.glob(fname))

fig = plt.figure()
im = plt.imshow(image.imread(filenames[0]))
def init():
    im.set_data(image.imread(filenames[0]))
    return im,

def animate(i):
    image_i=image.imread(filenames[i])
    im.set_data(image_i)
    return im,

animation.FuncAnimation(fig, animate, init_func=init,
                              frames=len(filenames), interval=500, blit=True)