xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision 4bcd6097eb738ae87d3212ea8c9aa03077eaf145)
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 - options for factorization
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->shiftnz = 1.e-12;
33   } else {
34     info->shiftnz = shift;
35   }
36   PetscFunctionReturn(0);
37 }
38 
39 #undef __FUNCT__
40 #define __FUNCT__ "PCFactorSetShiftPd"
41 /*@
42    PCFactorSetShiftPd - specify whether to use Manteuffel shifting.
43    If a matrix factorisation breaks down because of nonpositive pivots,
44    adding sufficient identity to the diagonal will remedy this.
45    Setting this causes a bisection method to find the minimum shift that
46    will lead to a well-defined matrix factor.
47 
48    Collective on PC
49 
50    Input parameters:
51 +  shifting - PETSC_TRUE to set shift else PETSC_FALSE
52 -  info - options for factorization
53 
54    Options Database Key:
55 .  -pc_factor_shift [1/0] - Activate/Deactivate PCFactorSetShiftPd(); the value
56    is optional with 1 being the default
57 
58    Level: intermediate
59 
60 .keywords: PC, indefinite, factorization
61 
62 .seealso: PCFactorSetShiftNonzero()
63 @*/
64 PetscErrorCode PCFactorSetShiftPd(PetscTruth shifting,MatFactorInfo *info)
65 {
66   PetscFunctionBegin;
67   info->shiftpd = shifting;
68   PetscFunctionReturn(0);
69 }
70 
71 
72