|
[Sponsors] |
[OpenFOAM] Python script for Integrate Variable |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 31, 2013, 06:09 |
Python script for Integrate Variable
|
#1 |
Member
Mehdi GHOZALI
Join Date: May 2013
Location: Dubai, UAE
Posts: 65
Rep Power: 12 |
Hello,
I am using paraview for visualize the velocity and the flow on a slice/clip that I did. I have a lot of clips and I have to export data for every one and even the integrate variable data on this one. The first part is done now I don't know what is the sciprt of integrate variable on a clip so I can do it automaticly!! hope some one will help thank you in advance dadou |
|
July 4, 2013, 11:25 |
|
#2 |
Senior Member
Eloïse
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 113
Rep Power: 13 |
Hello Mehdi,
I'd like to do a similar scripted post-processing: integrate a variable on different clips and then export the spreadsheet data to a file. Have you made any progress on your case? Regards, Eloïse |
|
July 5, 2013, 04:37 |
|
#3 |
Member
Mehdi GHOZALI
Join Date: May 2013
Location: Dubai, UAE
Posts: 65
Rep Power: 12 |
Hi Eloise,
Nop any progress unfortunately, do you have any idea ? Regards Mehdi |
|
July 5, 2013, 05:02 |
|
#4 |
Senior Member
Eloïse
Join Date: Jul 2012
Location: Trondheim, Norway
Posts: 113
Rep Power: 13 |
Hi Mehdi,
I'm not sure it is the fastest way to deal with the csv files, but I did manage. Here is the interesting part of the script Code:
try: paraview.simple except: from paraview.simple import * paraview.simple._DisableFirstRenderCameraReset() import csv surf = LegacyVTKReader( FileNames=['pathToImportFile.vtk'] ) RenderView1 = GetRenderView() Clip1 = Clip( ClipType="Plane" ) Clip1.Scalars = ['POINTS', 'p'] Clip1.ClipType.Origin = [0.0, 0.0, 0.0] #can be a random origin point Clip1.ClipType.Normal = [1.0, 0.0, 0.0] #can be a random normal orientation Clip1.ClipType = "Plane" Clip2 = Clip( ClipType="Plane" ) Clip2.Scalars = ['POINTS', 'p'] Clip2.ClipType.Origin = [1.0, 0.0, 0.0] #can be a random origin point Clip2.ClipType.Normal = [-1.0, 0.0, 0.0] #can be a random normal orientation Clip2.ClipType = "Plane" # we define the variable to be integrated on Clip2 Calculator1 = Calculator() Calculator1.AttributeMode = 'point_data' Calculator1.Function = 'writeHereTheFunctionOfYourVariable' Calculator1.ReplaceInvalidResults = 0 Calculator1.ResultArrayName = 'NameOfYourVariable' IntegrateVariables1 = IntegrateVariables() #this integrates the current variable over Clip2 finalFile = open('pathToCSVFile.csv','wb') fd = csv.writer(finalFile) writer = CreateWriter('PathToATemporaryFile.csv', IntegrateVariables1) writer.FieldAssociation = "Points" # or "Cells" for x in range(-6, 6): #loop through the origin point of Clip1 print "We integrate from %1.1f to %1.1f" % (x,x+1) Clip1.ClipType.Origin = [x,0.0,0.0] #moves the first clip Clip1.ClipType.Normal = [1.0,0.0,0.0] Clip2.ClipType.Origin = [x+1,0.0,0.0] # moves the second clip Clip2.ClipType.Normal = [-1.0,0.0,0.0] writer.UpdatePipeline() # writes the integrated variable table to the tmp file # appends the integrated results of this Clip to the final csv file ftmp = open('PathToATemporaryFile.csv','rb') reader = csv.reader(ftmp, delimiter=',') row = reader.next() row = reader.next() fd.writerow([str(row)]) ftmp.close() finalFile.close() del(writer) Render() Eloïse |
|
July 5, 2013, 06:38 |
|
#5 |
Member
Mehdi GHOZALI
Join Date: May 2013
Location: Dubai, UAE
Posts: 65
Rep Power: 12 |
I'll look it up.
Thank you so much for this, I'll see what I can do Regards Mehdi |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Python script to sum up a variable for all cells | hconel | ParaView | 1 | February 7, 2019 18:59 |
[General] python script to group/append datasets | ufocfd | ParaView | 0 | July 30, 2018 17:25 |
[OpenFOAM] Get cell center coordinates in a python script | francois | ParaView | 2 | June 3, 2017 09:20 |
[General] Using variables defined in a Python script on a Paraview/Python Calculator | gafxian87 | ParaView | 0 | June 8, 2015 14:18 |
[General] Using time in Python script | lingdeer | ParaView | 0 | August 11, 2014 02:57 |