1 #define PETSCKSP_DLL 2 3 #include "private/pcimpl.h" /*I "petscpc.h" I*/ 4 5 #undef __FUNCT__ 6 #define __FUNCT__ "PCFactorSetZeroPivot" 7 /*@ 8 PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero 9 10 Collective on PC 11 12 Input Parameters: 13 + pc - the preconditioner context 14 - zero - all pivots smaller than this will be considered zero 15 16 Options Database Key: 17 . -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot 18 19 Level: intermediate 20 21 .keywords: PC, set, factorization, direct, fill 22 23 .seealso: PCFactorSetShiftNonzero(), PCFactorSetShiftPd() 24 @*/ 25 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetZeroPivot(PC pc,PetscReal zero) 26 { 27 PetscErrorCode ierr,(*f)(PC,PetscReal); 28 29 PetscFunctionBegin; 30 PetscValidHeaderSpecific(pc,PC_COOKIE,1); 31 ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetZeroPivot_C",(void (**)(void))&f);CHKERRQ(ierr); 32 if (f) { 33 ierr = (*f)(pc,zero);CHKERRQ(ierr); 34 } 35 PetscFunctionReturn(0); 36 } 37 38 #undef __FUNCT__ 39 #define __FUNCT__ "PCFactorSetShiftNonzero" 40 /*@ 41 PCFactorSetShiftNonzero - adds this quantity to the diagonal of the matrix during 42 numerical factorization, thus the matrix has nonzero pivots 43 44 Collective on PC 45 46 Input Parameters: 47 + pc - the preconditioner context 48 - shift - amount of shift 49 50 Options Database Key: 51 . -pc_factor_shift_nonzero <shift> - Sets shift amount or PETSC_DECIDE for the default 52 53 Note: If 0.0 is given, then no shift is used. If a diagonal element is classified as a zero 54 pivot, then the shift is doubled until this is alleviated. 55 56 Level: intermediate 57 58 .keywords: PC, set, factorization, direct, fill 59 60 .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftPd() 61 @*/ 62 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftNonzero(PC pc,PetscReal shift) 63 { 64 PetscErrorCode ierr,(*f)(PC,PetscReal); 65 66 PetscFunctionBegin; 67 PetscValidHeaderSpecific(pc,PC_COOKIE,1); 68 ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetShiftNonzero_C",(void (**)(void))&f);CHKERRQ(ierr); 69 if (f) { 70 ierr = (*f)(pc,shift);CHKERRQ(ierr); 71 } 72 PetscFunctionReturn(0); 73 } 74 75 #undef __FUNCT__ 76 #define __FUNCT__ "PCFactorSetShiftPd" 77 /*@ 78 PCFactorSetShiftPd - specify whether to use Manteuffel shifting. 79 If a matrix factorisation breaks down because of nonpositive pivots, 80 adding sufficient identity to the diagonal will remedy this. 81 Setting this causes a bisection method to find the minimum shift that 82 will lead to a well-defined matrix factor. 83 84 Collective on PC 85 86 Input parameters: 87 + pc - the preconditioner context 88 - shifting - PETSC_TRUE to set shift else PETSC_FALSE 89 90 Options Database Key: 91 . -pc_factor_shift_positive_definite [PETSC_TRUE/PETSC_FALSE] - Activate/Deactivate PCFactorSetShiftPd(); the value 92 is optional with PETSC_TRUE being the default 93 94 Level: intermediate 95 96 .keywords: PC, indefinite, factorization 97 98 .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftNonzero() 99 @*/ 100 PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftPd(PC pc,PetscTruth shift) 101 { 102 PetscErrorCode ierr,(*f)(PC,PetscTruth); 103 104 PetscFunctionBegin; 105 PetscValidHeaderSpecific(pc,PC_COOKIE,1); 106 ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetShiftPd_C",(void (**)(void))&f);CHKERRQ(ierr); 107 if (f) { 108 ierr = (*f)(pc,shift);CHKERRQ(ierr); 109 } 110 PetscFunctionReturn(0); 111 } 112