CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Probe location in a script (https://www.cfd-online.com/Forums/paraview/155467-probe-location-script.html)

Mc Fly July 1, 2015 07:35

Probe location in a script
 
Hi everybody,

I am a new Paraview user. I am trying to extract points from a bunch of vtu files. It is pretty easily done with "probe location". But since I have a lot of files, I would like to automatize the process (with a macro or a python script).

Could someone maybe show me how it's done?

Thanks a lot.

Flowkersma September 15, 2015 02:11

Hi John,

Here is a example script which opens a vtu files, applies probe filter and saves the result to an array:

Code:

from paraview import numpy_support as ns
from paraview.simple import *

probeResults = []
variable = 'U' # name of the array
files = ['file1.vtu','file2.vtu','file3.vtu']

#Pipeline
reader = OpenDataFile(files[0])
probe = ProbeLocation(reader, ProbeType = "Fixed Radius Point Source")
probe.ProbeType.Center = [0,0,0]  # probe location [x,y,z]

# Loop through the files
for file in files:
  reader.FileNames = file
  probe.UpdatePipeline()
  data = servermanager.Fetch(probe)
  probeResults.append(ns.vtk_to_numpy(data.GetPointData().GetArray(variable)))
print probeResults

Let me know if it does/doesn't work for you.

-Mikko


All times are GMT -4. The time now is 17:26.