forked from prisms-center/phaseField
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_and_save.py
58 lines (49 loc) · 1.5 KB
/
plot_and_save.py
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
#!/usr/bin/env python3
import sys
from visit import *
#DeleteAllPlots()
# Step 1: Open a database (the whole .vtu time series)
dbname="solution-*.vtu database"
OpenDatabase(dbname)
#Step 2: Add contour plot to obtain grid information and dimensionality
#Add Contour plot
AddPlot("Contour", "n")
ContourAtts = ContourAttributes()
ContourAtts.contourValue = (0.5)
ContourAtts.contourMethod = ContourAtts.Value
SetPlotOptions(ContourAtts)
# Step 3: Draw the plots
DrawPlots()
# Step 4: Get the spacial extents
Query("SpatialExtents")
gpq = GetQueryOutputValue()
# Extracting number of coordinate limits
#(i.e. min x, max x, min y, max y, min z, max z
dimslength=len(gpq);
# Step 5 Determine if system is 2D or 3D (2D - dimslength=4; 3D - dimslength=6)
if dimslength >= 5:
is2D = False
else:
is2D = True
if is2D:
DeleteActivePlots()
AddPlot("Pseudocolor", "n")
DrawPlots()
# Step 7: Animate through time and save results
for states in range(TimeSliderGetNStates()):
#Set slider to state
SetTimeSliderState(states)
# Get the time corresponding to the state
Query("Time")
# Assign this time to the variable "t"
t = GetQueryOutputValue()
# Print the state number, time and phase fraction to
# screen and to files
print("Saving frame % d, time %.1f" %(states, t))
SaveWindowAtts = SaveWindowAttributes()
SaveWindowAtts.fileName = "frame_"
SetSaveWindowAttributes(SaveWindowAtts)
SaveWindow()
DeleteAllPlots()
CloseDatabase(dbname)
sys.exit()