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

Cut/Clip cylinder instead of sphere/plane?

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

Reply
 
LinkBack Thread Tools 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: 7
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, 14:54
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,507
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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: Paraview slice type - cylinder?
wyldckat is offline   Reply With Quote

Old   October 15, 2013, 03:04
Default Cylinder clip
  #3
New Member
 
Nisha
Join Date: Sep 2009
Location: Massachusetts
Posts: 18
Rep Power: 7
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: Paraview slice type - cylinder?
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, 13:09
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,507
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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, 04:30
Default
  #5
New Member
 
Nisha
Join Date: Sep 2009
Location: Massachusetts
Posts: 18
Rep Power: 7
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: 4
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
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,507
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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, 15:46
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,507
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Thanks to this thread: Clip Filter as Type Cylinder - 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

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
benchmark: flow over a circular cylinder goodegg Main CFD Forum 12 January 22, 2013 12:47
Incorrect Drag and Drag Coefficient for flow over a cylinder ozzythewise Main CFD Forum 8 June 13, 2012 06:24
Specifying boundary faces failes in blockMesh blaise OpenFOAM Meshing & Mesh Conversion 0 May 10, 2010 03:56
rotating cylinder using sliding mesh Tim Daly FLUENT 1 November 10, 2008 00:02
Turbulent steady flow around a circular cylinder Mirek Kabacinski FLUENT 0 July 23, 2003 18:40


All times are GMT -4. The time now is 18:47.