I have a problem when using petsc.
I want to solve a series of linear equations.
A1x1=b1, A2x2=b2, A3*x3=b3 ...
The A1,A2,A3 have the same sparstiy pattern.
I want to use MUMPS to solve the system. In order to enhance performance, I want to reuse the symbolic factorization.
Here my code for solve a single linear system is
Mat A, P, F;
PC pc;
Vec rhs_vec, result_vec;
KSPSetOperators(ksp, A, A);
KSPSetType(ksp, KSPPREONLY);
KSPGetPC(ksp, &pc);
PCSetType(pc, PCLU);
PCFactorSetMatSolverType(pc, MATSOLVERMUMPS);
PCFactorSetUpMatSolverType(pc);
PCFactorGetMatrix(pc, &F);
MatMumpsSetIcntl(F, 7, 5); // configure mumps.
KSPSolve(ksp, rhs_vec, result_vec);
I have no idea how to reuse symbolic factorization.
I have see the information from interent. The petsc developper have suggested that using:
KSPSetOperators(KSP_A, A, A, DIFFERENT_NONZERO_PATTERN)
KSPSetOperators(KSP_A, A, A, SAME_NONZERO_PATTERN)
see https://lists.mcs.anl.gov/pipermail/petsc-users/2013-March/016646.html However, this API seems depreacted.
I have see there exist API: MatLUFactorSymbolic
, MatLUFactorNumeric()
. but I have no idea how to call it.
How to reuse the symbolic factorization when using MUMPS in petsc?
Thanks for your time.