CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

Using time in Python script

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 11, 2014, 01:57
Default Using time in Python script
  #1
Member
 
Elaine
Join Date: Jul 2011
Posts: 48
Rep Power: 7
lingdeer is on a distinguished road
Hi,

I have data in time that has time points like {0.02124,0.04248,0.06372,0.08496, etc.}

I wrote a python script to loop through these time points with time increment of 0.02124 and export as .csv.

----------------------------------------------

for x in range(1, 4):

currentT = x*deltaT
AnimationScene1 = GetAnimationScene()
RenderView1 = GetRenderView()
AnimationScene1.AnimationTime = currentT
RenderView1.ViewTime = currentT
RenderView1.CacheKey = currentT
RenderView1.UseCache = 1
RenderView1.UseCache = 0


SetActiveSource(data)
writer = CreateWriter("output.csv")
writer.FieldAssociation = "Points"
writer.UpdatePipeline()
del writer

Render()

------------------------------------------

When I played the macro, some time points were not correctly read. (e.g. the 4th time point spreadsheet saved data that belong to the 3rd time point.)

I used "start trace" to see how paraview handles time, and here is what I caught:

--------------------------------------------------------
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

AnimationScene1 = GetAnimationScene()
RenderView1 = GetRenderView()
AnimationScene1.AnimationTime = 0.021239999681711197

RenderView1.ViewTime = 0.021239999681711197
RenderView1.CacheKey = 0.021239999681711197
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.042479999363422394

RenderView1.ViewTime = 0.042479999363422394
RenderView1.CacheKey = 0.042479999363422394
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.06372000277042389

RenderView1.ViewTime = 0.06372000277042389
RenderView1.CacheKey = 0.06372000277042389
RenderView1.UseCache = 1

AnimationScene1.AnimationTime = 0.08495999872684479

RenderView1.ViewTime = 0.08495999872684479
RenderView1.CacheKey = 0.08495999872684479
RenderView1.UseCache = 1

RenderView1.UseCache = 0

Render()
--------------------------------------------------------
Then I realized, if I tried to read data at 0.08496, it will read data from the previous time point instead. If I explicitly specify in my script to read data at time 0.08495999872684479, then it will read the correct data.

Anyone has any insights?
Thanks in advance!!!
lingdeer 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
Multiple floating objects CKH OpenFOAM Running, Solving & CFD 12 March 21, 2016 14:05
How to export time series of variables for one point? mary mor OpenFOAM Post-Processing 7 February 19, 2014 16:56
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 14:12
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 07:47
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 04:34


All times are GMT -4. The time now is 15:24.