Automating Post-Processing in Paraview


I am new to both the Paraview software and this forum, so if I am missing details/information please let me know.

I am looking to fully automate my post-processing algorithm in Paraview using Python. At the moment, I am able to load my .foam file, implement some basic filters and extract my numerical data (using the NumPy dataset adapter). I am now wishing to perform mathematical operations on my dataset, and view the result in Paraview’s render window.

This is my current pipeline:

# Load Raw Simulation Data & Extract Velocity Data
BaseSource = OpenFOAMReader(registrationName='BaseSource', FileName=['FilePath/Test.foam'])
BaseSource.MeshRegions.SelectAll() # Extract all of the mesh regions of interest
BaseSource.CellArrays = ['U']

# Merging Dataset for Easy Data Extraction
Merged = MergeBlocks(registrationName = 'Merged', Input = BaseSource) 

# Clip Dataset
Clipped = Clip(registrationName = 'PortsRemoved', Input = Merged)
Clipped.ClipType = 'Plane'
Clipped.ClipType.Origin = [-1.2665987014770508e-07, 0, 0.019]
Clipped.ClipType.Normal = [0, 0, -1]

# Extract Velocity Data for Manipulation
Local = sm.Fetch(Clipped) 
WrappedData = dsa.WrapDataObject(Local)
data = WrappedData.PointData[0]

After this point in my pipeline, I will be performing mathematical operations on the data located within each cell. However, I am wondering how I could convert my modified data so that I can view it in Paraview once my processing has been complete? Is what I am doing OK, or is there a better way to go about doing this?

I am not using the programmable filter because I would like to perform multiple iterations of this pipeline.

Any help would be greatly appreciated!

Hi @Matthew , and welcome !

Use the calculator or python calculator.

I am not using the programmable filter because I would like to perform multiple iterations of this pipeline.



One helpful thing to internalize is that ParaView is designed as a client/server application, with all the data residing on the server, the filter/data manipulating happening on the server, and then either geometry or rendered images are sent to the client. Yes, you can get the data as well using Fetch as you have shown, but that is a one-way operation moving data from the server to the client. There is no way back once you have done that.

For this reason, you need to manipulate your data on the server side? How? Using the Calculator or Python Calculator as @mwestphal indicated, or the Programmable Filter. The first two are limited to fairly simple expressions, while Programmable Filter lets you do a lot of data manipulation using either Python-wrapped VTK or numpy manipulations using the data wrapping mechanism as in your example code. If you do this, all the data manipulation will occur on the server side, and you will see the resulting geometry and rendered images reflect those manipulations.

I’m not 100% sure what you mean, but you could add several different Programmable Filters in different pipelines to compute different things.

1 Like

Hello Mathieu and Cory,

I greatly appreciate both of your responses and the additional information you have provided me with - this helps a lot!

In terms of me mentioning that I wish to perform ‘multiple iterations’ of the pipeline, I mean that I would like to analyze the data for different mathematical conditions. Specifically, I am looking use the same analysis pipeline, with mathematical values changed between each iteration or ‘run’. I want to perform 90 runs of my pipeline, each with different mathematical values. I was thinking that using pvpython would be preferred, as if I were to use the programmable filter I would have to manually run my data analysis 90 times, and extract the data by hand (rather than clicking my pvpython script once and having it return the data for me). Am I thinking about this wrong?

No, you are right. Prog filter are about perfoming an operation in the pipeline, eg to bridge a missing feature gap in ParaView filters.