-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_results.py
More file actions
222 lines (177 loc) · 9.25 KB
/
Copy pathview_results.py
File metadata and controls
222 lines (177 loc) · 9.25 KB
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
# trace generated using paraview version 5.9.0
import os
import argparse
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
parser = argparse.ArgumentParser()
# NOTE: If errors are being thrown when executing this script, check the default file_path directly below
# and change its default value to wherever your results folder is being saved
parser.add_argument('--file_path', dest='file_path', default='Documents/Repositories/Shell_MDO_ROM/results',
help="File path for saved results.")
parser.add_argument('--show_geom', dest='show_geom', default=False,
help="Show undeformed geometry.")
parser.add_argument('--show_geom_edge', dest='show_geom_edge', default=False,
help="Show edges on undeformed geometry.")
parser.add_argument('--show_disp', dest='show_disp', default=True,
help="Show deformed geometry.")
parser.add_argument('--show_disp_edge', dest='show_disp_edge', default=False,
help="Show edges on deformed geometry.")
parser.add_argument('--show_stress', dest='show_stress', default=True,
help="Show von Mises stress on deformed geometry.")
parser.add_argument('--geom_opacity', dest='geom_opacity', default=1.0,
help="Opacity for undeformed geometry.")
parser.add_argument('--disp_opacity', dest='disp_opacity', default=1.0,
help="Opacity for deformed geometry.")
parser.add_argument('--disp_scale', dest='disp_scale', default=10,
help="Scale factor for displacement.")
parser.add_argument('--start_ind', dest='start_ind', default=0,
help="Index for first spline.")
parser.add_argument('--end_ind', dest='end_ind', default=21,
help="Index for last spline.")
parser.add_argument('--save_state', dest='save_state', default=True,
help="Save current view to a Paraview state file.")
parser.add_argument('--filename_prefix', dest='filename_prefix', default='state',
help="Filename prefix for saved state file.")
parser.add_argument('--interact', dest='interact', default=False,
help="Launch interactive window.")
args = parser.parse_args()
### Arguments
#file_path = args.file_path
file_path = os.path.abspath(args.file_path)
show_geom = bool(args.show_geom)
show_geom_edge = bool(args.show_geom_edge)
show_disp = bool(args.show_disp)
show_disp_edge = bool(args.show_disp_edge)
show_stress = bool(args.show_stress)
geom_opacity = float(args.geom_opacity)
disp_opacity = float(args.disp_opacity)
disp_scale = int(args.disp_scale)
start_ind = int(args.start_ind)
end_ind = int(args.end_ind)
num_surf = end_ind - start_ind
save_state = bool(args.save_state)
filename = args.filename_prefix
interact = bool(args.interact)
if save_state:
filename += "_patch_"+str(start_ind)+"_"+str(end_ind)
if show_geom:
filename += "_geom"
if show_disp:
filename += "_disp"+str(disp_scale)
if show_stress:
filename += "_stress"
filename += ".pvsm"
renderView1 = GetActiveViewOrCreate('RenderView')
for surf_ind in range(start_ind, end_ind):
print("--- Displaying surface", surf_ind)
# create a new 'PVD Reader'
f0_0_filepvd = PVDReader(registrationName='F'+str(surf_ind)+'_0_file.pvd',
FileName=file_path+'/F'+str(surf_ind)+'_0_file.pvd')
f0_0_filepvd.PointArrays = ['F'+str(surf_ind)+'_0']
# create a new 'PVD Reader'
f0_1_filepvd = PVDReader(registrationName='F'+str(surf_ind)+'_1_file.pvd',
FileName=file_path+'/F'+str(surf_ind)+'_1_file.pvd')
f0_1_filepvd.PointArrays = ['F'+str(surf_ind)+'_1']
# create a new 'PVD Reader'
f0_2_filepvd = PVDReader(registrationName='F'+str(surf_ind)+'_2_file.pvd',
FileName=file_path+'/F'+str(surf_ind)+'_2_file.pvd')
f0_2_filepvd.PointArrays = ['F'+str(surf_ind)+'_2']
# create a new 'PVD Reader'
f0_3_filepvd = PVDReader(registrationName='F'+str(surf_ind)+'_3_file.pvd',
FileName=file_path+'/F'+str(surf_ind)+'_3_file.pvd')
f0_3_filepvd.PointArrays = ['F'+str(surf_ind)+'_3']
# create a new 'PVD Reader'
u0_0_filepvd = PVDReader(registrationName='u'+str(surf_ind)+'_0_file.pvd',
FileName=file_path+'/u'+str(surf_ind)+'_0_file.pvd')
u0_0_filepvd.PointArrays = ['u'+str(surf_ind)+'_0']
# create a new 'PVD Reader'
u0_1_filepvd = PVDReader(registrationName='u'+str(surf_ind)+'_1_file.pvd',
FileName=file_path+'/u'+str(surf_ind)+'_1_file.pvd')
u0_1_filepvd.PointArrays = ['u'+str(surf_ind)+'_1']
# create a new 'PVD Reader'
u0_2_filepvd = PVDReader(registrationName='u'+str(surf_ind)+'_2_file.pvd',
FileName=file_path+'/u'+str(surf_ind)+'_2_file.pvd')
u0_2_filepvd.PointArrays = ['u'+str(surf_ind)+'_2']
if show_stress:
# create a new 'PVD Reader'
von_Mises_top_0pvd = PVDReader(registrationName='von_Mises_top_'+str(surf_ind)+'.pvd',
FileName=file_path+'/von_Mises_top_'+str(surf_ind)+'.pvd')
von_Mises_top_0pvd.PointArrays = ['von_Mises_top_'+str(surf_ind)+'']
# set active source
SetActiveSource(f0_0_filepvd)
# # set active source
# SetActiveSource(von_Mises_top_0pvd)
if show_stress:
# create a new 'Append Attributes'
appendAttributes1 = AppendAttributes(registrationName='AppendAttributes'+str(surf_ind),
Input=[f0_0_filepvd, f0_1_filepvd, f0_2_filepvd,
f0_3_filepvd, u0_0_filepvd, u0_1_filepvd,
u0_2_filepvd, von_Mises_top_0pvd])
else:
appendAttributes1 = AppendAttributes(registrationName='AppendAttributes'+str(surf_ind),
Input=[f0_0_filepvd, f0_1_filepvd, f0_2_filepvd,
f0_3_filepvd, u0_0_filepvd, u0_1_filepvd,
u0_2_filepvd])
# create a new 'Calculator'
calculator1 = Calculator(registrationName='Calculator'+str(surf_ind)+'_1',
Input=appendAttributes1)
# Properties modified on calculator1
calculator1.Function = '(F'+str(surf_ind)+'_0/F'+str(surf_ind)\
+'_3-coordsX)*iHat + (F'+str(surf_ind)+'_1/F'\
+str(surf_ind)+'_3-coordsY)*jHat + (F'+str(surf_ind)\
+'_2/F'+str(surf_ind)+'_3-coordsZ)*kHat'
# create a new 'Warp By Vector'
warpByVector1 = WarpByVector(registrationName='WarpByVector'+str(surf_ind)+'_1',
Input=calculator1)
warpByVector1.Vectors = ['POINTS', 'Result']
if show_geom:
warpByVector1Display = Show(warpByVector1, renderView1,
'UnstructuredGridRepresentation')
ColorBy(warpByVector1Display, None)
warpByVector1Display.Opacity = geom_opacity
if show_geom_edge:
warpByVector1Display.SetRepresentationType('Surface With Edges')
# create a new 'Calculator'
calculator2 = Calculator(registrationName='Calculator'+str(surf_ind)+'_2',
Input=warpByVector1)
# Properties modified on calculator2
calculator2.Function = '(u'+str(surf_ind)+'_0/F'+str(surf_ind)\
+'_3)*iHat + (u'+str(surf_ind)+'_1/F'\
+str(surf_ind)+'_3)*jHat + (u'+str(surf_ind)\
+'_2/F'+str(surf_ind)+'_3)*kHat'
# create a new 'Warp By Vector'
warpByVector2 = WarpByVector(registrationName='WarpByVector'+str(surf_ind)+'_2',
Input=calculator2)
warpByVector2.Vectors = ['POINTS', 'Result']
warpByVector2.ScaleFactor = disp_scale
if show_disp:
warpByVector2Display = Show(warpByVector2, renderView1,
'UnstructuredGridRepresentation')
ColorBy(warpByVector2Display, ('POINTS', 'Result', 'Magnitude'))
warpByVector2Display.Opacity = disp_opacity
if show_disp_edge:
warpByVector2Display.SetRepresentationType('Surface With Edges')
# # show color bar/color legend
# warpByVector2Display.SetScalarBarVisibility(renderView1, True)
# UpdatePipeline(time=0.0, proxy=warpByVector2)
if show_stress:
# create a new 'Calculator'
calculator3 = Calculator(registrationName='Calculator'+str(surf_ind)+'_3',
Input=warpByVector2)
# Properties modified on calculator3
calculator3.Function = 'von_Mises_top_'+str(surf_ind)+''
# UpdatePipeline(time=0.0, proxy=calculator3)
calculator3Display = Show(calculator3, renderView1,
'UnstructuredGridRepresentation')
renderView1.InteractionMode = '3D'
renderView1.ResetCamera()
renderView1.Update()
if save_state:
if not os.path.exists("./states/"):
os.mkdir("states")
servermanager.SaveState("./states/"+filename)
if interact:
RenderAllViews()
Interact()