MFEM  v4.6.0
Finite element discretization library
pardiso.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_PARDISO
13 #define MFEM_PARDISO
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MKL_PARDISO
18 
19 #include "mkl_pardiso.h"
20 #include "operator.hpp"
21 
22 namespace mfem
23 {
24 /**
25  * @brief MKL Parallel Direct Sparse Solver PARDISO
26  *
27  * Interface to MKL PARDISO: the direct sparse solver based on PARDISO
28  */
30 {
31 public:
32  enum MatType
33  {
38  };
39 
40  /**
41  * @brief Construct a new PardisoSolver object
42  *
43  */
44  PardisoSolver();
45 
46  /**
47  * @brief Set the Operator object and perform factorization
48  *
49  * @a op needs to be of type SparseMatrix.
50  *
51  * @param op Operator to use in factorization and solve
52  */
53  void SetOperator(const Operator &op) override;
54 
55  /**
56  * @brief Solve
57  *
58  * @param b RHS vector
59  * @param x Solution vector
60  */
61  void Mult(const Vector &b, Vector &x) const override;
62 
63  /**
64  * @brief Set the print level for MKL Pardiso
65  *
66  * Prints statistics after the factorization and after each solve.
67  *
68  * @param print_lvl Print level
69  */
70  void SetPrintLevel(int print_lvl);
71 
72  /**
73  * @brief Set the matrix type
74  *
75  * The matrix type supported is either real and symmetric or real and
76  * non-symmetric.
77  *
78  * @param mat_type Matrix type
79  */
80  void SetMatrixType(MatType mat_type);
81 
83 
84 private:
85  // Global number of rows
86  int m;
87 
88  // Number of nonzero entries
89  int nnz;
90 
91  // CSR data structure for the copy data of the local CSR matrix
92  int *csr_rowptr = nullptr;
93  double *reordered_csr_nzval = nullptr;
94  int *reordered_csr_colind = nullptr;
95 
96  // Internal solver memory pointer pt,
97  // 32-bit: int pt[64]
98  // 64-bit: long int pt[64] or void *pt[64] should be OK on both architectures
99  mutable void *pt[64] = {0};
100 
101  // Solver control parameters, detailed description can be found in the
102  // constructor.
103  mutable int iparm[64] = {0};
104  mutable int maxfct, mnum, msglvl, phase, error;
105  int mtype;
106  int nrhs;
107 
108  // Dummy variables
109  mutable int idum;
110  mutable double ddum;
111 };
112 } // namespace mfem
113 
114 #endif // MFEM_USE_MKL_PARDISO
115 
116 #endif
void Mult(const Vector &b, Vector &x) const override
Solve.
Definition: pardiso.cpp:107
MKL Parallel Direct Sparse Solver PARDISO.
Definition: pardiso.hpp:29
void SetMatrixType(MatType mat_type)
Set the matrix type.
Definition: pardiso.cpp:123
PardisoSolver()
Construct a new PardisoSolver object.
Definition: pardiso.cpp:21
void SetPrintLevel(int print_lvl)
Set the print level for MKL Pardiso.
Definition: pardiso.cpp:118
double b
Definition: lissajous.cpp:42
void SetOperator(const Operator &op) override
Set the Operator object and perform factorization.
Definition: pardiso.cpp:54
Vector data type.
Definition: vector.hpp:58
Base class for solvers.
Definition: operator.hpp:682
Abstract operator.
Definition: operator.hpp:24