CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] Python script to export animation images

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 3, 2013, 09:33
Default Python script to export animation images
  #1
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 12
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, 12:33
Default
  #2
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 12
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, 19:36
Default
  #3
Senior Member
 
JR22's Avatar
 
Jose Rey
Join Date: Oct 2012
Posts: 134
Rep Power: 17
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, 06:56
Default
  #4
Member
 
Join Date: Nov 2012
Posts: 58
Rep Power: 13
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, 09:13
Default
  #5
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 620
Blog Entries: 6
Rep Power: 24
elvis will become famous soon enough
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, 09:32
Default
  #6
New Member
 
Mahyar
Join Date: Jun 2013
Posts: 3
Rep Power: 12
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, 19:53
Default
  #7
Member
 
CFDUser
Join Date: Mar 2014
Posts: 59
Rep Power: 13
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, 07:01
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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, 20:19
Default
  #9
Member
 
CFDUser
Join Date: Mar 2014
Posts: 59
Rep Power: 13
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, 12:54
Default
  #10
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
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, 11:11
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[General] Close Paraview after python script execution taalf ParaView 4 August 29, 2019 21:29
[General] Generating isosurface from vtk file with python script Leios ParaView 1 March 26, 2018 12:33
A CFX-POST error (ver 14.5.7) wangyflp88 CFX 2 July 22, 2017 00:17
[General] Python script: Auto-scale color scale julien.decharentenay ParaView 2 December 9, 2013 05:39
Animation - error - fieldview export Prasad Dudhgaonkar FLUENT 0 May 26, 2007 06:07


All times are GMT -4. The time now is 11:20.