This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

how to use Cholesky factorization as a solver?

0 votes

How would I solve a symmetric linear variational problem using Cholesky factorization? Can anyone point me to an example or provide a few key lines of code.

asked Feb 28, 2015 by dnarnold FEniCS User (2,360 points)

1 Answer

+1 vote
 
Best answer

Hi, after the merge of this pull request Cholesky factorization should be selected automatically if you declare the problem symmetric and chose the lu_solver that supports the factorization. These are MUMPS, PETSC and PASTIX.

method = 'mumps'
symmetric = True

problem = LinearVariationalProblem(a, L, u, bc)
solver = LinearVariationalSolver(problem)
solver.parameters['linear_solver'] = method
solver.parameters['symmetric'] = symmetric

While playing around with different method/symmetric combinations I noticed that PETSc's symmetric solver can get really really slow.

answered Mar 1, 2015 by MiroK FEniCS Expert (80,920 points)
selected Mar 1, 2015 by dnarnold

Thanks for MiroK's answer. I will expand on it a bit for the record. Naturally, one can also use the syntax

solve(a == L, u, bc, solver_parameters={'linear_solver': method, 'symmetric': symmetric})

With either syntax, if the 'linear_solver' parameter is not specified it defaults to 'umfpack', but UMFPACK apparently does not do anything with the 'symmetric' parameter. If 'linear_solver' is 'mumps', then 'symmetric' is honored and there is a significant speed-up (30% for Poisson on a 40x40x40 mesh of the unit cube). If 'linear_solver' is 'petsc', the symmetric parameter has a perverse effect: it results in a very significant slow-down. Thus it seems that the combination {'linear_solver': 'petsc', 'symmetric': True} should never be used, and the best choice for direct solve of a symmetric positive definite problem is {'linear_solver': 'mumps', 'symmetric': True}.

...