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

[General] VTK API: Working with values inside the python shell

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2013, 06:05
Default VTK API: Working with values inside the python shell
  #1
New Member
 
Thomas S
Join Date: Aug 2012
Posts: 11
Rep Power: 13
Thoma is on a distinguished road
Dear all,

I have some problems with the VTK API. The problem is a value which I have calculated before in a python script. I want now to import and to work with it inside the python shell.

That is what I have done so far:

s_kero = 3.4 #dummy value, normally calculated in a python script

Calculator2 = Calculator()
Calculator2.AttributeMode = 'cell_data'
Calculator2.Function = 'a*s_kero' # a: value from the CFD simulation
Calculator2.ResultArrayName = 's_kerosene'

Of course this is not working.... Does anyone have a suggestion?

Thanks for your help.
Thoma is offline   Reply With Quote

Old   January 7, 2013, 15:43
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
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 Thomas,

I'm not sure I understand the problem.
Assuming you're using ParaView, the code seems to work, at least up to a point. On ParaView 3.14.1, these following commands worked for me:
Code:
from paraview.simple import *

Calculator2 = Calculator()
Calculator2.AttributeMode = 'cell_data'
Calculator2.Function = 'p*2'
Calculator2.ResultArrayName = 's_kerosene'

Show()
Render()
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 7, 2013, 17:16
Default
  #3
New Member
 
Thomas S
Join Date: Aug 2012
Posts: 11
Rep Power: 13
Thoma is on a distinguished road
Hey Bruno,

thank you very much for your response. Yes, I am working with paraview. I need to do some modifications on the results stored in a vtk-file.

Because I want to display these results later in Paraview, I am working with the calculator. The problem is, that my value, s_kero (your 2), is a value, that comes from a complex python script. It is computed for every cell and the numbers are changing depending on the input values.
I do not want to translate the entire phyton script with calculators in paraview. It would be too much work... I hope to find a way to create an interface between the value from pyhton and paraview.

So I have the calculator function:

Calculator2.Function = 'p*s_kero' where s_kero is a value, calculated for every cell and corresponds every time to a different number.

Regards,

Thomas
Thoma is offline   Reply With Quote

Old   January 8, 2013, 15:08
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
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 Thomas,

Sorry about that, it was late and I was tired. Right now it also took some time to finally understand the problem.
But still, there are (at least) two possibilities, because I'm not 100% certain of what you need. So:
  1. If "s_kero" is a single value to be multiplied by the whole 'p' field, then this should do the trick:
    Code:
    Calculator2.Function = 'p*' + str(s_kero)
  2. If on the other hand, "s_kero" is in essence a field itself, then you need to register the field into the current data space first and only then you can do the math. I believe you can use the "Python Calculator" filter for creating the field "s_kero": http://www.vtk.org/Wiki/Python_Calculator
    Then you can use the resulting field on the "Calculator2"!
    Here's another tutorial on this subject: http://www.vtk.org/Wiki/ParaView/Use...ammable_Filter
Best regards,
Bruno
Thoma likes this.
__________________
wyldckat is offline   Reply With Quote

Old   January 10, 2013, 14:35
Default
  #5
New Member
 
Thomas S
Join Date: Aug 2012
Posts: 11
Rep Power: 13
Thoma is on a distinguished road
Hey Bruno.

Thank you very much!! Actually I can use both of your suggestions!!
Thoma 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
do permeability and inertia loss coefficients values depend on working fluid? sh.a.ghafour FLUENT 4 July 5, 2020 22:38
Working with Python: Query of through-plane flow of multiple clips in one plot PedroInvierno EnSight 8 April 10, 2017 09:23
[General] Python Shell Clipping sisetrun ParaView 0 January 30, 2017 12:57
Limiting values inside volScalarField PekkaRo OpenFOAM Programming & Development 3 March 18, 2011 07:50
meshing F1 front wing Steve FLUENT 0 April 17, 2003 12:37


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