# IndexError: list index out of range, fuzzysort

**URL:** <https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735>\
**Category:** Errors\
**Created:** [9 January 2023 18:17 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735 "2023-01-09T18:17:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [9 January 2023 18:17 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/1 "2023-01-09T18:17:42Z")

</div>

The .ini file I’m using is

```auto
[backend]
precision = double

[backend-openmp]
cc = gcc-12

[constants]
gamma = 1.4
mu = 1.47e-5
Pr = 0.72

M = 0.12
uc = 1.47
rhoc = 1.0

[soln-plugin-writer]
dt-out = 0.02
basedir = .
basename = test-{t:1f}

[solver]
system = navier-stokes
order = 4

[solver-time-integrator]
scheme = rk45
controller = pi
t0 = 0.0
dt = 2.5e-8
atol = 1e-6
rtol = 1e-6
tend = 5

[solver-interfaces]
riemann-solver = rusanov
ldg-beta = 0.5
ldg-tau = 0.1

[solver-interfaces-line]
flux-pts = gauss-legendre
quad-deg = 10
quad-pts = gauss-legendre

[solver-interfaces-quad]
flux-pts = gauss-legendre
quad-deg = 10
quad-pts = gauss-legendre

[solver-elements-hex]
soln-pts = gauss-legendre
quad-deg = 10
quad-pts = gauss-legendre

[solver-elements-pri]
soln-pts = williams-shunn~gauss-legendre
quad-deg = 10
quad-pts = williams-shunn~gauss-legendre

[solver-interfaces-tri]
flux-pts = williams-shunn
quad-deg = 10
quad-pts = williams-shunn

[soln-bcs-wall]
type = no-slp-adia-wall

[soln-bcs-inflow]
type = char-riem-inv
rho = rhoc
u = uc
v = 0
w = 0
p = rhoc*uc*uc/(M*M*gamma)

[soln-bcs-outflow]
type = char-riem-inv
p = rhoc*uc*uc/(M*M*gamma)
u = uc
v = 0
w = 0
rho = rhoc

[soln-ics]
rho = rhoc
u = uc
v = 0
w = 0
p = rhoc*uc*uc/(M*M*gamma)

```

And the error I get is:

```auto
Traceback (most recent call last):
  File "/opt/homebrew/bin/pyfr", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 118, in main
    args.process(args)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 251, in process_run
    _process_common(
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 236, in _process_common
    solver = get_solver(backend, rallocs, mesh, soln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/ __init__.py", line 16, in get_solver
    return get_integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/ __init__.py", line 36, in get_integrator
    return integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/controllers.py", line 91, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/controllers.py", line 13, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/steppers.py", line 133, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/base.py", line 26, in __init__
    self.system = systemcls(backend, rallocs, mesh, initsoln,
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/system.py", line 58, in __init__
    int_inters = self._load_int_inters(rallocs, mesh, elemap)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/system.py", line 130, in _load_int_inters
    int_inters = self.intinterscls(self.backend, lhs, rhs, elemap,
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/navstokes/inters.py", line 24, in __init__
    super(). __init__ (be, lhs, rhs, elemap, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/navstokes/inters.py", line 12, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvecdiff/inters.py", line 10, in __init__
    super(). __init__ (be, lhs, rhs, elemap, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvec/inters.py", line 15, in __init__
    self._gen_perm(lhs, rhs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvecdiff/inters.py", line 33, in _gen_perm
    self._perm = self._get_perm_for_view(side, 'get_scal_fpts_for_inter')
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 65, in _get_perm_for_view
    vm = _get_inter_objs(inter, meth, self.elemap)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 11, in _get_inter_objs
    return [emap[type](eidx, fidx) for type, eidx, fidx, flags in interside]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 11, in <listcomp>
    return [emap[type](eidx, fidx) for type, eidx, fidx, flags in interside]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 387, in get_scal_fpts_for_inter
    rmap = self._srtd_face_fpts[fidx][eidx]
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in _srtd_face_fpts
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in <listcomp>
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in <listcomp>
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 96, in fuzzysort
    srtdidx[i:j] = fuzzysort(arr, srtdidx[i:j], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 100, in fuzzysort
    srtdidx[i:] = fuzzysort(arr, srtdidx[i:], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 96, in fuzzysort
    srtdidx[i:j] = fuzzysort(arr, srtdidx[i:j], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 88, in fuzzysort
    arrd = arr[dim]
IndexError: list index out of range
[192.168.1.55:05655] [[49021,0],0] ORTE_ERROR_LOG: Data unpack would read past end of buffer in file util/show_help.c at line 501
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 3 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
[192.168.1.55:05655] PMIX ERROR: UNREACHABLE in file server/pmix_server.c at line 2198
Traceback (most recent call last):
  File "/opt/homebrew/bin/pyfr", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 118, in main
    args.process(args)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 251, in process_run
    _process_common(
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/ __main__.py", line 236, in _process_common
    solver = get_solver(backend, rallocs, mesh, soln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/ __init__.py", line 16, in get_solver
    return get_integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/ __init__.py", line 36, in get_integrator
    return integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/controllers.py", line 91, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/controllers.py", line 13, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/steppers.py", line 133, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/integrators/std/base.py", line 26, in __init__
    self.system = systemcls(backend, rallocs, mesh, initsoln,
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/system.py", line 58, in __init__
    int_inters = self._load_int_inters(rallocs, mesh, elemap)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/system.py", line 130, in _load_int_inters
    int_inters = self.intinterscls(self.backend, lhs, rhs, elemap,
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/navstokes/inters.py", line 24, in __init__
    super(). __init__ (be, lhs, rhs, elemap, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/navstokes/inters.py", line 12, in __init__
    super(). __init__ (*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvecdiff/inters.py", line 10, in __init__
    super(). __init__ (be, lhs, rhs, elemap, cfg)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvec/inters.py", line 15, in __init__
    self._gen_perm(lhs, rhs)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/baseadvecdiff/inters.py", line 33, in _gen_perm
    self._perm = self._get_perm_for_view(side, 'get_scal_fpts_for_inter')
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 65, in _get_perm_for_view
    vm = _get_inter_objs(inter, meth, self.elemap)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 11, in _get_inter_objs
    return [emap[type](eidx, fidx) for type, eidx, fidx, flags in interside]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/inters.py", line 11, in <listcomp>
    return [emap[type](eidx, fidx) for type, eidx, fidx, flags in interside]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 387, in get_scal_fpts_for_inter
    rmap = self._srtd_face_fpts[fidx][eidx]
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in _srtd_face_fpts
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in <listcomp>
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/solvers/base/elements.py", line 110, in <listcomp>
    return [[np.array(fuzzysort(pts.tolist(), ffpts)) for pts in plocfpts]
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 96, in fuzzysort
    srtdidx[i:j] = fuzzysort(arr, srtdidx[i:j], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 100, in fuzzysort
    srtdidx[i:] = fuzzysort(arr, srtdidx[i:], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 96, in fuzzysort
    srtdidx[i:j] = fuzzysort(arr, srtdidx[i:j], dim + 1, tol)
  File "/opt/homebrew/lib/python3.10/site-packages/pyfr/nputil.py", line 88, in fuzzysort
    arrd = arr[dim]
IndexError: list index out of range

```

Any idea on how to solve?

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [10 January 2023 09:48 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/2 "2023-01-10T09:48:50Z")

</div>

Given yor very small time step I’m assuming you have some very small elements. The fuzzy sort called at pyfr.solvers.base.elements.py line 110 can take a tolernece argument, you can either try scaling up your case (which is probably the best thing to do) or you can try changing the tolerence.

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [10 January 2023 10:22 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/3 "2023-01-10T10:22:17Z")

</div>

Changing the time step or the tolerance seemed to not have solved the issue and I get the same error again

The new .ini file is:

```auto
[backend]
precision = double

[backend-openmp]
cc = gcc-12

[constants]
gamma = 1.4
mu = 1.47e-5
Pr = 0.72

M = 0.12
uc = 1.47
rhoc = 1.0

[soln-plugin-writer]
dt-out = 0.02
basedir = .
basename = NRELS826-{t:1f}

[solver]
system = navier-stokes
order = 4

[solver-time-integrator]
scheme = rk45
controller = pi
t0 = 0.0
dt = 2.5e-1
atol = 1e-2
rtol = 1e-2
tend = 5

[solver-interfaces]
riemann-solver = rusanov
ldg-beta = 0.5
ldg-tau = 0.1

[solver-interfaces-quad]
flux-pts = gauss-legendre

[solver-elements-hex]
soln-pts = gauss-legendre

[solver-elements-pri]
soln-pts = williams-shunn~gauss-legendre
quad-deg = 10
quad-pts = williams-shunn~gauss-legendre

[solver-interfaces-tri]
flux-pts = williams-shunn
quad-deg = 10
quad-pts = williams-shunn

[soln-bcs-wall]
type = no-slp-adia-wall

[soln-bcs-inlet]
type = char-riem-inv
rho = rhoc
u = uc
v = 0
w = 0
p = rhoc*uc*uc/(M*M*gamma)

[soln-bcs-outlet]
type = char-riem-inv
p = rhoc*uc*uc/(M*M*gamma)
u = uc
v = 0
w = 0
rho = rhoc

[soln-ics]
rho = rhoc
u = uc
v = 0
w = 0
p = rhoc*uc*uc/(M*M*gamma)

```

Any further suggestion?

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [10 January 2023 11:47 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/4 "2023-01-10T11:47:39Z")

</div>

Changing the time step size wouldn’t/shouldn’t change this, I meant scaling up the mesh so that the mesh spacing was larger in absolute terms but the non-dimensional groups were the same.

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [10 January 2023 12:06 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/5 "2023-01-10T12:06:35Z")

</div>

Ok I got you, but my issue is related to the necessity of having yplus = 1, if I remesh to get yplus = 5 it works fine (mesh scaled up).

Any idea on how to deal with an element (first element in boundary layer) which has a dimension of ~4e-5? How I can access the tolerance of the fuzzy sort algorithm to allow such small elements?

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [10 January 2023 13:00 UTC](https://pyfr.discourse.group/t/indexerror-list-index-out-of-range-fuzzysort/735/6 "2023-01-10T13:00:13Z")

</div>

The tolerence for the fuzzysort is an optional argument that you can set this is the functions prototype:

```auto
def fuzzysort(arr, idx, dim=0, tol=1e-6):
   ...

```

Also what I meant was scale eveything up, so you’re dx/yplus shouldn’t change.
