xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision 5e8efad83d01ce26f954f35fd18b1c0d811c1bc4)
1 
2 #include "src/ksp/pc/pcimpl.h"                /*I "petscpc.h" I*/
3 
4 #undef __FUNCT__
5 #define __FUNCT__ "PCFactorSetShiftNonzero"
6 /*@
7    PCFactorSetShiftNonzero - adds this quantity to the diagonal of the matrix during
8      numerical factorization, thus the matrix has nonzero pivots
9 
10    Collective on PC
11 
12    Input Parameters:
13 +  shift - amount of shift
14 -  info -
15 
16    Options Database Key:
17 .  -pc_factor_shiftnonzero <shift> - Sets shift amount or PETSC_DECIDE for the default
18 
19    Note: If 0.0 is given, then no shift is used. If a diagonal element is classified as a zero
20          pivot, then the shift is doubled until this is alleviated.
21 
22    Level: intermediate
23 
24 .keywords: PC, set, factorization, direct, fill
25 
26 .seealso: PCFactorSetFill(), PCFactorSetShiftPd()
27 @*/
28 PetscErrorCode PCFactorSetShiftNonzero(PetscReal shift,MatFactorInfo *info)
29 {
30   PetscFunctionBegin;
31   if (shift == (PetscReal) PETSC_DECIDE) {
32     info->damping = 1.e-12;
33   } else {
34     info->damping = shift;
35   }
36   PetscFunctionReturn(0);
37 }
38