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

[OpenFOAM] [ParaView] Programmable Filter to repeat 2 degree segments

Register Blogs Community New Posts Updated Threads Search

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

Reply
 
LinkBack Thread Tools Search this Thread 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: 15
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: 15
laurensvd is on a distinguished road
Anyone?
laurensvd is offline   Reply With Quote

Old   February 10, 2012, 16:15
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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: 15
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


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
[General] Listing the inputs of a grouped dataset with a programmable python filter in Paraview NadineHS ParaView 3 December 12, 2021 15:54
[General] Programmable filter halal ParaView 0 March 19, 2018 10:49
[General] Pass variable from programmable filter to Plot Over Line Filter Jack001 ParaView 0 March 29, 2016 14:18
Programmable Filter Problem quantenmaschine OpenFOAM Post-Processing 0 August 22, 2015 10:44
[General] Programmable Filter: when multiple inputs, how to verify which input is which? macfly ParaView 0 July 12, 2014 12:14


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