Skip to content

Commit 571f5c5

Browse files
authored
Merge pull request #975 from nschloe/mdpa-fix
Mdpa fix
2 parents ae05f49 + 8bb0bd3 commit 571f5c5

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

meshio/mdpa/_mdpa.py

+10-17
Original file line numberDiff line numberDiff line change
@@ -527,35 +527,28 @@ def write(filename, mesh, float_fmt=".16e", binary=False):
527527
# rest is actual cell data.
528528
tag_data = {}
529529
other_data = {}
530-
for cell_type, a in mesh.cell_data.items():
531-
tag_data[cell_type] = {}
532-
other_data[cell_type] = {}
533-
for key, data in a.items():
534-
if key in ["gmsh:physical", "gmsh:geometrical"]:
535-
tag_data[cell_type][key] = data.astype(numpy.int32)
536-
else:
537-
other_data[cell_type][key] = data
538-
539-
# We identity which dimension are we
530+
for key, data in mesh.cell_data.items():
531+
if key in ["gmsh:physical", "gmsh:geometrical"]:
532+
tag_data[key] = [entry.astype(numpy.int32) for entry in data]
533+
else:
534+
other_data[key] = data
535+
536+
# identity dimension
540537
dimension = 2
541538
for c in cells:
542539
name_elem = _meshio_to_mdpa_type[c.type]
543540
if local_dimension_types[name_elem] == 3:
544541
dimension = 3
545542
break
546543

547-
# We identify the entities
544+
# identify entities
548545
_write_nodes(fh, mesh.points, float_fmt, binary)
549546
_write_elements_and_conditions(fh, cells, tag_data, binary, dimension)
550547
for name, dat in mesh.point_data.items():
551548
_write_data(fh, "NodalData", name, dat, binary)
552549
cell_data_raw = raw_from_cell_data(other_data)
553-
for (
554-
name,
555-
dat,
556-
) in (
557-
cell_data_raw.items()
558-
): # NOTE: We will assume always when writing that the components are elements (for now)
550+
for name, dat in cell_data_raw.items():
551+
# assume always that the components are elements (for now)
559552
_write_data(fh, "ElementalData", name, dat, binary)
560553

561554

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = meshio
3-
version = 4.3.5
3+
version = 4.3.6
44
author = Nico Schlömer et al.
55
author_email = [email protected]
66
description = I/O for many mesh formats

0 commit comments

Comments
 (0)