Safty check for matrix inversion

Hello,

When umfpack direct solver fails to factorize the linear system (due to singularity), the code simply crashes.
Is there a safer way to proceed other than producing the following error message and exit the code?

netgen.libngpy._meshing.NgException: UmfpackInverse: Numeric factorization failed.
I noticed pardiso solver will still proceed with the factorization, but producing nan values.

Best,
Guosheng

Hi Guosheng,

you can use the try - except syntax of Python

try:
    a.mat.Inverse(fes.FreeDofs(), inverse="umfpack")
except:
   print("Singular matrix")
   #...

Then the code does not exit.

Best,
Michael