<div dir="ltr">Dear Petsc-users,<div><br></div><div>I modified the code based on KSP ex1f. I'm solving a 2D stream function vorticity finite element problem. The problem is relatively small, around 2500x2500. I choose to use single processor and LU preconditioner. But the algorithm set some zeros on the diagonals. By checking the PCLU manual page, I think I need shift, the code looks like this: </div><div><br></div><div><div>      call KSPGetPC(ksp,preconditioner,ierr)</div><div>      call PCSetType(preconditioner,PCLU,ierr)</div><div>      call PCFactorSetShiftAmount(preconditioner, 100.0D0,ierr)</div><div>      call KSPSetFromOptions(ksp,ierr)</div><div>      call KSPSolve(ksp, pet_rhs, pet_sol_update,ierr)</div></div><div><br></div><div>But I still get errors here.</div><div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>[0]PETSC ERROR: Zero pivot in LU factorization: <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#ZeroPivot">http://www.mcs.anl.gov/petsc/documentation/faq.html#ZeroPivot</a></div><div>[0]PETSC ERROR: Zero pivot row 4 value 0 tolerance 2.22045e-14</div><div>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: Petsc Release Version 3.5.3, Jan, 31, 2015 </div><div>[0]PETSC ERROR: ./ex1f on a FEM_project named anakin by sgao Mon Apr 20 10:23:58 2015</div><div>[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-fblaslapack --download-mpich</div><div>[0]PETSC ERROR: #1 MatPivotCheck_none() line 622 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/include/petsc-private/matimpl.h</div><div>[0]PETSC ERROR: #2 MatPivotCheck() line 641 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/include/petsc-private/matimpl.h</div><div>[0]PETSC ERROR: #3 MatLUFactorNumeric_SeqAIJ() line 575 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/mat/impls/aij/seq/aijfact.c</div><div>[0]PETSC ERROR: #4 MatLUFactorNumeric() line 2893 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/mat/interface/matrix.c</div><div>[0]PETSC ERROR: #5 PCSetUp_LU() line 152 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/pc/impls/factor/lu/lu.c</div><div>[0]PETSC ERROR: #6 PCSetUp() line 902 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/pc/interface/precon.c</div><div>[0]PETSC ERROR: #7 KSPSetUp() line 306 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/ksp/interface/itfunc.c</div><div>[0]PETSC ERROR: #8 KSPSolve() line 418 in /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/ksp/interface/itfunc.c</div></div><div><br></div><div><br></div><div>I tried other run time options, but none of them works. Some gives Zero pivot errors, some doesn't converge.       </div><div><br></div><div>./ex1f -pc_factor_shift_type NONZERO -ksp_monitor_true_residual -ksp_max_it 10<br></div><div><br></div><div>./ex1f -pc_factor_shift_type NONZERO -pc_factor_shift_amount 1  -ksp_monitor_true_residual -ksp_max_it 10<br></div><div><br></div><div>./ex1f -pc_factor_shift_type POSITIVE_DEFINITE -pc_factor_shift_amount 1  -ksp_monitor_true_residual -ksp_max_it 10 <br></div><div><br></div><div><div>./ex1f  -pc_factor_nonzeros_along_diagonal -ksp_monitor_true_residual -ksp_max_it 10</div></div><div><br></div><div>The matrix on a small grid is attached. Thanks </div></div>