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

[OpenFOAM] Paraview slice type - cylinder?

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 15, 2013, 13:46
Default Paraview slice type - cylinder?
  #1
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hello to everybody,

I computed the flow in axial fan, in one blade passage and I want see the flow structure in meridian section - so I need to make a slice with cylindrical surface over the blades, and then to "flatten" that surface.

Is it possibly to do that in Paraview (paraFoam)? Any help would be more that welcome. Thanks in advance.

Alex.
acocic is offline   Reply With Quote

Old   May 18, 2013, 15:51
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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 Alex and welcome to the forum!

It's possible, but 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 "Slice" filter. The reason for this is because the "Cylinder" is an implicit function that for some reason they forgot to include in ParaView
Reference: http://www.paraview.org/pipermail/pa...ry/016019.html

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)
    cutter = vtk.vtkCutter()
    transf = vtk.vtkTransform()
    transf.RotateX(90)
    cyl = vtk.vtkCylinder()
    cyl.SetCenter(0,0,0)
    cyl.SetRadius(0.4)
    cyl.SetTransform(transf)
    cutter.SetCutFunction(cyl)
    cutter.SetInput(inp_copy)
    cutter.Update()
    self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0))
  3. Notes on important details:
    • The cylinder is infinite, because it's an implicit function.
    • "cyl.SetRadius(0.4)" - defines the radius.
    • "cyl.SetCenter(0,0,0)" - defines the centre of the cylinder.
    • The transformation is done with these lines of code:
      Code:
       transf = vtk.vtkTransform()
      transf.RotateX(90)
    • If more transformations are needed, see the list of methods here: http://www.vtk.org/doc/release/5.10/...Transform.html
Best regards,
Bruno
kaifu, Tobi, Nucleophobe and 3 others like this.
__________________
wyldckat is offline   Reply With Quote

Old   May 20, 2013, 06:10
Default
  #3
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hey Bruno,

It works just perfect!! Thank you very much! By default, I didn't have "Programmable filter" and Python support (I'm using OpenFOAM-1.6-ext and ParaView 3.12.0 which I compiled without Python support, I guess).

I downloaded then Paraview 3.12 again with

wget http://www.paraview.org/files/v3.12/...-x86_64.tar.gz

extract the files, and tried your code with "new" paraview on VTK data which I previously generated with foamToVTK. And then I got perfect cylindrical slice .

What is left for me is to connect this version of paraview with OpenFOAM, to be called with paraFoam.

Thanks to your other link

http://www.cfd-online.com/Forums/blo...-openfoam.html

it won't be a problem !

Best regards,
Alex.
wyldckat likes this.
acocic is offline   Reply With Quote

Old   May 21, 2013, 07:31
Default
  #4
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hello once again,

I just wanted to add some new insights on this topic. Actually, we don't have to modify paraFoam script, and OpenFOAM bashrc file. This paraView version I mentioned in previous thread supports OpenFOAM files, and you can open files with *.foam extension.

So I just created aliases, something like paraViewWithPython, which points to binary of new paraview. When you start this command in the root of the case, it won't automatically load the case data, but you can open *.foam file which is there, and then use Programmable filter.

Best regards,
Alex.
acocic is offline   Reply With Quote

Old   May 21, 2013, 18:40
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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
Hi Alex,

You use the following alias:
Code:
alias paraViewWP='touch case.foam && /long/path/to/ParaView-3.12.0/bin/paraview --data=case.foam'
It was based on the one shown here:http://openfoamwiki.net/index.php/Ho...using_ParaView

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   May 22, 2013, 03:31
Default
  #6
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hi Bruno,

Once again, it works perfect! Now the data are automatically loaded, and Programmable filter & mighty Python support are there!

Thank you once again for all your support and answers!

Best regards,
Alex.
acocic is offline   Reply With Quote

Old   June 16, 2013, 17:02
Default Cylindrical Slice in Paraveiw
  #7
New Member
 
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 13
akashjangid is on a distinguished road
Hello,

I computed the flow through a rotor(Diameter -1m) which is placed inside a wind tunnel.
Now i want to analyze flow at different span length of blades. So for that i need a cylindrical slice.
I am using 3.12.0 ParaVeiw version
I used this code but it does not show any output

input = self.GetInputDataObject(0, 0)
inp_copy = input.NewInstance() inp_copy.ShallowCopy(input)
inp_copy.UnRegister(None)
cutter = vtk.vtkCutter()
transf = vtk.vtkTransform()
transf.RotateX(90)
cyl = vtk.vtkCylinder()
cyl.SetCenter(0,0,0)
cyl.SetRadius(0.4)
cyl.SetTransform(transf)
cutter.SetCutFunction(cyl)
cutter.SetInput(inp_copy)
cutter.Update() self.GetOutputDataObject(0).ShallowCopy(cutter.Get OutputDataObject(0))

Can someone tell me why?
Thanks a lot!!
akashjangid is offline   Reply With Quote

Old   June 16, 2013, 17:15
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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
Hi Akash and welcome to the forum!

(I forgot to welcome you to the forum, when I replied to the message you had sent me!)

And thank you for posting your question here!
But there is one big question left unanswered: where exactly in space is your rotor?

Because this code assumes that the rotor is centred in "0,0,0" and its axis is aligned with Z.

If you don't know exactly where the rotor is in space, you can use the source "Cylinder" and move this cylinder to the location where your rotor is. This source is located in the menu "Sources -> Cylinder".

Then, knowing the position of this cylinder, it'll be easier to configure the script to do the section-cut in the right place!

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 17, 2013, 00:36
Default
  #9
New Member
 
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 13
akashjangid is on a distinguished road
Hi wyldckat,

Yes my rotor is located at (0,0,0) and is rotating along z axis.
akashjangid is offline   Reply With Quote

Old   June 17, 2013, 03:58
Default
  #10
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hello Akash,

I think that you made some mistakes in the code, or it's just because of copying. For me Bruno's code works perfectly. So if you compare with it, there are slight differences. These are the paraview messages for your code, and possible solutions

Remark 1:
File "<string>", line 3
inp_copy = input.NewInstance() inp_copy.ShallowCopy(input)
^
SyntaxError: invalid syntax

This should be two lines,
Code:
inp_copy = input.NewInstance()
inp_copy.ShallowCopy(input)
Remark 2:
File "<string>", line 15
cutter.Update() self.GetOutputDataObject(0).ShallowCopy(cutter.Get OutputDataObject(0))
^
SyntaxError: invalid syntax

Also two lines:
Code:
cutter.Update()
self.GetOutputDataObject(0).ShallowCopy(cutter.Get OutputDataObject(0)
Remark 3: no space in last line
NOT
Code:
self.GetOutputDataObject(0).ShallowCopy(cutter.Get  OutputDataObject(0))
BUT
Code:
self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0))
If you used foamToVTK, and you analyze VTK data, you should choose vtkPolyData instead "Same as Input" in Output Data Set Type (just bellow Apply Reset Delete)

Best regards,
Alex.
Ramsky likes this.
acocic is offline   Reply With Quote

Old   June 17, 2013, 05:23
Default
  #11
New Member
 
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 13
akashjangid is on a distinguished road
Hello acocic,

I did the changes in the script as told by you.
But it is still showing some errors

Traceback (most recent call last):
File "<string>", line 21, in <module>
File "<string>", line 14, in RequestData
AttributeError: SetInput

Actually I'm a beginner in scripting python for ParaView.
Please help me with this ? Do i have to add any vtk modules for this ?
akashjangid is offline   Reply With Quote

Old   June 17, 2013, 14:24
Default
  #12
New Member
 
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 13
akashjangid is on a distinguished road
hey,

I installed paraveiw 3.14 and in that the script worked correctly
Thanks !!
akashjangid is offline   Reply With Quote

Old   June 18, 2013, 01:44
Default
  #13
New Member
 
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 13
akashjangid is on a distinguished road
Hello,

I got the cylindrical slice, now i want to flatten that surface
any idea how to do that ?
Thanks
akashjangid is offline   Reply With Quote

Old   June 20, 2013, 17:57
Default
  #14
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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
Hi Akash,

The ParaView filter "Warp by vector" comes to mind, but I think I've never used it

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   July 6, 2013, 11:52
Default empty output
  #15
New Member
 
Christian Weiß
Join Date: Jul 2013
Posts: 4
Rep Power: 13
Nephi is on a distinguished road
hello
i have to do almoust the same task as Aleksandar and was verry happy to find your post and so i tried out the programmable filter on a dummycylinder that ist orientated along the y-axis as default and copied in the code into the programmable filter. there are no errors comming up but i do not get any results. the output geometry has 0 points and 0 cells.
is there anythig special i have to be aware of?
i am using paraview 3.14 on linux and on windows
with best regards
Christian
Nephi is offline   Reply With Quote

Old   July 7, 2013, 06:09
Default Sharing some experience :-)
  #16
New Member
 
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17
acocic is on a distinguished road
Hello Christian,

For me, it was very straightforward. Main flow was in Z-direction, so the axis of the cylinder matched with Z-axis, and Bruno's original code worked perfectly. After it I tried the code with my other case (LES in pipe, where X-axis was the symmetry), and the code didn't work. The solution was to change to rotational axis in

Code:
transf.RotateX(90)
to

Code:
transf.RotateZ(90)
and to put (leave) the center of cylinder at (0, 0, 0), which is actually pipe inlet. The length of the pipe was 0.1m and if I put the center of cylinder in the middle of the domain, (0.05, 0, 0), I also got nothing, On the other hand, if I delete "transform.Rotate" line, I've got cylinder which axis is parallel to Y, and which is shown no matter where the center is located.

So basically, you just have to play around with two lines of the code (cylinder center and axis of rotation) and see what's the most suitable in your case. Maybe, first delete the line with transf.Rotate and see what you'll get (the axis of cylinder should be in Y-dir).

Best regards,
Alex.
Attached Images
File Type: jpg cyl-1.jpg (23.8 KB, 188 views)
File Type: jpg cyl-2.jpg (24.3 KB, 169 views)
File Type: jpg cyl-3.jpg (28.6 KB, 134 views)
File Type: jpg cyl-4.jpg (31.2 KB, 161 views)
wyldckat likes this.
acocic is offline   Reply With Quote

Old   July 7, 2013, 13:29
Default
  #17
New Member
 
Christian Weiß
Join Date: Jul 2013
Posts: 4
Rep Power: 13
Nephi is on a distinguished road
Hi Alex
thank you for your fast reply. But unfortunatly it still does not work.
I tryed out all rotations and all cylinders are centered in 0,0,0
with best regards
Christian
Nephi is offline   Reply With Quote

Old   July 7, 2013, 15:24
Default
  #18
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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 to all!

@Christian: could you please give some indications are to where your geometry/data is located in 3D space? As well as the limits of said geometry/data?

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   July 8, 2013, 04:45
Default
  #19
New Member
 
Christian Weiß
Join Date: Jul 2013
Posts: 4
Rep Power: 13
Nephi is on a distinguished road
Hi Bruno,
i just added da cylindersurce centered at 0,0,0 with high 1 and a radius of 0.5 , which is symmetric around the y-axis.
I tried cutting with a rotation around x-axis, z-axis and wothout rotarion. I also changed the radius to 0.5, were i expected to get the whole cylindersurface as result.
with best regards
Christian
Nephi is offline   Reply With Quote

Old   July 10, 2013, 17:29
Default
  #20
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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
Hi Christian,

Oddly enough, it does not work with a cylinder source. I have no idea why

But it does work with a sphere source! You can use the default settings and it will work!

Best regards,
Bruno
__________________
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
activeBaffleVelocity boundary condition ? om3ro OpenFOAM Programming & Development 10 November 17, 2020 00:26
Modified pimpleFoam solver to MRFPimpleFoam solver hiuluom OpenFOAM Programming & Development 12 June 14, 2015 22:22
Strange high velocity in centrifugal pump simulation huangxianbei OpenFOAM Running, Solving & CFD 26 August 15, 2014 03:27
interFoam/kOmegaSST tank filling with printStackError/Mules simpomann OpenFOAM Running, Solving & CFD 3 February 17, 2014 18:06
Error during initialization of "rhoSimpleFoam" kornickel OpenFOAM Running, Solving & CFD 8 September 17, 2013 06:37


All times are GMT -4. The time now is 00:29.