meshio icon indicating copy to clipboard operation
meshio copied to clipboard

[BUG] could not read .med file

Open ekremekc opened this issue 1 year ago • 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!

ekremekc avatar Mar 26 '23 16:03 ekremekc

I'm facing the same issue. It seems to be fixed by replacing: https://github.com/nschloe/meshio/blob/0138cc8692b806b44b32d344f7961e8370121ff7/src/meshio/_mesh.py#L179 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.

smr02 avatar Dec 13 '23 12:12 smr02