@@ -192,19 +192,27 @@ def mises_stress(u):
192
192
output_dir = Path (solution_file_zip ).parent
193
193
with df .io .VTKFile (
194
194
MPI .COMM_WORLD ,
195
- str (output_dir / f"solution_field_data_displacements_{ parameters ['configuration' ]} .vtk" ),
195
+ str (
196
+ output_dir
197
+ / f"solution_field_data_displacements_{ parameters ['configuration' ]} .vtk"
198
+ ),
196
199
"w" ,
197
200
) as vtk :
198
201
vtk .write_function (u , 0.0 )
199
202
with df .io .VTKFile (
200
203
MPI .COMM_WORLD ,
201
- str (output_dir / f"solution_field_data_stress_{ parameters ['configuration' ]} .vtk" ),
204
+ str (
205
+ output_dir / f"solution_field_data_stress_{ parameters ['configuration' ]} .vtk"
206
+ ),
202
207
"w" ,
203
208
) as vtk :
204
209
vtk .write_function (stress_nodes_red , 0.0 )
205
210
with df .io .VTKFile (
206
211
MPI .COMM_WORLD ,
207
- str (output_dir / f"solution_field_data_mises_stress_{ parameters ['configuration' ]} .vtk" ),
212
+ str (
213
+ output_dir
214
+ / f"solution_field_data_mises_stress_{ parameters ['configuration' ]} .vtk"
215
+ ),
208
216
"w" ,
209
217
) as vtk :
210
218
vtk .write_function (mises_stress_nodes , 0.0 )
@@ -235,18 +243,28 @@ def mises_stress(u):
235
243
if MPI .COMM_WORLD .rank == 0 :
236
244
with open (metrics_file , "w" ) as f :
237
245
json .dump (metrics , f , indent = 4 )
238
- # store all .pvd , .vtu, and .vtk files for this configuration in the zip file
246
+ # store all .vtu , .pvtu and .vtk files for this configuration in the zip file
239
247
import zipfile
240
248
241
249
config = parameters ["configuration" ]
242
250
file_patterns = [
243
- str (output_dir / f"solution_field_data_displacements_{ config } *.pvd " ),
244
- str (output_dir / f"solution_field_data_stress_{ config } *.vtu " ),
245
- str (output_dir / f"solution_field_data_mises_stress_{ config } *.vtk " ),
251
+ str (output_dir / f"solution_field_data_displacements_{ config } *" ),
252
+ str (output_dir / f"solution_field_data_stress_{ config } *" ),
253
+ str (output_dir / f"solution_field_data_mises_stress_{ config } *" ),
246
254
]
255
+ print (file_patterns )
256
+
257
+ # assert False
247
258
files_to_store = []
248
259
for pattern in file_patterns :
249
- files_to_store .extend (Path ().glob (pattern ))
260
+ files_to_store .extend (
261
+ filter (
262
+ # filter for all file endings because this is not possible with glob
263
+ lambda path : path .suffix in [".vtk" , ".vtu" , ".pvtu" ],
264
+ Path ().glob (pattern ),
265
+ )
266
+ )
267
+ # files_to_store.extend(Path().glob(pattern))
250
268
with zipfile .ZipFile (solution_file_zip , "w" ) as zipf :
251
269
for filepath in files_to_store :
252
270
zipf .write (filepath , arcname = filepath .name )
@@ -282,4 +300,4 @@ def mises_stress(u):
282
300
args .input_mesh_file ,
283
301
args .output_solution_file_zip ,
284
302
args .output_metrics_file ,
285
- )
303
+ )
0 commit comments