]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve error handling in UMFPACK wrappers. 18444/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 12 May 2025 02:56:20 +0000 (20:56 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 12 May 2025 02:56:20 +0000 (20:56 -0600)
source/lac/sparse_direct.cc

index 6dae18c2facbec6e8e793b61c7364fb254fc0bf3..f59d6a93166abe0d1bc9b3dd14beb7a097363368 100644 (file)
@@ -364,10 +364,27 @@ SparseDirectUMFPACK::factorize(const Matrix &matrix)
                                 &numeric_decomposition,
                                 control.data(),
                                 nullptr);
-  AssertThrow(status == UMFPACK_OK,
-              ExcUMFPACKError("umfpack_dl_numeric", status));
 
+  // Clean up before we deal with the error code from the calls above:
   umfpack_dl_free_symbolic(&symbolic_decomposition);
+  if (status == UMFPACK_WARNING_singular_matrix)
+    {
+      // UMFPACK sometimes warns that the matrix is singular, but that a
+      // factorization was successful nonetheless. Report this by
+      // throwing an exception that can be caught at a higher level:
+      AssertThrow(false,
+                  ExcMessage(
+                    "UMFPACK reports that the matrix is singular, "
+                    "but that the factorization was successful anyway. "
+                    "You can try and see whether you can still "
+                    "solve a linear system with such a factorization "
+                    "by catching and ignoring this exception, "
+                    "though in practice this will typically not "
+                    "work."));
+    }
+  else
+    AssertThrow(status == UMFPACK_OK,
+                ExcUMFPACKError("umfpack_dl_numeric", status));
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.