@@ -206,9 +206,13 @@ def _read_families(fas_data):
206
206
return families
207
207
208
208
209
- def write (filename , mesh , add_global_ids = True , compression = "gzip" , compression_opts = 4 ):
209
+ def write (filename , mesh , add_global_ids = True ):
210
210
import h5py
211
211
212
+ # MED doesn't support compression,
213
+ # <https://github.com/nschloe/meshio/issues/781#issuecomment-616438066>
214
+ # compression = None
215
+
212
216
f = h5py .File (filename , "w" )
213
217
214
218
# Strangely the version must be 3.0.x
@@ -248,23 +252,13 @@ def write(filename, mesh, add_global_ids=True, compression="gzip", compression_o
248
252
nodes_group .attrs .create ("CGS" , 1 )
249
253
profile = "MED_NO_PROFILE_INTERNAL"
250
254
nodes_group .attrs .create ("PFL" , numpy .string_ (profile ))
251
- coo = nodes_group .create_dataset (
252
- "COO" ,
253
- data = mesh .points .flatten (order = "F" ),
254
- compression = compression ,
255
- compression_opts = compression_opts ,
256
- )
255
+ coo = nodes_group .create_dataset ("COO" , data = mesh .points .flatten (order = "F" ))
257
256
coo .attrs .create ("CGT" , 1 )
258
257
coo .attrs .create ("NBR" , len (mesh .points ))
259
258
260
259
# Point tags
261
260
if "point_tags" in mesh .point_data : # only works for med -> med
262
- family = nodes_group .create_dataset (
263
- "FAM" ,
264
- data = mesh .point_data ["point_tags" ],
265
- compression = compression ,
266
- compression_opts = compression_opts ,
267
- )
261
+ family = nodes_group .create_dataset ("FAM" , data = mesh .point_data ["point_tags" ])
268
262
family .attrs .create ("CGT" , 1 )
269
263
family .attrs .create ("NBR" , len (mesh .points ))
270
264
@@ -279,22 +273,14 @@ def write(filename, mesh, add_global_ids=True, compression="gzip", compression_o
279
273
med_cells .attrs .create ("CGT" , 1 )
280
274
med_cells .attrs .create ("CGS" , 1 )
281
275
med_cells .attrs .create ("PFL" , numpy .string_ (profile ))
282
- nod = med_cells .create_dataset (
283
- "NOD" ,
284
- data = cells .flatten (order = "F" ) + 1 ,
285
- compression = compression ,
286
- compression_opts = compression_opts ,
287
- )
276
+ nod = med_cells .create_dataset ("NOD" , data = cells .flatten (order = "F" ) + 1 )
288
277
nod .attrs .create ("CGT" , 1 )
289
278
nod .attrs .create ("NBR" , len (cells ))
290
279
291
280
# Cell tags
292
281
if "cell_tags" in mesh .cell_data : # works only for med -> med
293
282
family = med_cells .create_dataset (
294
- "FAM" ,
295
- data = mesh .cell_data ["cell_tags" ][k ],
296
- compression = compression ,
297
- compression_opts = compression_opts ,
283
+ "FAM" , data = mesh .cell_data ["cell_tags" ][k ]
298
284
)
299
285
family .attrs .create ("CGT" , 1 )
300
286
family .attrs .create ("NBR" , len (cells ))
@@ -309,15 +295,15 @@ def write(filename, mesh, add_global_ids=True, compression="gzip", compression_o
309
295
try :
310
296
if len (mesh .point_tags ) > 0 :
311
297
node = families .create_group ("NOEUD" )
312
- _write_families (node , mesh .point_tags , compression , compression_opts )
298
+ _write_families (node , mesh .point_tags )
313
299
except AttributeError :
314
300
pass
315
301
316
302
# For cell tags
317
303
try :
318
304
if len (mesh .cell_tags ) > 0 :
319
305
element = families .create_group ("ELEME" )
320
- _write_families (element , mesh .cell_tags , compression , compression_opts )
306
+ _write_families (element , mesh .cell_tags )
321
307
except AttributeError :
322
308
pass
323
309
@@ -329,9 +315,7 @@ def write(filename, mesh, add_global_ids=True, compression="gzip", compression_o
329
315
if name == "point_tags" : # ignore point_tags already written under FAS
330
316
continue
331
317
supp = "NOEU" # nodal data
332
- _write_data (
333
- fields , mesh_name , profile , name , supp , data , compression , compression_opts
334
- )
318
+ _write_data (fields , mesh_name , profile , name , supp , data )
335
319
336
320
# Cell data
337
321
# Only support writing ELEM fields with only 1 Gauss point per cell
@@ -351,28 +335,12 @@ def write(filename, mesh, add_global_ids=True, compression="gzip", compression_o
351
335
else : # general ELGA data defined at unknown Gauss points
352
336
supp = "ELGA"
353
337
_write_data (
354
- fields ,
355
- mesh_name ,
356
- profile ,
357
- name ,
358
- supp ,
359
- data ,
360
- compression ,
361
- compression_opts ,
362
- med_type ,
338
+ fields , mesh_name , profile , name , supp , data , med_type ,
363
339
)
364
340
365
341
366
342
def _write_data (
367
- fields ,
368
- mesh_name ,
369
- profile ,
370
- name ,
371
- supp ,
372
- data ,
373
- compression ,
374
- compression_opts ,
375
- med_type = None ,
343
+ fields , mesh_name , profile , name , supp , data , med_type = None ,
376
344
):
377
345
# Skip for general ELGA fields defined at unknown Gauss points
378
346
if supp == "ELGA" :
@@ -422,12 +390,7 @@ def _write_data(
422
390
profile .attrs .create ("GAU" , numpy_void_str )
423
391
424
392
# Dataset
425
- profile .create_dataset (
426
- "CO" ,
427
- data = data .flatten (order = "F" ),
428
- compression = compression ,
429
- compression_opts = compression_opts ,
430
- )
393
+ profile .create_dataset ("CO" , data = data .flatten (order = "F" ))
431
394
432
395
433
396
def _component_names (n_components ):
@@ -447,7 +410,7 @@ def _family_name(set_id, name):
447
410
return "FAM" + "_" + str (set_id ) + "_" + "_" .join (name )
448
411
449
412
450
- def _write_families (fm_group , tags , compression , compression_opts ):
413
+ def _write_families (fm_group , tags ):
451
414
"""
452
415
Write point/cell tag information under FAS/[mesh_name]
453
416
"""
@@ -456,13 +419,7 @@ def _write_families(fm_group, tags, compression, compression_opts):
456
419
family .attrs .create ("NUM" , set_id )
457
420
group = family .create_group ("GRO" )
458
421
group .attrs .create ("NBR" , len (name )) # number of subsets
459
- dataset = group .create_dataset (
460
- "NOM" ,
461
- (len (name ),),
462
- dtype = "80int8" ,
463
- compression = compression ,
464
- compression_opts = compression_opts ,
465
- )
422
+ dataset = group .create_dataset ("NOM" , (len (name ),), dtype = "80int8" )
466
423
for i in range (len (name )):
467
424
name_80 = name [i ] + "\x00 " * (80 - len (name [i ])) # make name 80 characters
468
425
dataset [i ] = [ord (x ) for x in name_80 ]
0 commit comments