Shape Mismatch in np.linalg.solve in soln-plugin-sampler (sampler.py) Causing ValueError

Nature of bug

Error in using [soln-plugin-sampler] ( associated to sampler.py file)

Error print out (if applicable)

ValueError: solve: Input operand 1 has a mismatch in its core
dimension 0, with gufunc signature (m,m), (m, n) ›(m,n) (size 20 is different from 2)

PyFR information

  • PyFR version: pyfr 2.0.2
  • OS: NAME=CentOS Linux; VERSION=“7 (Core)”
  • System description: Architecture x86_64; Intel(R) Xeon(R) CPU E5-2640 v2 @ 2.00GHz ; NVIDIA v100
  • Compiler and version: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
  • Backend (if applicable): CUDA

Git diff that reproduces bug

diff --git a/pyfr/plugins/sampler.py b/pyfr/plugins/sampler.py
index 818dc81..79dd8e3 100644
--- a/pyfr/plugins/sampler.py
+++ b/pyfr/plugins/sampler.py
@@ -43,7 +43,13 @@ def _plocs_to_tlocs(sbasis, spts, plocs, tlocs):
     for k in range(3):
         jac_ops = sbasis.jac_nodal_basis_at(ktlocs)
         kjplocs = np.einsum('ijk,jkl->kli', jac_ops, spts)
-        ktlocs -= np.linalg.solve(kjplocs, kplocs - plocs)
+       # ktlocs -= np.linalg.solve(kjplocs, kplocs - plocs)
+# Adjust the shape of kplocs - plocs to match kjplocs
+        rhs = (kplocs - plocs)[..., np.newaxis]
+
+# Solve the linear system
+        ktlocs -= np.linalg.solve(kjplocs, rhs).reshape(ktlocs.shape)
+
 
         ops = sbasis.nodal_basis_at(ktlocs)
         np.einsum('ij,jik->ik', ops, spts, out=kplocs)

Please provide an .ini file which reproduces the issue (ideally with a built-in test case).

Regards, Freddie.

As a follow up this appears to be an issue with NumPy v2. A simple workaround is to downgrade to 1.26. Alternatively, you can switch to the current development version of PyFR where this issue is resolved.

Regards, Freddie.

Thank you for the suggestions, Dr. Freddie.