MFEM  v4.4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
cpardiso.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, 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_CPARDISO
13 #define MFEM_CPARDISO
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 #ifdef MFEM_USE_MKL_CPARDISO
19 
20 #include "mkl_cluster_sparse_solver.h"
21 #include "operator.hpp"
22 
23 namespace mfem
24 {
25 /**
26  * @brief MKL Parallel Direct Sparse Solver for Clusters
27  *
28  * Interface to MKL CPardiso: the MPI-enabled Intel MKL version of Pardiso
29  */
30 class CPardisoSolver : public Solver
31 {
32 public:
33  enum MatType
34  {
37  };
38 
39  /**
40  * @brief Construct a new CPardisoSolver object
41  *
42  * @param comm MPI Communicator
43  */
44  CPardisoSolver(MPI_Comm comm);
45 
46  /**
47  * @brief Set the Operator object and perform factorization
48  *
49  * @a op needs to be of type HypreParMatrix. The contents are copied and
50  * reordered in an internal CSR structure.
51  *
52  * @param op Operator to use in factorization and solve
53  */
54  void SetOperator(const Operator &op) override;
55 
56  /**
57  * @brief Solve
58  *
59  * @param b RHS vector
60  * @param x Solution vector
61  */
62  void Mult(const Vector &b, Vector &x) const override;
63 
64  /**
65  * @brief Set the print level for MKL CPardiso
66  *
67  * Prints statistics after the factorization and after each solve.
68  *
69  * @param print_lvl Print level
70  */
71  void SetPrintLevel(int print_lvl);
72 
73  /**
74  * @brief Set the matrix type
75  *
76  * The matrix type supported is either real and symmetric or real and
77  * non-symmetric.
78  *
79  * @param mat_type Matrix type
80  */
81  void SetMatrixType(MatType mat_type);
82 
84 
85 private:
86  MPI_Fint comm_;
87 
88  // Global number of rows
89  int m;
90 
91  // First row index of the global matrix on the local MPI rank
92  int first_row;
93 
94  // Local number of nonzero entries
95  int nnz_loc;
96 
97  // Local number of rows, obtained from a ParCSR matrix
98  int m_loc;
99 
100  // CSR data structure for the copy data of the local CSR matrix
101  int *csr_rowptr = nullptr;
102  double *reordered_csr_nzval = nullptr;
103  int *reordered_csr_colind = nullptr;
104 
105  // Internal solver memory pointer pt,
106  // 32-bit: int pt[64]
107  // 64-bit: long int pt[64] or void *pt[64] should be OK on both architectures
108  mutable void *pt[64] = {0};
109 
110  // Solver control parameters, detailed description can be found in the
111  // constructor.
112  mutable int iparm[64] = {0};
113  mutable int maxfct, mnum, msglvl, phase, error;
114  int mtype;
115  int nrhs;
116 
117  // Dummy variables
118  mutable int idum;
119  mutable double ddum;
120 };
121 } // namespace mfem
122 
123 #endif
124 #endif // MFEM_USE_MKL_CPARDISO
125 #endif // MFEM_USE_MPI
void Mult(const Vector &b, Vector &x) const override
Solve.
Definition: cpardiso.cpp:160
CPardisoSolver(MPI_Comm comm)
Construct a new CPardisoSolver object.
Definition: cpardiso.cpp:12
double b
Definition: lissajous.cpp:42
void SetOperator(const Operator &op) override
Set the Operator object and perform factorization.
Definition: cpardiso.cpp:49
Vector data type.
Definition: vector.hpp:60
void SetPrintLevel(int print_lvl)
Set the print level for MKL CPardiso.
Definition: cpardiso.cpp:185
void SetMatrixType(MatType mat_type)
Set the matrix type.
Definition: cpardiso.cpp:190
Base class for solvers.
Definition: operator.hpp:651
Abstract operator.
Definition: operator.hpp:24
MKL Parallel Direct Sparse Solver for Clusters.
Definition: cpardiso.hpp:30