March 29, 2016, 14:18
|
Pass variable from programmable filter to Plot Over Line Filter
|
#1
|
Member
Jack
Join Date: May 2015
Posts: 98
Rep Power: 11
|
My problem is as follows. The script below basically orders unstructured points of an airfoil profile so that I get points ordered from the Leading edge to trailing edge on both suction and pressure surfaces. This is accomplished inside the Programmable filter. The point of interest is . I now want to use the result of this variable in a plot over line filter. How can I "communicate" this variable from inside the programmable filter to the input of the plot over line filter like below:
Code:
#### import the simple module from the paraview
from paraview.simple import *
# create a new 'EnSight Reader'
cFX_00 = EnSightReader(CaseFileName='/Users/CFD/Rotor/user_files/CFX_001_ensight.case')
# create a new 'Extract Block'
extractBlock1 = ExtractBlock(Input=cFX_00)
# Properties modified on extractBlock1
extractBlock1.BlockIndices = [4]
# create a new 'Extract Surface'
extractSurface1 = ExtractSurface(Input=extractBlock1)
# create a new 'Generate Surface Normals'
generateSurfaceNormals1 = GenerateSurfaceNormals(Input=extractSurface1)
generateSurfaceNormals1.FlipNormals = 0
# create a new 'Programmable Filter'
programmableFilter1 = ProgrammableFilter(Input=generateSurfaceNormals1)
script1 = [
'from vtk.util.numpy_support import vtk_to_numpy',
'import numpy as np',
'try:',
' import ordering',
'except ImportError:',
' import sys',
' sys.path.append("/Users/CFXPost")',
' import ordering',
'def order(input, output):',
' output.ShallowCopy(input)',
' numPoints = input.GetNumberOfPoints()',
' coords = []',
' for i in range(0, numPoints):',
' coord = input.GetPoint(i)',
' coords.append(coord) ',
' coords = np.asarray(coords)',
' x,y,z = coords[:,0],coords[:,1],coords[:,2]',
' r,th = ordering.convert_to_cyl(x,y)',
' iss,ips = ordering.order_chord(coords)',
' ss = ordering.perc_arc(z[iss],th[iss])',
' ps = ordering.perc_arc(z[ips],th[ips])',
' ind = (np.abs(ss-%0.4f)).argmin()' % chord_loc,
' point_ind = iss[ind]',
' point_coord = input.GetPoints().GetPoint(point_ind)',
' ',
'input = self.GetInputDataObject(0, 0)',
'output = self.GetOutputDataObject(0)',
' ',
'if input.IsA("vtkMultiBlockDataSet"):',
' output.CopyStructure(input)',
' iter = input.NewIterator()',
' iter.UnRegister(None)',
' iter.InitTraversal()',
' while not iter.IsDoneWithTraversal():',
' curInput = iter.GetCurrentDataObject()',
' curOutput = curInput.NewInstance()',
' curOutput.UnRegister(None)',
' output.SetDataSet(iter, curOutput)',
' order(curInput, curOutput)',
' iter.GoToNextItem();',
'else:',
' order(input, output)'
]
programmableFilter1.Script = str("\n".join(script1))
programmableFilter1.RequestInformationScript = ''
programmableFilter1.RequestUpdateExtentScript = ''
programmableFilter1.PythonPath = ''
# create a new 'Plot Over Line'
plotOverLine1 = PlotOverLine(Input=cFX_00, Source='High Resolution Line Source')
plotOverLine1.Source.Point2 = point_coord # <-- From programmable filter!
plotOverLine1.Source.Point2 = [0.05050000175833702, 0.020051924511790276, 0.0]
|
|
|