Making GIF/AVI Animations for ANSYS FLUENT Users

The Colorful Fluid Mixing Gallery

This document describes how to make GIF/AVI animations from model calculations done with the ANSYS FLUENT computational fluid dynamics software from ANSYS, Inc. The instructions are based on FLUENT 6, but are still applicable to the newer versions (R12 and higher). Of course, you may also consider using ANSYS CFD-Post.

GIF animations are a standard format used on the Internet and can be viewed from a web browser. This makes them cross-platform and easily usable and accessible. GIF animations consist of a series of 256 color images, concatenated into an animation file. AVI files are more suited for use with PowerPoint.

I. The first step is to create the images to be animated.

To do this, after reading the case and data file into FLUENT, we need to set the hardcopy options under File - Hardcopy as follows:

Click Apply and Close after having set these options.

For time dependent calculations using FLUENT, we can save flow field images at every time step using the Solve - Monitor - Command option (FLUENT 5) or the Solve - Execute Commands option (FLUENT 6). Before iterating set all the display and hardcopy options. Then, have the code plot the flow field and save a TIF raster file every time step, as shown in the panel below.

The first, reset-graphics, command is optional.

With the second command we select the surface on which we want to plot the flow field. Replace 'mysurfcename' with the name of your own surface.

With the third command we have contours of velocity magnitude from 0 to 20 m/s plotted on this surface. You can replace this command with your own graphics plotting command.

With the fourth command we restore the view that we want. Replace 'front' with the name of your own view.

The fifth command saves the flow field image to a file. The %t option adds the time step number to the file name (%i would add the iteration number, and %n the number of hard-copy files saved so-far).

Obviously, additional commands can be added, to save the flow field in multiple views or slices.

The nice thing is that a time dependent calculation can be run and the animation created, without having to save the flow field data. This is especially helpful for large 3-D simulations, e.g. with LES. Alternatively, this method can be used to show how a steady state simulation converges.

For an animation based on a steady state flow field, the Display - Animate option can also be used. After creating the animation sequence set the Write/Record Format option to Hardcopy Frames when playing the animation. Set the Hardcopy Options to TIF files.

II. Convert the individual TIF files to individual GIF files.

* This step is not necessary if you choose to use QuickTime Pro to create an AVI animation; which is what I would recommend if you want to have a small animation file and use the animation with PowerPoint.

* On Unix workstations and Windows PCs that have ImageMagick from installed this can be done with the

mogrify -format gif *.tif

command. If mogrify gives an error message saying that it doesn't recognize the '-format' option, it most likely means that you have an old version of ImageMagick installed. I noticed that there are still quite a lot of five year old copies floating around. You will have to download the latest version and install it.

Note: Most Unix distributions of Fluent include ImageMagick (in the contrib directory), but the Windows version does not. A Windows version of ImageMagick does exist, however, and can be downloaded from the ImageMagick Internet site. Also, there may be newer versions of ImageMagick on the ImageMagick website than what is included on the Fluent CD. In that case, you may want to download the latest version. Also, if you rely on the ImageMagick distributions coming on the Fluent Unix CD, and (1) are working on a Unix platform other than a SUN, (2) get error messages when executing this command, and (3) have access to a SUN; you can try to run it on the SUN, which comes with a more up to date version of ImageMagick.

* Windows users who do not have ImageMagick or prefer to use a program with a graphical user interface should use IrfanView or PaintShop Pro. Both of these programs have a format batch conversion option under the File - Batch Conversion menu command. Use that menu command to convert a group of files in one step, without having to read, convert, and save many files manually.

III. Create the animation file from the individual images.

* QuickTime Pro users can use the File - Open Image Sequence command to read the images. They can export the animation in their desired format with the File - Export command. It requires your image sequences to be sequentially numbered. If your images are not correctly numbered, you can first renumber them using the batch rename feature of IrfanView.

* On Unix workstations and Windows PCs that have ImageMagick installed this can be done with the

convert -adjoin -delay 5 *.gif animation-name.gif

command. The file animation-name.gif can be viewed in a web browser. The "-delay 5" command sets the delay between the images to 5/100 second. This number can be changed to obtain the required playback speed. If convert gives an error message saying that it doesn't recognize the '-adjoin' option, it most likely means that you have an old version of ImageMagick installed. Also, some Unix systems now have a built in convert command to convert audio files. Make sure that you are using the ImageMagick convert command, and not the Unix convert command. If you don't get anywhere with Unix, just find a PC and use IrfanView and GIF Construction Set or QuickTime Pro!

* Windows users who do not have ImageMagick or prefer to use a program with a graphical user interface should use the GIF Construction Set Professional (shareware, free test version) from The Animation Wizard under the File menu will guide you through the steps.


* QuickTime Pro (for which you have to pay) is a nice tool to convert image sequences to any kind of animation format (GIF, AVI, MOV, etc.). I really like it and it is worth the money. I would recommend this program to convert your TIF image series to AVI. It requires your image sequences to be sequentially numbered. If your images are not correctly numbered, you can renumber them using the batch rename feature of IrfanView.

* The GIF Construction Set Professional from Alchemy Mindworks can also convert the GIF animations to AVI format and vice-versa. Make sure that the File|Settings|Files|AVI-Quality-Factor is set to 8500 instead of to the default value of 7500, which leads to a lower image quality. Read in the GIF animation. Save it as AVI using the File|Movie|Gif-to-Movie command. Test the AVI file by playing it with the Windows media player. If your GIF animation was created with ImageMagick, color flickering may occur in the AVI file. If this happens you need to first recreate your GIF animation with the GIF Construction Set. To do this, read in the GIF animation; select all blocks/images; save the individual images to the harddisk using the Block|Extract command; recreate the GIF animation using the File|Animation-Wizard command; and save it as an AVI file using the File|Movie|Gif-to-Movie command.

* If the TIF files have many different colors, the number of colors will be reduced to 256. This may sometimes lead to color shifting. On the PC, IrfanView, Paintshop Pro, and the GIF Construction Set Professional all have settings on how to handle the color reduction. One may have to try various options to obtain the best results. This is usually only a problem when lighting and shading are on in Fluent 5. When lighting is off, the number of colors is usually less than 256, and color shifting will not occur. If you work from TIF files created by Fluent, good results can often be obtained by first converting the files to 16 million color BMP files with IrfanView, and then creating the animation using the PhotoRealistic setting in the Gif Construction Set.

* Cropping: the mogrify command can also crop your images. Say for example, that you saved your images at 1024x768 resolution, and want to crop of the Fluent captions:

mogrify -crop 808x660+166+2 -format gif *.tif

will crop the images to 808 pixels wide, 660 pixels high, with x- and y-offsets of 166 and 2 pixels respectively, while converting the tif files to gif format. If you just execute:

mogrify -crop 808x660+166+2 *.tif

it will overwrite your existing tif files, with the cropped tif files. Obviously, you can replace these numbers with any width, height, or offset you want.

* Some people have asked me for command line tools for Windows to convert image sequences to AVI files. Check out BMP2AVI for this. It requires the raster images to be in BMP format. You can use ImageMagick to do this conversion. If you are handy, you can use the combination of BMP2AVI and ImageMagick to create batch scripts to do all this automatically.

* For really handy C-programmers who are used to compiling C-code they download from the Web, you can download Im2AVI to convert image sequences to AVI under Linux. This is not for the faint of heart though!

* GIF animations created with ImageMagic can suffer from a number of problems, such as color flickering, excessively large filesize, and others. If you run into problems like that, you are better of obtaining the Gif Construction Set or MainActor on the PC and remaking your animations with those programs.

* The Unix ImageMagick commands work faster and are more convenient than the PC programs with the graphical user interfaces. However, the animations themselves end up being of a larger size. One animation made with the PC programs was 7MB in size, and the same animation made with the Unix programs was 85MB. Also, I noticed that when many images (~200) are used, the Unix commands sometimes lead to an animation with a periodic flicker, which was not seen in the animations that were created on the PC with the GIF Construction Set Professional. The cause of this is unclear, maybe it is just the size of the file that causes problems while viewing. Animations with fewer images may not have that problem.

* On Unix workstations that have ImageMagick installed, one can use the

animate *tif

command to show an animation of all TIF files in the working directory. This is useful if one wants to check which files have been saved and how the animation will look, before starting the process of creating the GIF animation. The 'animate' command, however, does not create animations that can be shared with other users.

Return to Graphics Tips

Return to Table of Contents

Last Updated February 20, 2012 by André Bakker
© André Bakker 2000-2012