|
[Sponsors] |
[OpenFOAM] [ParaView] Programmable Filter to repeat 2 degree segments |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 23, 2012, 10:44 |
[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 |
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) Any help will be appreciated |
|
February 10, 2012, 04:49 |
|
#2 |
Member
Laurens Van Dyck
Join Date: Jul 2011
Location: Netherlands/Germany
Posts: 34
Rep Power: 15 |
Anyone?
|
|
February 10, 2012, 16:15 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
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() If you then need to do more post-processing on it, select them all and use the filter "Group Datasets". Best regards, Bruno
__________________
|
|
February 13, 2012, 05:22 |
|
#4 |
Member
Laurens Van Dyck
Join Date: Jul 2011
Location: Netherlands/Germany
Posts: 34
Rep Power: 15 |
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() |
|
|
|
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 |