|
[Sponsors] |
|
May 15, 2013, 12:46 |
Paraview slice type - cylinder?
|
#1 |
New Member
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17 |
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. |
|
May 18, 2013, 14:51 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings Alex and welcome to the forum!
It's possible, but it requires two things:
Instructions:
Bruno
__________________
|
|
May 20, 2013, 05:10 |
|
#3 |
New Member
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17 |
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. |
|
May 21, 2013, 06:31 |
|
#4 |
New Member
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17 |
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. |
|
May 21, 2013, 17:40 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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' Best regards, Bruno
__________________
|
|
May 22, 2013, 02:31 |
|
#6 |
New Member
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17 |
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. |
|
August 7, 2014, 07:59 |
|
#7 |
New Member
Stefano Rolfo
Join Date: Aug 2014
Location: UK
Posts: 3
Rep Power: 11 |
hi Bruno
i have also try this scirpt, but in my case is not working. My output is in ensight format and i had to modify the script in order to deal with Multiblock Dataset. With the following script i don't get any error but the output is empty. Here my code Code:
def cut_cylinder(input_block, output_block): inp_copy = input_block.NewInstance() inp_copy.ShallowCopy(input_block.VTKObject) inp_copy.UnRegister(None) cutter = vtk.vtkCutter() transf = vtk.vtkTransform() transf.RotateX(90) cyl = vtk.vtkCylinder() cyl.SetCenter(0,0,0) cyl.SetRadius(0.04) cyl.SetTransform(transf) cutter.SetCutFunction(cyl) #cutter.SetInputConnection(inp_copy.GetOutputPort()) cutter.SetInput(inp_copy) #cutter.SetInputData(inp_copy) #cutter.ShallowCopy(inp_copy) cutter.Update() self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0)) #output_block.ShallowCopy(cutter.GetOutputDataObject(0)) #============================================================================================ from paraview import vtk from paraview.vtk.dataset_adapter import MultiCompositeDataIterator import math from paraview.numpy_support import vtk_to_numpy from paraview.vtk.dataset_adapter import numpyTovtkDataArray, vtkDataArrayToVTKArray import numpy as np iter = MultiCompositeDataIterator([inputs[0], output]) for input_block, output_block in iter: cut_cylinder(input_block,output_block) Code:
cutter.SetInput(inp_copy) Code:
cutter.SetInputData(inp_copy) Does anyone know how i can make this script working. Thanks very much Stefano I get Last edited by wyldckat; August 11, 2014 at 10:33. Reason: [QUOTE] -> [CODE] |
|
August 16, 2014, 13:01 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings Stefano and welcome to the forum!
Can you provide a small example file with which I can reproduce this error? In addition, I suggest that you use the "Merge Blocks" filter before applying this particular programmable filter, so that it makes it easier to at least test this programmable filter. Beyond this, I suspect the problem is that you did not properly calibrate the settings for the position of the cylinder, namely these values were not changed: Code:
transf.RotateX(90) cyl.SetCenter(0,0,0) cyl.SetRadius(0.04) Bruno
__________________
|
|
August 18, 2014, 13:30 |
|
#9 |
New Member
Stefano Rolfo
Join Date: Aug 2014
Location: UK
Posts: 3
Rep Power: 11 |
Dear Bruno
thanks very much for your replay. I check the centre, radius and axis and all are ok (The axis is z and the radius should be between 0.029 and 0.05). I also try to use the filter merge block and after i applied your filter that posted at the top and still the result is the same of the input with no cut. I manage to get something similar to what i was looking for using a coordinate transformation from Cartesian to cylindrical and after using the plane cut on the new geometry. but, in any case, would be nice to have also this filter working. In attachment the small case as you have requested and if you manage to get something let me know. In the input there is only the mesh, but no variables. Just to be clear at the moment i'm using Paraview 4.0 and i don’t know if the version is the source of the problem. Thanks very much for your help Best wishes Stefano |
|
November 13, 2014, 07:51 |
|
#10 |
New Member
Jacopo De Amicis
Join Date: Mar 2012
Posts: 2
Rep Power: 0 |
Hello everybody,
have you managed to find a solution for this problem in version 4.0? I have the same problem as Stefano, changing that line makes the script work but it gives the parent geometry back. Cheers! |
|
April 5, 2015, 12:20 |
|
#11 | |||
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
I'll answer to all 3 posts here: ------------ @Stefano: Quote:
I tested with ParaView 4.1.0 with the following code and it worked just fine with the test case you provided: 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.04) cyl.SetTransform(transf) cutter.SetCutFunction(cyl) cutter.SetInputData(inp_copy) cutter.Update() self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0)) I've tested as well with ParaView 4.0.1 64-bit, which I downloaded as one of the pre-built packages from ParaView.org, and it worked as well. Do notice that the critical detail here is that the radius needs to be changed from "0.4" to "0.04": Code:
cyl.SetRadius(0.04) ---------- @Jacopo: Quote:
By the way, I hope you're using the "Programmable Filter", not the "Programmable Source". ---------- @Lourenço: Quote:
If not, you'll have to provide more details, because I can't figure out what exactly you're looking for. Best regards, Bruno
__________________
|
||||
April 25, 2016, 09:08 |
|
#12 | |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
Dear Bruno,
Which command here is for defining the axis direction of the cylindrical slice before is it flattened? Thanks. Quote:
|
||
May 1, 2016, 19:14 |
|
#13 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Quote:
Code:
transf.RotateX(90)
__________________
|
||
June 16, 2013, 16:02 |
Cylindrical Slice in Paraveiw
|
#14 |
New Member
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 12 |
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!! |
|
June 16, 2013, 16:15 |
|
#15 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
June 16, 2013, 23:36 |
|
#16 |
New Member
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 12 |
Hi wyldckat,
Yes my rotor is located at (0,0,0) and is rotating along z axis. |
|
June 17, 2013, 02:58 |
|
#17 |
New Member
Aleksandar Ćoćić
Join Date: Mar 2009
Location: Belgrade
Posts: 6
Rep Power: 17 |
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) 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) NOT Code:
self.GetOutputDataObject(0).ShallowCopy(cutter.Get OutputDataObject(0)) Code:
self.GetOutputDataObject(0).ShallowCopy(cutter.GetOutputDataObject(0)) Best regards, Alex. |
|
June 17, 2013, 04:23 |
|
#18 |
New Member
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 12 |
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 ? |
|
June 17, 2013, 13:24 |
|
#19 |
New Member
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 12 |
hey,
I installed paraveiw 3.14 and in that the script worked correctly Thanks !! |
|
June 18, 2013, 00:44 |
|
#20 |
New Member
Akash Sharma
Join Date: May 2013
Location: Paris
Posts: 15
Rep Power: 12 |
Hello,
I got the cylindrical slice, now i want to flatten that surface any idea how to do that ? Thanks |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
activeBaffleVelocity boundary condition ? | om3ro | OpenFOAM Programming & Development | 10 | November 16, 2020 23:26 |
Modified pimpleFoam solver to MRFPimpleFoam solver | hiuluom | OpenFOAM Programming & Development | 12 | June 14, 2015 21:22 |
Strange high velocity in centrifugal pump simulation | huangxianbei | OpenFOAM Running, Solving & CFD | 26 | August 15, 2014 02:27 |
interFoam/kOmegaSST tank filling with printStackError/Mules | simpomann | OpenFOAM Running, Solving & CFD | 3 | February 17, 2014 17:06 |
Error during initialization of "rhoSimpleFoam" | kornickel | OpenFOAM Running, Solving & CFD | 8 | September 17, 2013 05:37 |