|
[Sponsors] |
March 19, 2018, 10:49 |
Programmable filter
|
#1 |
New Member
Tomas B.
Join Date: Dec 2016
Posts: 2
Rep Power: 0 |
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) |
|
Tags |
programmable filter |
|
|
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 |