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

[General] Programmable filter

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2018, 10:49
Question Programmable filter
  #1
New Member
 
Tomas B.
Join Date: Dec 2016
Posts: 2
Rep Power: 0
halal is on a distinguished road
I am trying to calculate the average particle position and velocity. This is the basic code I am using:

Code:
pdi = self.GetPolyDataInput()
pdo =  self.GetPolyDataOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()

sumx=0
sumy=0
sumz=0
sumvx=0
sumvy=0
sumvz=0

for i in range(0, numPoints):
    coord = pdi.GetPoint(i)
    x, y, z = coord[:3]
    sumx = sumx+x
    sumy = sumy+y
    sumz = sumz+z
    vx = pdi.GetPointData().GetArray("v").GetValue(0)
    vy = pdi.GetPointData().GetArray("v").GetValue(1)
    vz = pdi.GetPointData().GetArray("v").GetValue(2)
    sumvx = sumvx+vx
    sumvy = sumvy+vy
    sumvz = sumvz+vz

avx=sumx/numPoints
avy=sumy/numPoints
avz=sumz/numPoints
avvx=sumvx/numPoints
avvy=sumvy/numPoints
avvz=sumvz/numPoints

newPoints.InsertPoint(0, avx, avy, avz)

pdo.SetPoints(newPoints)
but I don't know how to write the average velocity into the output. Could someone point me in the right direction? I've tried looking for similar topics but I am getting quite confused with the programmable filter and what commands to use for specific purposes. Is there a list of possible commands for the programmable filter? Thank you for your answer
halal is offline   Reply With Quote

Reply

Tags
programmable filter


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] Listing the inputs of a grouped dataset with a programmable python filter in Paraview NadineHS ParaView 3 December 12, 2021 15:54
[General] Pass data through programmable filter t8fanning ParaView 0 November 14, 2018 20:06
[General] Pass variable from programmable filter to Plot Over Line Filter Jack001 ParaView 0 March 29, 2016 14:18
Programmable Filter Problem quantenmaschine OpenFOAM Post-Processing 0 August 22, 2015 10:44
[General] Programmable Filter: when multiple inputs, how to verify which input is which? macfly ParaView 0 July 12, 2014 12:14


All times are GMT -4. The time now is 21:37.