Mesh import with binary Gmsh version 4 fails

I have a Gmsh mesh with a header which looks like this

$MeshFormat
4.1 1 8
<binary output>
$EndMeshFormat
$Nodes
<binary output>
...

And it fails to import to PyFR with an error:

Traceback (most recent call last):
  File "/home/rms/.local/share/uv/tools/pyfr/bin/pyfr", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/__main__.py", line 124, in main
    args.process(args)
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/__main__.py", line 135, in process_import
    reader = get_reader_by_extn(extn, args.inmesh, args.progress)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/readers/__init__.py", line 17, in get_reader_by_extn
    return reader_map[extn](*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/readers/gmsh.py", line 217, in __init__
    for l in filter(lambda l: l != '\n', mshit):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/progress.py", line 165, in wrap_iterable
    for i, v in enumerate(iter):
                ^^^^^^^^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 1115: invalid start byte

I suspect that PyFR Gmsh import is limited to a version and ASCII/binary representation. Could you please confirm? If yes, could this be explicitly stated in the documentation?

Also, note that the link to Gmsh here is dead.

meshio is useful tool for converting meshes between formats:

meshio convert \
    --ascii \
    --input-format gmsh \
    --output-format gmsh22 \
    mesh_gmsh4.msh mesh_gmsh22.msh

Now trying with it though encountering a different problem:

Traceback (most recent call last):
  File "/home/rms/.local/share/uv/tools/pyfr/bin/pyfr", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/__main__.py", line 124, in main
    args.process(args)
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/__main__.py", line 138, in process_import
    mesh = reader.to_pyfrm(args.lintol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/readers/base.py", line 22, in to_pyfrm
    mesh = self._to_raw_pyfrm(lintol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rms/.local/share/uv/tools/pyfr/lib64/python3.12/site-packages/pyfr/readers/gmsh.py", line 420, in _to_raw_pyfrm
    pents = self._felespent, self._bfacespents, self._pfacespents
            ^^^^^^^^^^^^^^^
AttributeError: 'GmshReader' object has no attribute '_felespent'

Please see:

which should clarify what’s supported and how the mesh needs to be prepared.

Regards, Freddie.

2 Likes

Thanks. This is clear and precisely what I needed to know. The mesh was missing PhysicalName section and the fluid tag.

I’d like to ask a follow-up question though. The version 2.8 has no backward compatibility with 2.2 offered by meshio, is that right?

Just for background, I am sorry, I am in a little awkward situation as I don’t have the mesh. I am helping with a conversion. I wrote a little script which reapplies the tags but I couldn’t yet get it to work with 4 yet so exported to gmsh22. PyFR now complains about unpaired faces, which I suspect is due to either missing data in the mesh I was given, something amiss with my conversion script or gmsh22 not being supported in PyFR. I just want to eliminate the last option.

I think 2.8 is a typo in the docs. The version the code supports is 2.2. I’ll get that fixed.

Regards, Freddie.

1 Like