Search code examples
pythonnumpyvtkopenfoam

How to generate a snapshot of a field in a time step with VTK and Python


I am working with the cavity example of the OpenFoam installation (v1812). After executing it (icoFoam) having the following result:

$ ls
0  0.1  0.2  0.3  0.4  0.5  constant  system

I would like to know if it is possible to postprocess the time steps, through a script, that generated a matrix of pixels with the values of a given field (for instance the pressure).

Apart from the array (which could be handled with numpy) of each time step, I'd also like to show as a result a heat map like this:

enter image description here


Solution

  • You can find an example of post processing of the cavity example here using vedo.

    enter image description here