VtkAnim

From OpenFOAMWiki
Revision as of 06:44, 23 March 2010 by Nogenmyr (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Saving selected field variables in selected surfaces in your computational domain into time-directories is a functionality provided in the official release of OpenFOAM. This is a small contribution that will help you to use that functionality to generate animations. By using the Python script below, the files in the saved time-directories will be copied and renamed in a fashion that will allow ParaView to interpret the save-outs as a time series.


Usage

1. Modify the following to suite your case and add to your system/controlDict-file:

 
functions
(
    planes
    {
        type surfaces;
        interval 100;
        surfaceFormat vtk;
        fields
        (
            U
            p
        );
        surfaces
        (
            xz
            {
                type            plane;
                basePoint	(1e-5 1e-5 1e-5);
                normalVector	(0 1 0);
                triangulate     false;
            }
            yz
            {
                type            plane;
                basePoint	(1e-5 1e-5 1e-5);
                normalVector	(1 0 0);
                triangulate     false;
            }
        );
    }
);

This will create a directory named planes/ in your case directory. When the case is running, the selected cross section surfaces with sampled field variables will be saved as time directories in planes/ in vtk format.

2. Executing this Python script will conveniently copy the vtk-files in the time directories to the planes/ directory and add a count-number to each file. By doing this, ParaView will recognize these data fields as time series.

3. Start ParaView and go to the planes/ directory. There you can open each saved variable as a time series.

Hints: To save disk space and your precious time, you can change 'shutil.copy2' to 'os.rename' in the last line of the script. Then, the vtk-files will be renamed instead of copied. This would be particular useful if you download the time-directories from a cluster. But if you do this in your running simulation, you will have trouble to make a longer animation later.

ParaView will open the data as cell data, which is troublesome for vectors. By using the filter "Cell data to point data" provided in ParaView, this is easily solved