[petsc-users] Reuse symbolic factorization with petsc - mumps

Jose E. Roman jroman at dsic.upv.es
Thu Feb 17 03:17:43 CST 2022


Since version 3.5, KSPSetOperators() will check if the passed matrix has the same sparse pattern as the previously set one, so you don't have to do anything.

The list of changes in version 3.5 has this note:
"KSPSetOperators() no longer has the MatStructure argument. The Mat objects now track that information themselves. Use KSP/PCSetReusePreconditioner() to prevent the recomputation of the preconditioner if the operator changed in the way that SAME_PRECONDITIONER did with KSPSetOperators()."

You don't call MatLUFactorSymbolic() yourself, it is called internally. You can check with -log_view if the number of calls to MatLUFactorSymbolic() is as expected.

Jose



> El 17 feb 2022, a las 9:42, 459543524 via petsc-users <petsc-users at mcs.anl.gov> escribió:
> 
> Sir, I have a problem when using petsc.
> 
> I want to solve a series of linear equations.
> 
> A1*x1=b1, A2*x2=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 when using MUMPS.
> 
> 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)
> However, this API seems depreacted.
> see https://lists.mcs.anl.gov/pipermail/petsc-users/2013-March/016646.html
> 
> I have see there exist API: MatLUFactorSymbolic,  MatLUFactorNumeric(). but I have no idea how to call it.
> 
> Could you please give me an example how to reuse the symbolic factorization when using MUMPS in petsc?
> 
> Thanks for your time.
> 
> Xu Hui
> 
> 
>  



More information about the petsc-users mailing list