From bd755d6c555bfcef2061d55bb8acc01840ae43b0 Mon Sep 17 00:00:00 2001
From: "Praetorius, Simon" <simon.praetorius@tu-dresden.de>
Date: Wed, 28 Aug 2019 11:11:44 +0200
Subject: [PATCH] added error messages to umfpack error codes

---
 src/amdis/linearalgebra/mtl/UmfpackRunner.hpp | 28 +++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp
index 0f5729a6..546d25d0 100644
--- a/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp
+++ b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp
@@ -52,7 +52,7 @@ namespace AMDiS
       try {
         solver_.reset(new SolverType(matrix, symmetricStrategy_, allocInit_));
       } catch (mtl::mat::umfpack::error const& e) {
-        error_exit("UMFPACK_ERROR(factorize, {}) = {}", e.code, e.what());
+        umfpack_error_exit("factorize", e.code);
       }
     }
 
@@ -68,7 +68,7 @@ namespace AMDiS
       try {
         code = (*solver_)(x, b);
       } catch (mtl::mat::umfpack::error& e) {
-        error_exit("UMFPACK_ERROR(solve, {}) = {}", e.code, e.what());
+        umfpack_error_exit("solve", e.code);
       }
 
       auto r = Vector(b);
@@ -81,6 +81,30 @@ namespace AMDiS
       return code;
     }
 
+    static void umfpack_error_exit(std::string solutionPhase, int code)
+    {
+      static std::map<int, std::string> error_message = {
+        {UMFPACK_OK, "UMFPACK was successful"},
+        {UMFPACK_WARNING_singular_matrix, "Matrix is singular. There are exact zeros on the diagonal."},
+        {UMFPACK_WARNING_determinant_underflow, "The determinant is nonzero, but smaller in magnitude than the smallest positive floating-point number."},
+        {UMFPACK_WARNING_determinant_overflow, "The determinant is larger in magnitude than the largest positive floating-point number (IEEE Inf)."},
+        {UMFPACK_ERROR_out_of_memory, "Not enough memory. The ANSI C malloc or realloc routine failed."},
+        {UMFPACK_ERROR_invalid_Numeric_object, "Invalid Numeric object."},
+        {UMFPACK_ERROR_invalid_Symbolic_object, "Invalid Symbolic object."},
+        {UMFPACK_ERROR_argument_missing, "Some required arguments are missing."},
+        {UMFPACK_ERROR_n_nonpositive, "The number of rows or columns of the matrix must be greater than zero."},
+        {UMFPACK_ERROR_invalid_matrix, "The matrix is invalid."},
+        {UMFPACK_ERROR_different_pattern, "The pattern of the matrix has changed between the symbolic and numeric factorization."},
+        {UMFPACK_ERROR_invalid_system, "The sys argument provided to one of the solve routines is invalid."},
+        {UMFPACK_ERROR_invalid_permutation, "The permutation vector provided as input is invalid."},
+        {UMFPACK_ERROR_file_IO, "Error in file IO"},
+        {UMFPACK_ERROR_ordering_failed, "The ordering method failed."},
+        {UMFPACK_ERROR_internal_error, "An internal error has occurred, of unknown cause."}
+      };
+
+      error_exit("UMFPACK_ERROR({}, {}) = {}", solutionPhase, code, error_message[code]);
+    }
+
   protected:
     std::shared_ptr<SolverType> solver_;
 
-- 
GitLab