1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
from paraview.simple import *
from paraview import smtesting
from paraview.vtk.vtkPVClientServerCoreRendering import vtkPVCacheKeeper
from paraview.vtk.vtkPVServerManagerDefault import vtkPVGeneralSettings
smtesting.ProcessCommandLineArguments()
filename = smtesting.DataDir + '/can.ex2'
can_ex2 = OpenDataFile(filename)
AnimationScene1 = GetAnimationScene()
AnimationScene1.EndTime = 0.004299988504499197
AnimationScene1.PlayMode = 'Snap To TimeSteps'
can_ex2.PointVariables = ['ACCL', 'DISPL', 'VEL']
can_ex2.ElementVariables = ['EQPS']
can_ex2.GlobalVariables = ['KE', 'NSTEPS', 'TMSTEP', 'XMOM', 'YMOM', 'ZMOM']
can_ex2.ApplyDisplacements = 0
can_ex2.ElementBlocks = ['Unnamed block ID: 1 Type: HEX Size: 4800', 'Unnamed block ID: 2 Type: HEX Size: 2352']
DataRepresentation1 = Show()
RenderView1 = GetRenderView()
RenderView1.CameraPosition = [0.21706008911132812, 4.0, 46.629626614745732]
RenderView1.CameraFocalPoint = [0.21706008911132812, 4.0, -5.1109471321105957]
RenderView1.CameraParallelScale = 13.391445890217907
RenderView1.CenterOfRotation = [0.21706008911132812, 4.0, -5.1109471321105957]
RenderView1.CameraViewUp = [0.0, 0.0, 1.0]
RenderView1.CameraPosition = [0.21706008911132812, 55.740573746856327, -5.1109471321105957]
RenderView1.CameraFocalPoint = [0.21706008911132812, 4.0, -5.1109471321105957]
Render()
#---------------------------------------------------------
# Initial state, nothing cached, or expected to be cached.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToNext()
assert vtkPVCacheKeeper.GetCacheSkips() > 0 and vtkPVCacheKeeper.GetCacheMisses() == 0 and vtkPVCacheKeeper.GetCacheHits() == 0
#---------------------------------------------------------
# nothing cached, or expected to be cached since we didn't enable caching.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToNext()
AnimationScene1.GoToNext()
AnimationScene1.GoToPrevious()
assert vtkPVCacheKeeper.GetCacheSkips() > 0 and vtkPVCacheKeeper.GetCacheMisses() == 0 and vtkPVCacheKeeper.GetCacheHits() == 0
#---------------------------------------------------------
# Enable caching
vtkPVGeneralSettings.GetInstance().SetCacheGeometryForAnimation(True)
#---------------------------------------------------------
# Nothing in cache, but we expect the data to be cached for next time.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToFirst()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() > 0 and vtkPVCacheKeeper.GetCacheHits() == 0
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToNext()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() > 0 and vtkPVCacheKeeper.GetCacheHits() == 0
#---------------------------------------------------------
# now we expect the cache to hit and have no misses.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToPrevious()
AnimationScene1.GoToFirst()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() == 0 and vtkPVCacheKeeper.GetCacheHits() > 0
#---------------------------------------------------------
# Let's fill up the cache fully. We'll have some hits and misses, but no skips.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.GoToFirst()
AnimationScene1.Play()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() > 0 and vtkPVCacheKeeper.GetCacheHits() > 0
#---------------------------------------------------------
# Play again, this time cache should be used.
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.Play()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() == 0 and vtkPVCacheKeeper.GetCacheHits() > 0
#---------------------------------------------------------
# Modify properties and play. this time it should be a cache miss since
# the cache should have been cleared.
can_ex2.PointVariables = ['ACCL', 'DISPL']
vtkPVCacheKeeper.ClearCacheStateFlags()
AnimationScene1.Play()
assert vtkPVCacheKeeper.GetCacheSkips() == 0 and vtkPVCacheKeeper.GetCacheMisses() > 0 and vtkPVCacheKeeper.GetCacheHits() == 0
print "All's well that ends well! Looks like the cache is working as expected."
|