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 hypre_CSRMatrix *csr_op = hypre_MergeDiagAndOffd(parcsr_op);
59 #if MFEM_HYPRE_VERSION >= 21600
60 hypre_CSRMatrixBigJtoJ(csr_op);
63 m = parcsr_op->global_num_rows;
64 first_row = parcsr_op->first_row_index;
65 nnz_loc = csr_op->num_nonzeros;
66 m_loc = csr_op->num_rows;
71 double *csr_nzval = csr_op->data;
72 int *csr_colind = csr_op->j;
75 delete[] reordered_csr_colind;
76 delete[] reordered_csr_nzval;
77 csr_rowptr =
new int[m_loc + 1];
78 reordered_csr_colind =
new int[nnz_loc];
79 reordered_csr_nzval =
new double[nnz_loc];
81 for (
int i = 0; i <= m_loc; i++)
83 csr_rowptr[i] = (csr_op->i)[i];
87 std::vector<int> permutation_idx(nnz_loc);
88 std::iota(permutation_idx.begin(), permutation_idx.end(), 0);
89 for (
int i = 0; i < m_loc; i++)
91 std::sort(permutation_idx.begin() + csr_rowptr[i],
92 permutation_idx.begin() + csr_rowptr[i + 1],
93 [csr_colind](
int i1,
int i2)
95 return csr_colind[i1] < csr_colind[i2];
99 for (
int i = 0; i < nnz_loc; i++)
101 reordered_csr_colind[i] = csr_colind[permutation_idx[i]];
102 reordered_csr_nzval[i] = csr_nzval[permutation_idx[i]];
105 hypre_CSRMatrixDestroy(csr_op);
109 iparm[40] = first_row;
113 iparm[41] = first_row + m_loc - 1;
117 cluster_sparse_solver(pt,
125 reordered_csr_colind,
135 MFEM_ASSERT(error == 0,
"CPardiso analyze input error");
139 cluster_sparse_solver(pt,
147 reordered_csr_colind,
157 MFEM_ASSERT(error == 0,
"CPardiso factorization input error");
164 cluster_sparse_solver(pt,
172 reordered_csr_colind,
182 MFEM_ASSERT(error == 0,
"Pardiso solve error");
187 msglvl = print_level;
199 cluster_sparse_solver(pt,
207 reordered_csr_colind,
217 MFEM_ASSERT(error == 0,
"CPardiso free error");
220 delete[] reordered_csr_colind;
221 delete[] reordered_csr_nzval;
226 #endif // MFEM_USE_MKL_CPARDISO
227 #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.