# How to solve a linear problem A x = b in PETSC when matrix A has zero diagonal enteries?

I am solving a structural mechanics problem that involves setting constraints, and I use Lagrange multipliers to set it. Consequently, some diagonal entries of the tangent stiffness matrix vanish, and I couldn't solve the system using the KSP solver.

I will appreciate any help.

• Are you using the name "pivots" to mean "diagonal entries of $A$"? I always used it to mean "diagonal elements of the $U$ factor of $A=LU$", so I am a bit confused: if a matrix has $U_{kk}=0$ it is singular, at least up to perturbations of the order of machine precision. Nov 29, 2020 at 16:03
• Why can't you use the KSP solvers? That's pretty much exactly what they're meant to be used for. Nov 29, 2020 at 17:51
• Also, what are your constraints? Nov 29, 2020 at 17:51
• @FedericoPoloni Yes, diagonal entries of A. Nov 29, 2020 at 18:31
• @WolfgangBangerth Sir, I used linear solve PCLU. The PETSC couldn't set up the preconditioner even. I got this error- PCSETUP_FAILED due to FACTOR_NUMERIC_ZEROPIVOT. As pointed out in the answer below I tried using PCFIELDSPLIT. I used options " -ksp_type gmres -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_detect_saddle point " . Still I could not succeed. I am not sure if made any mistake. Nov 29, 2020 at 18:45

Use of Lagrange multipliers produces a saddle-point problem, $$\begin{pmatrix} A & B^T \\ B & 0 \end{pmatrix} \begin{pmatrix} u \\ \lambda \end{pmatrix} = \begin{pmatrix} b \\ 0 \end{pmatrix}$$