8 #ifdef MFEM_USE_MKL_CPARDISO
14 comm_ = MPI_Comm_c2f(comm);
44 mtype = MatType::REAL_NONSYMMETRIC;
53 MFEM_ASSERT(hypreParMat,
"Must pass HypreParMatrix as Operator");
55 auto parcsr_op =
static_cast<hypre_ParCSRMatrix *
>(
58 hypreParMat.HostRead();
59 hypre_CSRMatrix *csr_op = hypre_MergeDiagAndOffd(parcsr_op);
60 hypreParMat.HypreRead();
61 #if MFEM_HYPRE_VERSION >= 21600
62 hypre_CSRMatrixBigJtoJ(csr_op);
65 m = parcsr_op->global_num_rows;
66 first_row = parcsr_op->first_row_index;
67 nnz_loc = csr_op->num_nonzeros;
68 m_loc = csr_op->num_rows;
73 double *csr_nzval = csr_op->data;
74 int *csr_colind = csr_op->j;
77 delete[] reordered_csr_colind;
78 delete[] reordered_csr_nzval;
79 csr_rowptr =
new int[m_loc + 1];
80 reordered_csr_colind =
new int[nnz_loc];
81 reordered_csr_nzval =
new double[nnz_loc];
83 for (
int i = 0; i <= m_loc; i++)
85 csr_rowptr[i] = (csr_op->i)[i];
89 std::vector<int> permutation_idx(nnz_loc);
90 std::iota(permutation_idx.begin(), permutation_idx.end(), 0);
91 for (
int i = 0; i < m_loc; i++)
93 std::sort(permutation_idx.begin() + csr_rowptr[i],
94 permutation_idx.begin() + csr_rowptr[i + 1],
95 [csr_colind](
int i1,
int i2)
97 return csr_colind[i1] < csr_colind[i2];
101 for (
int i = 0; i < nnz_loc; i++)
103 reordered_csr_colind[i] = csr_colind[permutation_idx[i]];
104 reordered_csr_nzval[i] = csr_nzval[permutation_idx[i]];
107 hypre_CSRMatrixDestroy(csr_op);
111 iparm[40] = first_row;
115 iparm[41] = first_row + m_loc - 1;
119 cluster_sparse_solver(pt,
127 reordered_csr_colind,
137 MFEM_ASSERT(error == 0,
"CPardiso analyze input error");
141 cluster_sparse_solver(pt,
149 reordered_csr_colind,
159 MFEM_ASSERT(error == 0,
"CPardiso factorization input error");
166 cluster_sparse_solver(pt,
174 reordered_csr_colind,
184 MFEM_ASSERT(error == 0,
"Pardiso solve error");
189 msglvl = print_level;
201 cluster_sparse_solver(pt,
209 reordered_csr_colind,
219 MFEM_ASSERT(error == 0,
"CPardiso free error");
222 delete[] reordered_csr_colind;
223 delete[] reordered_csr_nzval;
228 #endif // MFEM_USE_MKL_CPARDISO
229 #endif // MFEM_USE_MPI
void Mult(const Vector &b, Vector &x) const override
Solve.
CPardisoSolver(MPI_Comm comm)
Construct a new CPardisoSolver object.
double * GetData() const
Return a pointer to the beginning of the Vector data.
int height
Dimension of the output / number of rows in the matrix.
void SetOperator(const Operator &op) override
Set the Operator object and perform factorization.
void SetPrintLevel(int print_lvl)
Set the print level for MKL CPardiso.
void SetMatrixType(MatType mat_type)
Set the matrix type.
Wrapper for hypre's ParCSR matrix class.
int width
Dimension of the input / number of columns in the matrix.