CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Paraview & paraFoam

[ParaView] Programmable Filter to repeat 2 degree segments

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By wyldckat
  • 1 Post By laurensvd

Reply
 
LinkBack Thread Tools Display Modes
Old   January 23, 2012, 10:44
Default [ParaView] Programmable Filter to repeat 2 degree segments
  #1
Member
 
Laurens Van Dyck
Join Date: Jul 2011
Location: Netherlands/Germany
Posts: 34
Rep Power: 6
laurensvd is on a distinguished road
Hey all

I am simulating an axisymmetric problem with a 2 degree wedge representation. In postprocessing, using paraview, I want to repeat this 2 degree segment such that I get a full 3D Domain (primarily to retrieve the streamlines). I found that this should be achievable using the programmable filter in paraview but since I am not familiar with Python this is a bit difficult. I came up with the following code:
(making sure that the input is a single data set and the output format is set to multiblock):

Code:
 from paraview import vtk
 input_copy = inputs[0].NewInstance()
 input_copy.UnRegister(None)
 input_copy.ShallowCopy(inputs[0].VTKObject)
 
 rotated=inputs[0].NewInstance()
 rotated.UnRegister(None)
 rotated.ShallowCopy(inputs[0].VTKObject)
 
 transform = vtk.vtkTransform()
 transformFilter=vtk.vtkTransformFilter()
 
 rotatedMultiBlock=vtk.vtkMultiBlockDataSet()
 transformFilter.SetInput(input_copy)
 for i in range(180):
     transform.RotateX(2)
     transformFilter.SetTransform(transform)
     transformFilter.Update()
     rotatedMultiBlock.SetBlock(i,transformFilter.GetOutput())
 output.ShallowCopy(rotatedMultiBlock)
The problem is that even though 180 blocks are generated, they all hold the data of the last iteration. I am suspecting I have to work with arrays for the different transforms and transformation filters but I just cant seem to get it to work.

Any help will be appreciated
laurensvd is offline   Reply With Quote

Old   February 10, 2012, 04:49
Default
  #2
Member
 
Laurens Van Dyck
Join Date: Jul 2011
Location: Netherlands/Germany
Posts: 34
Rep Power: 6
laurensvd is on a distinguished road
Anyone?
laurensvd is offline   Reply With Quote

Old   February 10, 2012, 16:15
Default
  #3
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings Laurensvd,

If you had posted on the sub-forum for ParaView (http://www.cfd-online.com/Forums/openfoam-paraview/), I would have picked up on this a lot sooner .

You don't need to make a shallow copy of the initial object. Simply apply several transformation filters to the main object! "Tools->Start trace" can aid you with this as well, namely the stages of opening a file and then transforming.

By using a "cone" object as a source and the Python tracing strategy, I've adapted the resulting macro and made this small script (save in a file with the extension ".py"):
Code:
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

Cone2 = GetActiveSource()

for i in range(2,360,2):
  TransformV = Transform( Transform="Transform" )
  TransformV.Transform = "Transform"
  TransformV.Transform.Rotate = [0.0, 0.0, ii]

Render()
I used ParaView 3.12.0 and rotated over Z. It requires that you have the initial item selected before running the macro. After it is done, you'll have to select every single transform object and click where the eye on the left should be; this will turn on all selected objects (or off).

If you then need to do more post-processing on it, select them all and use the filter "Group Datasets".

Best regards,
Bruno
fumiya likes this.
wyldckat is offline   Reply With Quote

Old   February 13, 2012, 05:22
Default
  #4
Member
 
Laurens Van Dyck
Join Date: Jul 2011
Location: Netherlands/Germany
Posts: 34
Rep Power: 6
laurensvd is on a distinguished road
Thank you very much
The source code above still had a few minor flaws but the start/stop trace helped me with that. For those who are interested the final code is:

Code:
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

Cone2 = GetActiveSource()

for ii in range(2,360,2):
  TransformV = Transform( Transform="Transform" )
  TransformV.Transform = "Transform"
  TransformV.Transform.Rotate = [0.0, 0.0, 2.0]

DataRepresentationV = Show()
Render()
fumiya likes this.
laurensvd is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accumulating Dust on a Filter Cartridge WalterW CFX 20 April 22, 2014 06:19
how can use the LES filter? (laplace filter and anistropic filter) ethan oh OpenFOAM 7 February 7, 2014 17:13
How to use a programmable filter with two geometries alpha_tango OpenFOAM Paraview & paraFoam 1 August 10, 2011 03:15


All times are GMT -4. The time now is 14:45.