Doing the zero pivot thing is a hack and is generally a very bad idea. Looks 
like you should be using a PCFIELDSPLIT preconditioner likely with a 
-pc_fieldsplit_type schur    you can start with the option 
-pc_fieldsplit_detect_saddle_point but in the longer run you likely should 
provide programmatically in the code the IS that defines the "zero block" of 
the matrix.

  Barry



> On Apr 20, 2015, at 10:03 AM, Song Gao <[email protected]> wrote:
> 
> Dear Petsc-users,
> 
> 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: 
> 
>       call KSPGetPC(ksp,preconditioner,ierr)
>       call PCSetType(preconditioner,PCLU,ierr)
>       call PCFactorSetShiftAmount(preconditioner, 100.0D0,ierr)
>       call KSPSetFromOptions(ksp,ierr)
>       call KSPSolve(ksp, pet_rhs, pet_sol_update,ierr)
> 
> But I still get errors here.
> 
> [0]PETSC ERROR: --------------------- Error Message 
> --------------------------------------------------------------
> [0]PETSC ERROR: Zero pivot in LU factorization: 
> http://www.mcs.anl.gov/petsc/documentation/faq.html#ZeroPivot
> [0]PETSC ERROR: Zero pivot row 4 value 0 tolerance 2.22045e-14
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for 
> trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.5.3, Jan, 31, 2015 
> [0]PETSC ERROR: ./ex1f on a FEM_project named anakin by sgao Mon Apr 20 
> 10:23:58 2015
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ 
> --with-fc=gfortran --download-fblaslapack --download-mpich
> [0]PETSC ERROR: #1 MatPivotCheck_none() line 622 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/include/petsc-private/matimpl.h
> [0]PETSC ERROR: #2 MatPivotCheck() line 641 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/include/petsc-private/matimpl.h
> [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
> [0]PETSC ERROR: #4 MatLUFactorNumeric() line 2893 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/mat/interface/matrix.c
> [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
> [0]PETSC ERROR: #6 PCSetUp() line 902 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/pc/interface/precon.c
> [0]PETSC ERROR: #7 KSPSetUp() line 306 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/ksp/interface/itfunc.c
> [0]PETSC ERROR: #8 KSPSolve() line 418 in 
> /home/cfd/sgao/public/for_FEM/petsc-3.5.3/src/ksp/ksp/interface/itfunc.c
> 
> 
> I tried other run time options, but none of them works. Some gives Zero pivot 
> errors, some doesn't converge.       
> 
> ./ex1f -pc_factor_shift_type NONZERO -ksp_monitor_true_residual -ksp_max_it 10
> 
> ./ex1f -pc_factor_shift_type NONZERO -pc_factor_shift_amount 1  
> -ksp_monitor_true_residual -ksp_max_it 10
> 
> ./ex1f -pc_factor_shift_type POSITIVE_DEFINITE -pc_factor_shift_amount 1  
> -ksp_monitor_true_residual -ksp_max_it 10 
> 
> ./ex1f  -pc_factor_nonzeros_along_diagonal -ksp_monitor_true_residual 
> -ksp_max_it 10
> 
> The matrix on a small grid is attached. Thanks 
> <mat.data>

Reply via email to