1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12 // Authors: Dario Mangoni, Radu Serban
13 // =============================================================================
14 
15 #include "chrono_pardisomkl/ChSolverPardisoMKL.h"
16 #include "chrono/parallel/ChOpenMP.h"
17 
18 namespace chrono {
19 
ChSolverPardisoMKL(int num_threads)20 ChSolverPardisoMKL::ChSolverPardisoMKL(int num_threads) {
21     int nthreads = (num_threads <= 0) ? ChOMP::GetNumProcs() : num_threads;
22     ChOMP::SetNumThreads(nthreads);
23 }
24 
FactorizeMatrix()25 bool ChSolverPardisoMKL::FactorizeMatrix() {
26     m_engine.compute(m_mat);
27     return (m_engine.info() == Eigen::Success);
28 }
29 
SolveSystem()30 bool ChSolverPardisoMKL::SolveSystem() {
31     m_sol = m_engine.solve(m_rhs);
32     return (m_engine.info() == Eigen::Success);
33 }
34 
PrintErrorMessage()35 void ChSolverPardisoMKL::PrintErrorMessage() {
36     // There are only three possible return codes (see manageErrorCode in Eigen's PardisoSupport.h)
37     switch (m_engine.info()) {
38         case Eigen::Success:
39             GetLog() << "computation was successful";
40             break;
41         case Eigen::NumericalIssue:
42             GetLog() << "provided data did not satisfy the prerequisites";
43             break;
44         case Eigen::InvalidInput:
45             GetLog() << "inputs are invalid, or the algorithm has been improperly called";
46             break;
47         case Eigen::NoConvergence:
48             // Not a possible error for Pardiso
49             break;
50     }
51 }
52 
53 }  // end of namespace chrono
54