Search code examples
pythonparaviewpost-processing

Script for post-processing vtu or pvd files


I am pretty new to post-processing using python scripts. But all these days I used ParaView to look at my results(images at different time steps). But as my mesh resolution increases the image of the next time step takes forever to load. Therefore, I would like to create a python script which can save the results at every timestep in image formats (png or jpeg) and also maybe merge the images as a video file.

I have a folder SavingsforParaview which contains a single .pvd file and 217 .vtu files, one for each time step. In ParaView, we load the pvd file and then visualize everything. Now, I would like to build a script to do the same. I don't want to use the inbuilt python script in ParaView, but create a separate file that I can run in a terminal using python commands.

The files can be found here.

https://filesender.renater.fr/?s=download&token=6aad92fb-dde3-41e0-966d-92284aa5884e


Solution

  • You can use the Python Trace, in Tool menu.

    Usage:

    • start trace
    • use PV as usual (load files, setup filters and views, take screenshot ...)
    • stop trace

    It generates the python version of your actions and display it. Then you can save it as a python file and manually modify it.

    For instance, you can do the visu for the first 2 timesteps and then edit the trace file to add a loop and cover each timesteps.