CFD Online URL
[Sponsors]
Home > Forums > OpenFOAM Paraview & paraFoam

Python script to export animation images

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 3, 2013, 10:33
Default Python script to export animation images
  #1
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 3
mahyarv14 is on a distinguished road
Hey everyone,

I am new to CFD and having a bit of trouble. My goal is to export the animation from ParaView as a video file or a series of images using some kind of script. The only way that I know how to export images is to manually go and click to export the images. I want to have a script that automatically does this so it would be more efficient. My current version of ParaView is 3.12.0 32-bit. I tried using this link http://paraview.org/Wiki/ParaView/Python_Scripting

to setup the python to work with the ParaVeiw, but no success. I could not find the path(s) that were mentioned on the tutorial. Any help is appreciate.


Thanks,
Mahyar
mahyarv14 is offline   Reply With Quote

Old   June 3, 2013, 13:33
Default
  #2
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 3
mahyarv14 is on a distinguished road
So I tried using the Trace option in ParaView but I get the following error:

from paraview.simple import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
import servermanager
File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
import paraview, re, os, os.path, new, sys, vtk
File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
from vtkCommonPython import *
ImportError: No module named vtkCommonPython

I cannot find vtkCommonPython anywhere on my system.
mahyarv14 is offline   Reply With Quote

Old   June 3, 2013, 20:36
Default
  #3
Senior Member
 
JR22's Avatar
 
Jose Rey
Join Date: Oct 2012
Posts: 119
Rep Power: 8
JR22 will become famous soon enough
  1. In paraview: File > Save Animation
  2. Then use one of several methods to make the video from the PNGs:
JR22 is offline   Reply With Quote

Old   June 4, 2013, 07:56
Default
  #4
Member
 
Join Date: Nov 2012
Posts: 58
Rep Power: 4
startingWithCFD is on a distinguished road
Hello! Even though the easiest manner is to use JR22's method, it is sometimes not possible. When I leave work, I only have remote access to a windows machine and through that to the cluster server (yeap, those lovely security restrictions lead to inefficient situations). Therefore, the best way to see the results when I am away is to develop a paraview script to post-process.

So, I find the OP's question for a script meaningful and did not have the time to work on it myself. Does someone have something ready to share or some guidelines?
startingWithCFD is offline   Reply With Quote

Old   June 4, 2013, 10:13
Default
  #5
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 541
Blog Entries: 4
Rep Power: 12
elvis is on a distinguished road
Hi

what about "Advanced Paraview Tutorial", by Dave DeMarle, Kitware, Inc. given on the 6th Openfoam workshop?
http://openfoam-extend.sourceforge.n...m/training.htm
elvis is offline   Reply With Quote

Old   June 4, 2013, 10:32
Default
  #6
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 3
mahyarv14 is on a distinguished road
I was able to solve the vtkCommonPython error by uninstalling ParaView 3.12 and installing a newer version. Now, I have used the Trace option to get a script from ParaView.

My main goal is to have a script run automatically once it detects the output files from OpenFOAM. It should basically create the vtk files, open them with ParaView, and output a video of the simulation to a specified directory.

Currently, I am somewhat stuck on calling Terminal commands in Ubuntu via a python script.

First, I have changed my directory using os.chdir(/path/to/files)

Then, I used os.system("paraFoam") in order to open ParaView from a directory but it says "sh: 1: paraFoam: not found"
mahyarv14 is offline   Reply With Quote

Old   May 21, 2014, 20:53
Default
  #7
Member
 
CFDUser
Join Date: Mar 2014
Posts: 54
Rep Power: 3
CFDUser_ is on a distinguished road
Quote:
Originally Posted by mahyarv14 View Post
I was able to solve the vtkCommonPython error by uninstalling ParaView 3.12 and installing a newer version. Now, I have used the Trace option to get a script from ParaView.

My main goal is to have a script run automatically once it detects the output files from OpenFOAM. It should basically create the vtk files, open them with ParaView, and output a video of the simulation to a specified directory.

Currently, I am somewhat stuck on calling Terminal commands in Ubuntu via a python script.

First, I have changed my directory using os.chdir(/path/to/files)

Then, I used os.system("paraFoam") in order to open ParaView from a directory but it says "sh: 1: paraFoam: not found"
Hi Mahyar,
Did you get any success? I am also trying to do the same. If you found the path will you guide me?

Regards,
CFDUser_
CFDUser_ is offline   Reply With Quote

Old   May 25, 2014, 08:01
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,511
Blog Entries: 33
Rep Power: 74
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings to all!

For future reference, the issue with the missing vtkCommonPython was reported here: http://www.openfoam.org/mantisbt/view.php?id=969 - a fix is also provided there.

As for CFDUser's question and Mahyar's issue: if a more detailed script had been provided, it would possibly had been easier to help. Anyway, as far as I can see:
  1. Once you're using Python scripting, and if you've already exported to VTK file format, it doesn't make much sense to call the paraFoam script.
  2. If you're going to use Python to call ParaView, it probably makes even more sense to use ParaView's pvpython application, which allows you to run Python code with ParaView's functionality ready to be used.
  3. To do such a thing, you should first prepare the Python part of the script directly in ParaView. The "Python Trace" feature that is available in the "Tools" menu should help: http://www.paraview.org/Wiki/Python_GUI_Tools#Trace
  4. Once that script is tested and working, you can try it out by calling pvpython from the command line.
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   May 25, 2014, 21:19
Default
  #9
Member
 
CFDUser
Join Date: Mar 2014
Posts: 54
Rep Power: 3
CFDUser_ is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Greetings to all!

For future reference, the issue with the missing vtkCommonPython was reported here: http://www.openfoam.org/mantisbt/view.php?id=969 - a fix is also provided there.

As for CFDUser's question and Mahyar's issue: if a more detailed script had been provided, it would possibly had been easier to help. Anyway, as far as I can see:
  1. Once you're using Python scripting, and if you've already exported to VTK file format, it doesn't make much sense to call the paraFoam script.
  2. If you're going to use Python to call ParaView, it probably makes even more sense to use ParaView's pvpython application, which allows you to run Python code with ParaView's functionality ready to be used.
  3. To do such a thing, you should first prepare the Python part of the script directly in ParaView. The "Python Trace" feature that is available in the "Tools" menu should help: http://www.paraview.org/Wiki/Python_GUI_Tools#Trace
  4. Once that script is tested and working, you can try it out by calling pvpython from the command line.
Best regards,
Bruno
Thank you very much Bruno, I follow most of your reply's. You are like OpenFOAM best documentation.

Regards,
CFDUser_
CFDUser_ is offline   Reply With Quote

Old   July 10, 2014, 13:54
Default
  #10
Senior Member
 
Join Date: Jan 2013
Posts: 168
Rep Power: 3
openfoammaofnepo is on a distinguished road
Dear Bruno,

I am wondering if I can post-processing my data using Paraview script. For example, I need to the following action for each time step:

Code:
output the velocity components on one slice to CSV file
in the script, how can I add the looping to go through all the time instants?

I read the following link:

http://www.paraview.org/Wiki/ParaView/Python_Scripting

But it is very difficult to understand for me now. Do you have any suggestions?

Thank you.
OFFO

Quote:
Originally Posted by wyldckat View Post
Greetings to all!

For future reference, the issue with the missing vtkCommonPython was reported here: http://www.openfoam.org/mantisbt/view.php?id=969 - a fix is also provided there.

As for CFDUser's question and Mahyar's issue: if a more detailed script had been provided, it would possibly had been easier to help. Anyway, as far as I can see:
  1. Once you're using Python scripting, and if you've already exported to VTK file format, it doesn't make much sense to call the paraFoam script.
  2. If you're going to use Python to call ParaView, it probably makes even more sense to use ParaView's pvpython application, which allows you to run Python code with ParaView's functionality ready to be used.
  3. To do such a thing, you should first prepare the Python part of the script directly in ParaView. The "Python Trace" feature that is available in the "Tools" menu should help: http://www.paraview.org/Wiki/Python_GUI_Tools#Trace
  4. Once that script is tested and working, you can try it out by calling pvpython from the command line.
Best regards,
Bruno
openfoammaofnepo is offline   Reply With Quote

Old   August 16, 2014, 12:11
Default
  #11
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,511
Blog Entries: 33
Rep Power: 74
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Hi OFFO,

Quote:
Originally Posted by openfoammaofnepo View Post
I read the following link:

http://www.paraview.org/Wiki/ParaView/Python_Scripting

But it is very difficult to understand for me now. Do you have any suggestions?
I don't know if you've managed to solve this issue.
If not, perhaps it's easier if you explain what you've already learned so far in using ParaView Python, so that I can figure out what needs to be explained.

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CentFOAM Python Script Installation: Error socon009 OpenFOAM Installation 2 May 26, 2012 10:36
[ParaView] SurfaceFlow filter in python script yohey ParaView 2 March 18, 2012 09:43
[ANSYS Meshing] Export .msh file for fluent by script Mostapha ANSYS Meshing & Geometry 1 August 2, 2011 06:33
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Animation - error - fieldview export Prasad Dudhgaonkar FLUENT 0 May 26, 2007 07:07


All times are GMT -4. The time now is 23:52.