some frames of an animation

Animating the Evolution of a Field

Brought to you by
John B. Schneider, Patrick J. Flynn, and Kurt L. Shlager

Overview

As described in the paper entitled "Animating the Evolution of a Field" submitted to the IEEE Antennas and Propagation Magazine, there is a relatively simple way to produce an animation of a varying two-dimension field. If you have not seen this paper, please read it before going any further! You can download the paper as a compressed PostScript file, or you can read the on-line HTML version. (Note that there are a few color pictures in the paper so it may be helpful to have access to a color printer if you plan to print the PostScript file.) At a minimum, you should skim the paper for the basic approach.

Links to source code, shell scripts, parameter files, etc., are provided in this and a related page. You can grab these files as needed, or you can download everything as one compressed tar file by clicking here.

Sample Output

Two sets of sample output are provided. The first set pertains to the FDTD solution of a line source in the vicinity of a perfectly conducting circular cylinder. The FDTD code to run the simulation is provided. The second set corresponds to the example discussed in the paper (follow this link if you want more details about this scattering problem).
Sample set 1. Line source near a cylinder. Links to MPEG encoder "parameter" files provided with this set. (Examples include relatively small MPEG files.)
Sample set 2. Pulsed plane wave illumination of a rectangular scatterer with slots. (Examples include large MPEG files.)

Source Code

A subroutine to generate appropriate raw files: wrtraw.f.

This subroutine, or one that similarly generates output, should be incorporated into existing code as described in the paper. This routine uses nested DO loops to write to a direct access file. Some compilers do this very inefficiently. Alternatively, the same thing can be accomplished using a single, insanely large, write statement. That version of the code is available by clicking here: wrtraw-one-shot.f

If you work primarily with two-dimensional arrays, one of the preceding routines (or a slight varient) should serve your needs well. However, if you work primarily with three-dimensional arrays, the preceding routines do not work very well. With slight modification they can be made to work in a three-dimensional context, but those modifications may not be vary flexible (i.e., getting output over different slices would require modifying the code, recompiling the program and running again). Instead, here is a much more flexible version of a raw-file generation routine that works with either two- or three-dimensional arrays and permits capturing data over any slice of the three-dimensional array: wrtraw3d.f. Please see the comment lines in the code for calling syntax.

A C version of this three-dimensional slicing routine is available by clicking here: wrtraw3d.c. Again, please see the comment lines in the code for calling syntax. Riaz Siushansian (riaz@uda.dgcd.doc.ca) developed a modified version of this code that is better suited for use with dynamically allocated arrays. His code, along with the array allocation functions, can be obtained by clicking here: wrtraw-riaz.c.

Program to covert the raw files to PGM or PPM files: rw2pnm.f. The conversion is typically done as post-processing of the data, i.e., this program is run after all the raw files have been created. This program requires the following subroutines (which are already included in the source listing):
Convert color coordinates from hsv space to RGB space: hsvrgb.f.
Mapping used for "one-sided" color output: cmap1.f.
Mapping used for "two-sided" color output: cmap2.f (zero = black) or cmap2.f (zero = blue). Choose the one you prefer. Or, you can call one of these mappings cmap3 and modify the rw2pnm accordingly. In that way you can select the mapping you want at run time.

As mentioned in the paper, the C version of rw2pnm is significantly faster than the Fortran version (in fact, it is close to an order of magnitude faster). So, if you are comfortable using C (or can even just compile a C routine), you should probably grab these routines instead of the Fortran routines. Here they are: rw2pnm.c, hsvrgb.c, cmap1.c, cmap2.c (zero = black) and cmap2.c (zero = blue).

The rw2pnm program paints along the left side of the image a ten-pixel wide view of the color mapping that was used. A slightly modified version of code allows the user to select the width of this mapping. If the user enters zero for the width, no map is displayed. This code can be obtained by clicking here: rw2pnm-vw.c (the "vw" stands for "variable width" color map). This routine uses the same functions as rw2pnm.c.

The concurrent processing of images requires the conversion routine to work on a single file and then terminate (at least our implementation has this requirement). Here is a program to covert a single raw file to a PGM or PPM file: rw2pnm1.c. (We have not bothered to write a Fortran version, but conversion to Fortran is simple.) This routine uses the same functions as rw2pnm.c.

Concurrent Processing

Links to Related Sites

And in Conclusion...

If you find this information useful, great. Although this work is peripheral to the research interests of all three of us, we welcome any feedback you care to give. Suggestions to improve this material will be gladly accepted. If you come up with mappings that you thinks are superior to ours, please let us know and we can add it to this page. If you tweak the code so that a more meaningful legend is produced with the image, we would love to hear about it. Also, if you know of other Web sites that are related to visualization or animation of numeric data, we would be happy to put links to those too (just send us the URL and a brief description). Enjoy!

John B. Schneider, schneidj@eecs.wsu.edu
Patrick J. Flynn, flynn@ee.eng.ohio-state.edu
Kurt Shlager, kurt.shlager@lmco.com