forked from SaeedZarzor/BFSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource_terms_video_3.py
267 lines (207 loc) · 10 KB
/
source_terms_video_3.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# trace generated using paraview version 5.10.0
#import paraview
#paraview.compatibility.major = 5
#paraview.compatibility.minor = 11
#### import the simple module from the paraview
from paraview.simple import *
from pathlib import Path
import os
import re
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
directory_folder = "Folder_Output"
parent_dir_folder = os.getcwd()
path_folder = os.path.join(parent_dir_folder, directory_folder)
Files = Path(path_folder)
# Iterate directory
res=[]
a=0.0
for f in Files.iterdir():
for file in Files.iterdir():
if re.match("Output_3_\d+\.vtk", file.name):
Output, degree, number=file.stem.split('_')
if(a == float(number)):
res.append(str(file))
a+=1
# create a new 'Legacy VTK Reader'
output_3_ = LegacyVTKReader(registrationName='Output_3_*', FileNames= res)
# get animation scene
animationScene1 = GetAnimationScene()
# update animation scene based on data timesteps
animationScene1.UpdateAnimationUsingDataTimeSteps()
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# show data in view
output_2_Display = Show(output_3_, renderView1, 'UnstructuredGridRepresentation')
# get color transfer function/color map for 'cell_desnity'
cell_desnityLUT = GetColorTransferFunction('cell_desnity')
# get opacity transfer function/opacity map for 'cell_desnity'
cell_desnityPWF = GetOpacityTransferFunction('cell_desnity')
# trace defaults for the display properties.
output_2_Display.Representation = 'Surface'
output_2_Display.ColorArrayName = ['POINTS', 'cell_desnity']
output_2_Display.LookupTable = cell_desnityLUT
output_2_Display.SelectTCoordArray = 'None'
output_2_Display.SelectNormalArray = 'None'
output_2_Display.SelectTangentArray = 'None'
output_2_Display.OSPRayScaleArray = 'cell_desnity'
output_2_Display.OSPRayScaleFunction = 'PiecewiseFunction'
output_2_Display.SelectOrientationVectors = 'displacement'
output_2_Display.ScaleFactor = 0.4
output_2_Display.SelectScaleArray = 'cell_desnity'
output_2_Display.GlyphType = 'Arrow'
output_2_Display.GlyphTableIndexArray = 'cell_desnity'
output_2_Display.GaussianRadius = 0.02
output_2_Display.SetScaleArray = ['POINTS', 'cell_desnity']
output_2_Display.ScaleTransferFunction = 'PiecewiseFunction'
output_2_Display.OpacityArray = ['POINTS', 'cell_desnity']
output_2_Display.OpacityTransferFunction = 'PiecewiseFunction'
output_2_Display.DataAxesGrid = 'GridAxesRepresentation'
output_2_Display.PolarAxes = 'PolarAxesRepresentation'
output_2_Display.ScalarOpacityFunction = cell_desnityPWF
output_2_Display.ScalarOpacityUnitDistance = 0.43868963652317955
output_2_Display.OpacityArrayName = ['POINTS', 'cell_desnity']
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
output_2_Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
output_2_Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
# reset view to fit data
renderView1.ResetCamera(False)
# show color bar/color legend
output_2_Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Clip'
clip1 = Clip(registrationName='Clip1', Input=output_3_)
clip1.ClipType = 'Plane'
clip1.HyperTreeGridClipper = 'Plane'
clip1.Scalars = ['POINTS', 'cell_desnity']
# init the 'Plane' selected for 'ClipType'
clip1.ClipType.Origin = [0.0, 0.998216695, 0.0]
# init the 'Plane' selected for 'HyperTreeGridClipper'
clip1.HyperTreeGridClipper.Origin = [0.0, 0.998216695, 0.0]
# show data in view
clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')
# trace defaults for the display properties.
clip1Display.Representation = 'Surface'
clip1Display.ColorArrayName = ['POINTS', 'cell_desnity']
clip1Display.LookupTable = cell_desnityLUT
clip1Display.SelectTCoordArray = 'None'
clip1Display.SelectNormalArray = 'None'
clip1Display.SelectTangentArray = 'None'
clip1Display.OSPRayScaleArray = 'cell_desnity'
clip1Display.OSPRayScaleFunction = 'PiecewiseFunction'
clip1Display.SelectOrientationVectors = 'displacement'
clip1Display.ScaleFactor = 0.4
clip1Display.SelectScaleArray = 'cell_desnity'
clip1Display.GlyphType = 'Arrow'
clip1Display.GlyphTableIndexArray = 'cell_desnity'
clip1Display.GaussianRadius = 0.02
clip1Display.SetScaleArray = ['POINTS', 'cell_desnity']
clip1Display.ScaleTransferFunction = 'PiecewiseFunction'
clip1Display.OpacityArray = ['POINTS', 'cell_desnity']
clip1Display.OpacityTransferFunction = 'PiecewiseFunction'
clip1Display.DataAxesGrid = 'GridAxesRepresentation'
clip1Display.PolarAxes = 'PolarAxesRepresentation'
clip1Display.ScalarOpacityFunction = cell_desnityPWF
clip1Display.ScalarOpacityUnitDistance = 0.42752329812227563
clip1Display.OpacityArrayName = ['POINTS', 'cell_desnity']
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
clip1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
clip1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
# hide data in view
Hide(output_3_, renderView1)
# show color bar/color legend
clip1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=clip1.ClipType)
# set scalar coloring
ColorBy(clip1Display, ('POINTS', 'source_terms', 'Magnitude'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(cell_desnityLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
clip1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
clip1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'source_terms'
source_termsLUT = GetColorTransferFunction('source_terms')
# get opacity transfer function/opacity map for 'source_terms'
source_termsPWF = GetOpacityTransferFunction('source_terms')
# set scalar coloring
ColorBy(clip1Display, ('POINTS', 'source_terms', 'X'))
# rescale color and/or opacity maps used to exactly fit the current data range
clip1Display.RescaleTransferFunctionToDataRange(False, False)
# Update a scalar bar component title.
UpdateScalarBarsComponentTitle(source_termsLUT, clip1Display)
# Properties modified on clip1Display
clip1Display.Specular = 0.66
# Properties modified on clip1Display
clip1Display.Specular = 0.67
# get color legend/bar for source_termsLUT in view renderView1
source_termsLUTColorBar = GetScalarBar(source_termsLUT, renderView1)
# Properties modified on source_termsLUTColorBar
source_termsLUTColorBar.TitleColor = [0.06465247577630275, 0.11065842679484245, 0.04505989166094453]
source_termsLUTColorBar.LabelColor = [0.06465247577630275, 0.11065842679484245, 0.04505989166094453]
animationScene1.GoToLast()
# Rescale transfer function
source_termsLUT.RescaleTransferFunction(-4.801942615444504, 953.471)
# Rescale transfer function
source_termsPWF.RescaleTransferFunction(-4.801942615444504, 953.471)
# Rescale transfer function
source_termsLUT.RescaleTransferFunction(0.0, 1000.0)
# Rescale transfer function
source_termsPWF.RescaleTransferFunction(0.0, 1000.0)
# get layout
layout1 = GetLayout()
# layout/tab size in pixels
layout1.SetSize(2000, 1354)
# current camera placement for renderView1
renderView1.CameraPosition = [8.997177266552725, 3.808796398466409, 6.749708333729424]
renderView1.CameraFocalPoint = [1.0413002590764291e-16, 0.9982166950000009, -1.1233811141195478e-16]
renderView1.CameraViewUp = [-0.13956302205410775, 0.9662934533243461, -0.21633105402977718]
renderView1.CameraParallelScale = 3.0005949060439203
# save animation
SaveAnimation(str(path_folder)+'/source_vz.avi', renderView1, ImageResolution=[2000, 1352],
OverrideColorPalette='WhiteBackground',
FrameRate=10,
FrameWindow=[0, len(res)])
# set scalar coloring
ColorBy(clip1Display, ('POINTS', 'source_terms', 'Y'))
# rescale color and/or opacity maps used to exactly fit the current data range
clip1Display.RescaleTransferFunctionToDataRange(False, False)
# Update a scalar bar component title.
UpdateScalarBarsComponentTitle(source_termsLUT, clip1Display)
# layout/tab size in pixels
layout1.SetSize(2000, 1354)
# current camera placement for renderView1
renderView1.CameraPosition = [8.997177266552725, 3.808796398466409, 6.749708333729424]
renderView1.CameraFocalPoint = [1.0413002590764291e-16, 0.9982166950000009, -1.1233811141195478e-16]
renderView1.CameraViewUp = [-0.13956302205410775, 0.9662934533243461, -0.21633105402977718]
renderView1.CameraParallelScale = 3.0005949060439203
# save animation
SaveAnimation(str(path_folder)+'/source_osvz.avi', renderView1, ImageResolution=[2000, 1352],
OverrideColorPalette='WhiteBackground',
FrameRate=10,
FrameWindow=[0, len(res)])
#================================================================
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
#================================================================
#--------------------------------
# saving layout sizes for layouts
# layout/tab size in pixels
layout1.SetSize(2000, 1354)
#-----------------------------------
# saving camera placements for views
# current camera placement for renderView1
renderView1.CameraPosition = [8.997177266552725, 3.808796398466409, 6.749708333729424]
renderView1.CameraFocalPoint = [1.0413002590764291e-16, 0.9982166950000009, -1.1233811141195478e-16]
renderView1.CameraViewUp = [-0.13956302205410775, 0.9662934533243461, -0.21633105402977718]
renderView1.CameraParallelScale = 3.0005949060439203
#--------------------------------------------
# uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).