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

[OpenFOAM] Cut/Clip cylinder instead of sphere/plane?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 30, 2011, 10:10
Default Cut/Clip cylinder instead of sphere/plane?
  #1
New Member
 
Yu
Join Date: May 2010
Location: Cambridge, MA
Posts: 11
Rep Power: 16
Ruehri is on a distinguished road
Dear Foamers,

I would like to make a cut in paraview with the form of a cylinder. Is there any way I can do this? When using the cut command, I can only choose sphere or plane, but would like to have cylinder surface.

Thanks all.
Ruehri is offline   Reply With Quote

Old   May 18, 2013, 15:54
Default
  #2
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
Sorry for digging this thread from so far in the past.
But since this shows up in the top Google search results when looking for this question, I'll leave a note to the recent solution: http://www.cfd-online.com/Forums/ope...tml#post428465
wyldckat is offline   Reply With Quote

Old   October 15, 2013, 04:04
Default Cylinder clip
  #3
New Member
 
Nisha
Join Date: Sep 2009
Location: Massachusetts
Posts: 18
Rep Power: 17
nisha is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Sorry for digging this thread from so far in the past.
But since this shows up in the top Google search results when looking for this question, I'll leave a note to the recent solution: http://www.cfd-online.com/Forums/ope...tml#post428465
Dear Wyldckat,

The link above gives solution for cylinder-"slice". I am looking for cylinder-"clip" like "box" or "sphere" option. I need the entire data that is enclosed in the cylinder. Please help. Thanks.

Nisha
nisha is offline   Reply With Quote

Old   October 19, 2013, 14:09
Default
  #4
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 Nisha,

Very good point! Back when I figured out how to use the "Cylinder" for slicing the results, I didn't properly read that this thread was about clipping and not slicing!

OK, basing myself on my other post, here goes...
It requires two things:
  1. That you are using ParaView 3.12 or 3.14, including the Python capabilities inside ParaView. The reason for this is that in ParaView 3.98, the necessary VTK filter is not present.
  2. That you use the "Programmable Filter" instead of the normal "Clip" filter. The reason for this is because the "Cylinder" is an implicit function that for some reason they forgot to include in ParaView
Instructions:
  1. Apply the "Programmable Filter" to the item you want to cut.
  2. Use the following code in the first text edit box:
    Code:
    input = self.GetInputDataObject(0, 0)
    inp_copy = input.NewInstance()
    inp_copy.ShallowCopy(input)
    inp_copy.UnRegister(None)
    
    transf = vtk.vtkTransform()
    transf.RotateX(90)
    cyl = vtk.vtkCylinder()
    cyl.SetCenter(0,0,0)
    cyl.SetRadius(0.4)
    cyl.SetTransform(transf)
    
    clipper = vtk.vtkClipDataSet()
    clipper.SetClipFunction(cyl)
    clipper.SetInput(inp_copy)
    #clipper.InsideOutOn()
    clipper.Update()
    
    self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))
  3. Notes on important details:
    1. The cylinder is infinite, because it's an implicit function.
    2. "cyl.SetRadius(0.4)" - defines the radius.
    3. "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    4. The transformation is done with these lines of code:
      Code:
      transf = vtk.vtkTransform()
      transf.RotateX(90)
    5. If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
    6. Remove the "#" if you want the inside side of the clip, instead of the outside... or vice-versa!?
    7. More possible options for the "vtkClipDataSet" filter are given here: http://www.vtk.org/doc/release/5.10/...ipDataSet.html
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 21, 2013, 05:30
Default
  #5
New Member
 
Nisha
Join Date: Sep 2009
Location: Massachusetts
Posts: 18
Rep Power: 17
nisha is on a distinguished road
Works like charm! Thanks wlydckat !!
nisha is offline   Reply With Quote

Old   December 18, 2013, 09:46
Default
  #6
New Member
 
Zhiyuan Li
Join Date: Aug 2013
Location: Beijing
Posts: 9
Rep Power: 13
babala is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Greetings Nisha,

Very good point! Back when I figured out how to use the "Cylinder" for slicing the results, I didn't properly read that this thread was about clipping and not slicing!

OK, basing myself on my other post, here goes...
It requires two things:
  1. That you are using ParaView 3.12 or 3.14, including the Python capabilities inside ParaView. The reason for this is that in ParaView 3.98, the necessary VTK filter is not present.
  2. That you use the "Programmable Filter" instead of the normal "Clip" filter. The reason for this is because the "Cylinder" is an implicit function that for some reason they forgot to include in ParaView
Instructions:
  1. Apply the "Programmable Filter" to the item you want to cut.
  2. Use the following code in the first text edit box:
    Code:
    input = self.GetInputDataObject(0, 0)
    inp_copy = input.NewInstance()
    inp_copy.ShallowCopy(input)
    inp_copy.UnRegister(None)
     
    transf = vtk.vtkTransform()
    transf.RotateX(90)
    cyl = vtk.vtkCylinder()
    cyl.SetCenter(0,0,0)
    cyl.SetRadius(0.4)
    cyl.SetTransform(transf)
     
    clipper = vtk.vtkClipDataSet()
    clipper.SetClipFunction(cyl)
    clipper.SetInput(inp_copy)
    #clipper.InsideOutOn()
    clipper.Update()
     
    self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))
  3. Notes on important details:
    1. The cylinder is infinite, because it's an implicit function.
    2. "cyl.SetRadius(0.4)" - defines the radius.
    3. "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    4. The transformation is done with these lines of code:
      Code:
      transf = vtk.vtkTransform()
      transf.RotateX(90)
    5. If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
    6. Remove the "#" if you want the inside side of the clip, instead of the outside... or vice-versa!?
    7. More possible options for the "vtkClipDataSet" filter are given here: http://www.vtk.org/doc/release/5.10/...ipDataSet.html
Best regards,
Bruno
Hi Bruno,
does this method work on paraview which is Windows version? And the VTK is created by OF-2.2.2, I find that the paraview 3-14 can't open this VTK file.Do you know why?

best regards,
Zhiyuan
babala is offline   Reply With Quote

Old   December 25, 2013, 12:49
Default
  #7
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 Zhiyuan,

Quote:
Originally Posted by babala View Post
does this method work on paraview which is Windows version? And the VTK is created by OF-2.2.2, I find that the paraview 3-14 can't open this VTK file.Do you know why?
That's very strange. What was the exact command line you used to export the case to VTK?


And the reported Python code should work on any Operating System that can run ParaView 3.14.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   August 20, 2015, 16:46
Default
  #8
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
Thanks to this thread: http://www.cfd-online.com/Forums/par...-cylinder.html - here are the revised instructions for ParaView 4.1.0:
  1. Apply the "Programmable Filter" to the item you want to cut.
  2. Use the following code in the first text edit box:
    Code:
    import vtk
    
    input = self.GetInputDataObject(0, 0)
    inp_copy = input.NewInstance()
    inp_copy.ShallowCopy(input)
    inp_copy.UnRegister(None)
    
    transf = vtk.vtkTransform()
    transf.RotateX(90)
    cyl = vtk.vtkCylinder()
    cyl.SetCenter(0,0,0)
    cyl.SetRadius(0.4)
    cyl.SetTransform(transf)
    
    clipper = vtk.vtkClipDataSet()
    clipper.SetClipFunction(cyl)
    clipper.SetInputData(inp_copy)
    #clipper.InsideOutOn()
    clipper.Update()
    
    self.GetOutputDataObject(0).ShallowCopy(clipper.GetOutputDataObject(0))
  3. Notes on important details:
    1. The cylinder is infinite, because it's an implicit function.
    2. "cyl.SetRadius(0.4)" - defines the radius.
    3. "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    4. The transformation is done with these lines of code:
      Code:
      transf = vtk.vtkTransform()
      transf.RotateX(90)
    5. If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
    6. Remove the "#" if you want the inside side of the clip, instead of the outside... or vice-versa!?
    7. More possible options for the "vtkClipDataSet" filter are given here: http://www.vtk.org/doc/release/5.10/...ipDataSet.html
wyldckat 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
Flow past a 2D cylinder - High Re (1E+05) - Cd too high Pervispasco OpenFOAM Running, Solving & CFD 4 March 14, 2022 03:19
Drag force coefficient too high for a flow past a cylinder using komega sst Scabbard OpenFOAM Running, Solving & CFD 37 March 21, 2016 17:16
Forces Acting on a Rotating Cylinder (Moving Mesh) dreamchaser CFX 5 April 25, 2015 07:01
Incorrect Drag and Drag Coefficient for flow over a cylinder ozzythewise Main CFD Forum 8 June 13, 2012 07:24
[blockMesh] Specifying boundary faces failes in blockMesh blaise OpenFOAM Meshing & Mesh Conversion 0 May 10, 2010 04:56


All times are GMT -4. The time now is 09:37.