nschloe/meshio

[BUG] could not read .med file

ekremekc opened this issue · 1 comments

Describe the bug
meshio is not reading the .med file, which is generated in Salome 9.7.0

To Reproduce
import meshio
meshio.read('pipe.med')

Output of the console

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/meshio/_helpers.py", line 71, in read
    return _read_file(Path(filename), file_format)
  File "/usr/lib/python3.10/site-packages/meshio/_helpers.py", line 103, in _read_file
    return reader_map[file_format](str(path))
  File "/usr/lib/python3.10/site-packages/meshio/med/_med.py", line 114, in read
    mesh = Mesh(
  File "/usr/lib/python3.10/site-packages/meshio/_mesh.py", line 181, in __init__
    if len(data[k]) != len(self.cells[k]):
TypeError: len() of unsized object

Mesh file

Mesh file can be found in here.

Thank you for your time!

I'm facing the same issue. It seems to be fixed by replacing:

for k in range(len(data)):

with

for k in [i for i, x in enumerate(data) if x is not None]:

however, I've not done much testing if this causes other problems.