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

[General] Pass variable from programmable filter to Plot Over Line Filter

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2016, 14:18
Default Pass variable from programmable filter to Plot Over Line Filter
  #1
Member
 
Jack
Join Date: May 2015
Posts: 98
Rep Power: 11
Jack001 is on a distinguished road
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
Code:
point_coord
. 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]
Jack001 is offline   Reply With Quote

Reply

Tags
paraview, plot over line, 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
Derivative of velocity and mean velocity hiuluom OpenFOAM Post-Processing 1 May 30, 2015 00:42
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 06:42
8x icoFoam speed up with Cufflink CUDA solver library kmooney OpenFOAM Running, Solving & CFD 42 November 6, 2012 12:37
Problems of Duns Codes! Martin J Main CFD Forum 8 August 15, 2003 00:19
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 16:16


All times are GMT -4. The time now is 08:23.