Error while importing the mesh: KeyError

Hello,
I was trying to simulate the flow around an airfoil using a 3D mesh obtained by extruding a 2D mesh along the z-axis. However, during the execution of the command pyfr import mesh.msh mesh.pyfrm, the following error occurred:

KeyError: (np.int64(2005), np.int64(4155), np.int64(4464), np.int64(225339))

Here is the link to the mesh and the .geo file:

Please provide the full backtrace.

Regards, Freddie.

$ pyfr import mesh.msh rae2822.pyfrm
Traceback (most recent call last):
  File "/lustre/home/pscavella/pyfr-venv/bin/pyfr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/__main__.py", line 124, in main
    args.process(args)
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/__main__.py", line 138, in process_import
    mesh = reader.to_pyfrm(args.lintol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/readers/base.py", line 22, in to_pyfrm
    mesh = self._to_raw_pyfrm(lintol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/readers/gmsh.py", line 424, in _to_raw_pyfrm
    pyfrm = mesh.get_connectivity(p)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/readers/base.py", line 189, in get_connectivity
    pfpairs, pmap = self._pair_periodic_fluid_faces(bpart, resid)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/readers/base.py", line 151, in _pair_periodic_fluid_faces
    lf = resid.pop(tuple(sorted(lfn)))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: (np.int64(2005), np.int64(4155), np.int64(4464), np.int64(221979))

If you do not extrude the mesh does everything work as expected?

Regards, Freddie.

Yes, the 2d simulation works as expected.

Next step is to try replacing the periodic boundary conditions with regular conditions and seeing if that resolves the issue. If so, you can be almost certain that the mistake is in how you are specifying the periodic connectivity.

Regards, Freddie.

I tried different conditions but nothing changes.
Regards, Luca

Do you still get the following error even without periodic interfaces?

File “/lustre/home/pscavella/pyfr-venv/lib/python3.12/site-packages/pyfr/readers/base.py”, line 151, in _pair_periodic_fluid_faces
lf = resid.pop(tuple(sorted(lfn)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: (np.int64(2005), np.int64(4155), np.int64(4464), np.int64(221979))

I solved this problem by changing the way I created the mesh

Hello,

I’m encountering the same error that you posted

"
KeyError: (np.int64(7), np.int64(11), np.int64(2502), np.int64(4889))
"

I created the mesh in the same way you described. Could you share how you changed your approach to generating the mesh?

I got a similar error when extruding a 2D mesh of airfoil with sharp trailing edge. This is without periodic interfaces in spanwise direction. I don’t get any error with the 2D mesh itself.

Traceback (most recent call last):
  File "~/pyvenv/bin/pyfr", line 33, in <module>
    sys.exit(load_entry_point('pyfr==2.1', 'console_scripts', 'pyfr')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/__main__.py", line 124, in main
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/__main__.py", line 138, in process_import
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 22, in to_pyfrm
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/gmsh.py", line 424, in _to_raw_pyfrm
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 193, in get_connectivity
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 167, in _ident_boundary_faces
KeyError: (np.int64(12859), np.int64(12863), np.int64(12940), np.int64(13214))

with periodic interfaces, the error changes to:

Traceback (most recent call last):
  File "~/pyvenv/bin/pyfr", line 33, in <module>
    sys.exit(load_entry_point('pyfr==2.1', 'console_scripts', 'pyfr')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/__main__.py", line 124, in main
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/__main__.py", line 138, in process_import
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 22, in to_pyfrm
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/gmsh.py", line 424, in _to_raw_pyfrm
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 189, in get_connectivity
  File "~/pyvenv/lib/python3.12/site-packages/pyfr-2.1-py3.12.egg/pyfr/readers/base.py", line 151, in _pair_periodic_fluid_faces
KeyError: (np.int64(1056), np.int64(1057), np.int64(12355), np.int64(13577))

In my case, the fix (not necessary ideal) was to use the airfoil with blunt trailing edge.