# Mesh import with binary Gmsh version 4 fails

**URL:** <https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293>\
**Category:** Errors\
**Tags:** mesh\
**Created:** [3 September 2025 10:19 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293 "2025-09-03T10:19:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlmostSurelyRob](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/almostsurelyrob/32/446_2.png) [@AlmostSurelyRob](https://pyfr.discourse.group/u/AlmostSurelyRob)\
**Post date:** [3 September 2025 10:19 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293/1 "2025-09-03T10:19:12Z")

</div>

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

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

```

And it fails to import to PyFR with an error:

```bash
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](https://pyfr.readthedocs.io/en/latest/user_guide.html) is dead.

---

<div class="post-metadata">

**Author:** ![AlmostSurelyRob](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/almostsurelyrob/32/446_2.png) [@AlmostSurelyRob](https://pyfr.discourse.group/u/AlmostSurelyRob)\
**Post date:** [3 September 2025 10:46 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293/2 "2025-09-03T10:46:57Z")

</div>

[meshio](https://pypi.org/project/meshio/) is useful tool for converting meshes between formats:

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

```

Now trying with it though encountering a different problem:

```plaintext
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'

```

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [3 September 2025 11:37 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293/3 "2025-09-03T11:37:52Z")

</div>

Please see:

> <https://github.com/PyFR/PyFR/blob/2a925c12a323cfb08b84bead0a1f54bde7947d06/doc/src/meshing.rst>

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

Regards, Freddie.

---

<div class="post-metadata">

**Author:** ![AlmostSurelyRob](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/almostsurelyrob/32/446_2.png) [@AlmostSurelyRob](https://pyfr.discourse.group/u/AlmostSurelyRob)\
**Post date:** [5 September 2025 14:47 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293/4 "2025-09-05T14:47:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [5 September 2025 15:01 UTC](https://pyfr.discourse.group/t/mesh-import-with-binary-gmsh-version-4-fails/1293/5 "2025-09-05T15:01:21Z")

</div>

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.
