getting size of clip filter in paraview

Submitted by msandli on Wed, 08/30/2017 - 17:52

All,

A while back, Christian (user richti83) provided me with a neat little script to put in a python programmable filter so that I can calculate the volume fraction of particles inside a box-shaped clip filter (slightly edited for my personal use):

import math
input = self.GetInputDataObject(0, 0)
output = self.GetOutputDataObject(0)
fielddata=input.GetFieldData()
COUNT=input.GetNumberOfPoints()
pd=input.GetPointData()

v=0
v0=5.78e-6 #change to volume of your measuremt region
#fname="black.csv"
#f = open(fname, 'a')
for i in xrange(COUNT):

d=pd.GetArray("diameter").GetValue(i)
vp=math.pi*4.0/24.0*d*d*d
v=v+vp

vf=v/v0
print vf

Now, being the amateur code writer that I am, I was wondering if I could automate one important step of the process. As you can see, to calculate the volume fraction, I sum the volume of the particles themselves (ignoring particle overlap, but that difference should be trivial), and then divide by v0, which is the volume of my clip filter.

I can sort of see where the script gets the variable info about the particles (count and pd). However, I am wondering if I can somehow get the volume of my clip filter into my script. In the information tab for a clip filter, the box bounds (and thus, the volume) are listed, but not in the data arrays section - they are in a separate section below that.

If I have to keep calculating v0 by hand, no big deal, but it would sure be a handy feature to have. Thanks!