[Paraview] Average a radial profile along the axial direction

Marco B. evilrude at hotmail.it
Wed Nov 18 16:03:56 EST 2015


I have the following Python script to plot the radial porosity profile for a single slice extracted from a VTK file:
import paraview.simple as pvimport numpy as npimport matplotlib.pyplot as pltfrom paraview import numpy_support as nsimport sys
fileName = r'porosity.vtk'
# Bulk velocity and sphere diameterU0 = 0.0033D0 = 0.003
# Slice location in streamwise directionx0 = 0.01
# Translate in y and z direction to get the origin in the middle of the pipel0 = -0.00015-0.0214/2

U = []R = []
# Pipelinereader = pv.OpenDataFile(fileName)transform=pv.Transform(reader)transform.Transform.Translate = [0,l0,l0]slice = pv.Slice(transform,SliceType='Plane')slice.SliceType.Origin = [x0,0,0]slice.SliceType.Normal = [1,0,0]calc = pv.Calculator(slice, ResultArrayName = 'radius', Function = 'sqrt(coordsY^2+coordsZ^2)')contour = pv.Contour(calc,ContourBy = ['POINTS','radius'],Isosurfaces = [0])int = pv.IntegrateVariables(contour)
# Loop over radial distancesfor r in np.linspace(0.00015,0.01065,200):    contour.Isosurfaces = [r]    intData = pv.servermanager.Fetch(int)    L = ns.vtk_to_numpy(intData.GetCellData().GetArray('Length'))[0]    U.append(ns.vtk_to_numpy(intData.GetPointData().GetArray('Porosity'))[0]/L)    R.append(0.01065-r)
# Plot the resultsplt.plot(np.array(R)/D0,np.array(U), 'b-')plt.xlabel('Distance from the wall in particle diameters')plt.ylabel('Porosity')plt.ylim(0,1)plt.show()
How could I modify this Python script to average the radial porosity profiles also along the streamwise (axial) direction (x coordinate)? 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20151118/e4ec2c38/attachment.html>


More information about the ParaView mailing list