Difference between revisions of "VtkAnim"

From OpenFOAMWiki
m
Line 48: Line 48:
  
 
''Hints:''
 
''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 moved 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 directory, you will have trouble to make longer animations at a later time.
+
To save disk space and your precious time, you can change 'shutil.copy2' to 'os.rename' in the end of the script. Then, the vtk-files will be moved 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 directory, you will have trouble to make longer animations at a later time.
  
 
ParaView will open the data as cell data. If you prefer point data, just apply the filter "Cell data to point data" provided in ParaView.
 
ParaView will open the data as cell data. If you prefer point data, just apply the filter "Cell data to point data" provided in ParaView.

Revision as of 04:15, 24 March 2010

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 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.

This was tested to work in OF1.5, using ParaView 3.3 and Python 2.4.3 in a Linux environment.

Usage

1. Modify the following to suite your case and add to your $FOAM_CASE/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;
            }
        );
    }
);

Upon runtime, the selected surfaces with sampled field variables will be saved in time-directories in the directory $FOAM_CASE/planes/ in vtk format.

2. Executing this Python script in the $FOAM_CASE/planes/ directory will conveniently copy the vtk-files in the time-directories to the $FOAM_CASE/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 $FOAM_CASE/planes/ directory. Now 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 end of the script. Then, the vtk-files will be moved 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 directory, you will have trouble to make longer animations at a later time.

ParaView will open the data as cell data. If you prefer point data, just apply the filter "Cell data to point data" provided in ParaView.