check if cell_type exists before checking cell_tags
@@ -241,8 +241,11 @@ def write(filename, mesh, add_global_ids=True):
nod.attrs.create("NBR", len(cells))
# Cell tags
+ if cell_type in mesh.cell_data:
if "cell_tags" in mesh.cell_data[cell_type]: # works only for med -> med
- fam = mai.create_dataset("FAM", data=mesh.cell_data[cell_type]["cell_tags"])
+ fam = mai.create_dataset(
+ "FAM", data=mesh.cell_data[cell_type]["cell_tags"]
+ )
fam.attrs.create("CGT", 1)
fam.attrs.create("NBR", len(cells))
