15e8efad8SHong Zhang 2c6db04a5SJed Brown #include <../src/ksp/pc/impls/factor/factor.h> /*I "petscpc.h" I*/ 35e8efad8SHong Zhang 4ee45ca4aSHong Zhang #undef __FUNCT__ 5f8260c8fSBarry Smith #define __FUNCT__ "PCFactorSetUpMatSolverPackage" 6f8260c8fSBarry Smith /*@ 7f8260c8fSBarry Smith PCFactorSetUpMatSolverPackage - Can be called after KSPSetOperators() or PCSetOperators(), causes MatGetFactor() to be called so then one may 8f8260c8fSBarry Smith set the options for that particular factorization object. 9f8260c8fSBarry Smith 10f8260c8fSBarry Smith Input Parameter: 11f8260c8fSBarry Smith . pc - the preconditioner context 12f8260c8fSBarry Smith 13f8260c8fSBarry Smith Notes: After you have called this function (which has to be after the KSPSetOperators() or PCSetOperators()) you can call PCFactorGetMatrix() and then set factor options on that matrix. 14f8260c8fSBarry Smith 15f8260c8fSBarry Smith .seealso: PCFactorSetMatSolverPackage(), PCFactorGetMatrix() 16f8260c8fSBarry Smith 172bd2b0e6SSatish Balay Level: intermediate 182bd2b0e6SSatish Balay 19f8260c8fSBarry Smith @*/ 20f8260c8fSBarry Smith PetscErrorCode PCFactorSetUpMatSolverPackage(PC pc) 21f8260c8fSBarry Smith { 22f8260c8fSBarry Smith PetscErrorCode ierr; 23f8260c8fSBarry Smith 24f8260c8fSBarry Smith PetscFunctionBegin; 25f8260c8fSBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 26f8260c8fSBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetUpMatSolverPackage_C",(PC),(pc));CHKERRQ(ierr); 27b3a44c85SBarry Smith PetscFunctionReturn(0); 28f8260c8fSBarry Smith } 29f8260c8fSBarry Smith 30f8260c8fSBarry Smith #undef __FUNCT__ 31ee45ca4aSHong Zhang #define __FUNCT__ "PCFactorSetZeroPivot" 32ee45ca4aSHong Zhang /*@ 33ee45ca4aSHong Zhang PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero 34ee45ca4aSHong Zhang 35ad4df100SBarry Smith Logically Collective on PC 36ee45ca4aSHong Zhang 37ee45ca4aSHong Zhang Input Parameters: 38afaefe49SHong Zhang + pc - the preconditioner context 39afaefe49SHong Zhang - zero - all pivots smaller than this will be considered zero 40ee45ca4aSHong Zhang 41ee45ca4aSHong Zhang Options Database Key: 42ee45ca4aSHong Zhang . -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot 43ee45ca4aSHong Zhang 44ee45ca4aSHong Zhang Level: intermediate 45ee45ca4aSHong Zhang 46ee45ca4aSHong Zhang .keywords: PC, set, factorization, direct, fill 47ee45ca4aSHong Zhang 48daa17b54SHong Zhang .seealso: PCFactorSetShiftType(), PCFactorSetShiftAmount() 49ee45ca4aSHong Zhang @*/ 507087cfbeSBarry Smith PetscErrorCode PCFactorSetZeroPivot(PC pc,PetscReal zero) 51ee45ca4aSHong Zhang { 524ac538c5SBarry Smith PetscErrorCode ierr; 53afaefe49SHong Zhang 54ee45ca4aSHong Zhang PetscFunctionBegin; 550700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 56c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,zero,2); 574ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetZeroPivot_C",(PC,PetscReal),(pc,zero));CHKERRQ(ierr); 58ee45ca4aSHong Zhang PetscFunctionReturn(0); 59ee45ca4aSHong Zhang } 60ee45ca4aSHong Zhang 615e8efad8SHong Zhang #undef __FUNCT__ 62d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftType" 63915743fcSHong Zhang /*@ 64915743fcSHong Zhang PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during 65915743fcSHong Zhang numerical factorization, thus the matrix has nonzero pivots 66915743fcSHong Zhang 67ad4df100SBarry Smith Logically Collective on PC 68915743fcSHong Zhang 69915743fcSHong Zhang Input Parameters: 70915743fcSHong Zhang + pc - the preconditioner context 71915743fcSHong Zhang - shifttype - type of shift; one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO, MAT_SHIFT_POSITIVE_DEFINITE, MAT_SHIFT_INBLOCKS 72915743fcSHong Zhang 73915743fcSHong Zhang Options Database Key: 74915743fcSHong Zhang . -pc_factor_shift_type <shifttype> - Sets shift type or PETSC_DECIDE for the default; use '-help' for a list of available types 75915743fcSHong Zhang 76915743fcSHong Zhang Level: intermediate 77915743fcSHong Zhang 78915743fcSHong Zhang .keywords: PC, set, factorization, 79915743fcSHong Zhang 80915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftAmount() 81915743fcSHong Zhang @*/ 827087cfbeSBarry Smith PetscErrorCode PCFactorSetShiftType(PC pc,MatFactorShiftType shifttype) 83d90ac83dSHong Zhang { 844ac538c5SBarry Smith PetscErrorCode ierr; 85d90ac83dSHong Zhang 86d90ac83dSHong Zhang PetscFunctionBegin; 870700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 88c5eb9154SBarry Smith PetscValidLogicalCollectiveEnum(pc,shifttype,2); 894ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetShiftType_C",(PC,MatFactorShiftType),(pc,shifttype));CHKERRQ(ierr); 90d90ac83dSHong Zhang PetscFunctionReturn(0); 91d90ac83dSHong Zhang } 92d90ac83dSHong Zhang 93d90ac83dSHong Zhang #undef __FUNCT__ 94d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftAmount" 95915743fcSHong Zhang /*@ 96915743fcSHong Zhang PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during 97915743fcSHong Zhang numerical factorization, thus the matrix has nonzero pivots 98915743fcSHong Zhang 99ad4df100SBarry Smith Logically Collective on PC 100915743fcSHong Zhang 101915743fcSHong Zhang Input Parameters: 102915743fcSHong Zhang + pc - the preconditioner context 103915743fcSHong Zhang - shiftamount - amount of shift 104915743fcSHong Zhang 105915743fcSHong Zhang Options Database Key: 106915743fcSHong Zhang . -pc_factor_shift_amount <shiftamount> - Sets shift amount or PETSC_DECIDE for the default 107915743fcSHong Zhang 108915743fcSHong Zhang Level: intermediate 109915743fcSHong Zhang 110915743fcSHong Zhang .keywords: PC, set, factorization, 111915743fcSHong Zhang 112915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftType() 113915743fcSHong Zhang @*/ 1147087cfbeSBarry Smith PetscErrorCode PCFactorSetShiftAmount(PC pc,PetscReal shiftamount) 115d90ac83dSHong Zhang { 1164ac538c5SBarry Smith PetscErrorCode ierr; 117d90ac83dSHong Zhang 118d90ac83dSHong Zhang PetscFunctionBegin; 1190700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 120c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,shiftamount,2); 1214ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetShiftAmount_C",(PC,PetscReal),(pc,shiftamount));CHKERRQ(ierr); 122d90ac83dSHong Zhang PetscFunctionReturn(0); 123d90ac83dSHong Zhang } 124d90ac83dSHong Zhang 125d90ac83dSHong Zhang #undef __FUNCT__ 126b7c853c4SBarry Smith #define __FUNCT__ "PCFactorSetDropTolerance" 12778fc6b22SHong Zhang /* 128b7c853c4SBarry Smith PCFactorSetDropTolerance - The preconditioner will use an ILU 12978fc6b22SHong Zhang based on a drop tolerance. (Under development) 13085317021SBarry Smith 131ad4df100SBarry Smith Logically Collective on PC 13285317021SBarry Smith 13385317021SBarry Smith Input Parameters: 13485317021SBarry Smith + pc - the preconditioner context 13585317021SBarry Smith . dt - the drop tolerance, try from 1.e-10 to .1 13685317021SBarry Smith . dtcol - tolerance for column pivot, good values [0.1 to 0.01] 13785317021SBarry Smith - maxrowcount - the max number of nonzeros allowed in a row, best value 13885317021SBarry Smith depends on the number of nonzeros in row of original matrix 13985317021SBarry Smith 14085317021SBarry Smith Options Database Key: 141b7c853c4SBarry Smith . -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance 14285317021SBarry Smith 14385317021SBarry Smith Level: intermediate 14485317021SBarry Smith 14585317021SBarry Smith There are NO default values for the 3 parameters, you must set them with reasonable values for your 14685317021SBarry Smith matrix. We don't know how to compute reasonable values. 14785317021SBarry Smith 14885317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, ILU 14978fc6b22SHong Zhang */ 1507087cfbeSBarry Smith PetscErrorCode PCFactorSetDropTolerance(PC pc,PetscReal dt,PetscReal dtcol,PetscInt maxrowcount) 15185317021SBarry Smith { 1524ac538c5SBarry Smith PetscErrorCode ierr; 15385317021SBarry Smith 15485317021SBarry Smith PetscFunctionBegin; 1550700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 156c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,dtcol,2); 157c5eb9154SBarry Smith PetscValidLogicalCollectiveInt(pc,maxrowcount,3); 1584ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetDropTolerance_C",(PC,PetscReal,PetscReal,PetscInt),(pc,dt,dtcol,maxrowcount));CHKERRQ(ierr); 15985317021SBarry Smith PetscFunctionReturn(0); 16085317021SBarry Smith } 16185317021SBarry Smith 16285317021SBarry Smith #undef __FUNCT__ 1632591b318SToby Isaac #define __FUNCT__ "PCFactorGetLevels" 1642591b318SToby Isaac /*@ 1652591b318SToby Isaac PCFactorGetLevels - Gets the number of levels of fill to use. 1662591b318SToby Isaac 1672591b318SToby Isaac Logically Collective on PC 1682591b318SToby Isaac 1692591b318SToby Isaac Input Parameters: 1702591b318SToby Isaac . pc - the preconditioner context 1712591b318SToby Isaac 1722591b318SToby Isaac Output Parameter: 1732591b318SToby Isaac . levels - number of levels of fill 1742591b318SToby Isaac 1752591b318SToby Isaac Level: intermediate 1762591b318SToby Isaac 1772591b318SToby Isaac .keywords: PC, levels, fill, factorization, incomplete, ILU 1782591b318SToby Isaac @*/ 1792591b318SToby Isaac PetscErrorCode PCFactorGetLevels(PC pc,PetscInt *levels) 1802591b318SToby Isaac { 1812591b318SToby Isaac PetscErrorCode ierr; 1822591b318SToby Isaac 1832591b318SToby Isaac PetscFunctionBegin; 1842591b318SToby Isaac PetscValidHeaderSpecific(pc,PC_CLASSID,1); 1852591b318SToby Isaac ierr = PetscTryMethod(pc,"PCFactorGetLevels_C",(PC,PetscInt*),(pc,levels));CHKERRQ(ierr); 1862591b318SToby Isaac PetscFunctionReturn(0); 1872591b318SToby Isaac } 1882591b318SToby Isaac 1892591b318SToby Isaac #undef __FUNCT__ 19085317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels" 19185317021SBarry Smith /*@ 19285317021SBarry Smith PCFactorSetLevels - Sets the number of levels of fill to use. 19385317021SBarry Smith 194ad4df100SBarry Smith Logically Collective on PC 19585317021SBarry Smith 19685317021SBarry Smith Input Parameters: 19785317021SBarry Smith + pc - the preconditioner context 19885317021SBarry Smith - levels - number of levels of fill 19985317021SBarry Smith 20085317021SBarry Smith Options Database Key: 20185317021SBarry Smith . -pc_factor_levels <levels> - Sets fill level 20285317021SBarry Smith 20385317021SBarry Smith Level: intermediate 20485317021SBarry Smith 20585317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 20685317021SBarry Smith @*/ 2077087cfbeSBarry Smith PetscErrorCode PCFactorSetLevels(PC pc,PetscInt levels) 20885317021SBarry Smith { 2094ac538c5SBarry Smith PetscErrorCode ierr; 21085317021SBarry Smith 21185317021SBarry Smith PetscFunctionBegin; 2120700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 213ce94432eSBarry Smith if (levels < 0) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_OUTOFRANGE,"negative levels"); 214c5eb9154SBarry Smith PetscValidLogicalCollectiveInt(pc,levels,2); 2154ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetLevels_C",(PC,PetscInt),(pc,levels));CHKERRQ(ierr); 21685317021SBarry Smith PetscFunctionReturn(0); 21785317021SBarry Smith } 21885317021SBarry Smith 21985317021SBarry Smith #undef __FUNCT__ 22085317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill" 22185317021SBarry Smith /*@ 22285317021SBarry Smith PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be 22385317021SBarry Smith treated as level 0 fill even if there is no non-zero location. 22485317021SBarry Smith 225ad4df100SBarry Smith Logically Collective on PC 22685317021SBarry Smith 22785317021SBarry Smith Input Parameters: 22885317021SBarry Smith + pc - the preconditioner context 22985317021SBarry Smith 23085317021SBarry Smith Options Database Key: 23185317021SBarry Smith . -pc_factor_diagonal_fill 23285317021SBarry Smith 23385317021SBarry Smith Notes: 23485317021SBarry Smith Does not apply with 0 fill. 23585317021SBarry Smith 23685317021SBarry Smith Level: intermediate 23785317021SBarry Smith 23885317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 23985317021SBarry Smith @*/ 2407087cfbeSBarry Smith PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc) 24185317021SBarry Smith { 2424ac538c5SBarry Smith PetscErrorCode ierr; 24385317021SBarry Smith 24485317021SBarry Smith PetscFunctionBegin; 2450700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 2464ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC),(pc));CHKERRQ(ierr); 24785317021SBarry Smith PetscFunctionReturn(0); 24885317021SBarry Smith } 24985317021SBarry Smith 25085317021SBarry Smith #undef __FUNCT__ 25185317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal" 25285317021SBarry Smith /*@ 25385317021SBarry Smith PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal 25485317021SBarry Smith 255ad4df100SBarry Smith Logically Collective on PC 25685317021SBarry Smith 25785317021SBarry Smith Input Parameters: 25885317021SBarry Smith + pc - the preconditioner context 25985317021SBarry Smith - tol - diagonal entries smaller than this in absolute value are considered zero 26085317021SBarry Smith 26185317021SBarry Smith Options Database Key: 26285317021SBarry Smith . -pc_factor_nonzeros_along_diagonal 26385317021SBarry Smith 26485317021SBarry Smith Level: intermediate 26585317021SBarry Smith 26685317021SBarry Smith .keywords: PC, set, factorization, direct, fill 26785317021SBarry Smith 26885317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal() 26985317021SBarry Smith @*/ 2707087cfbeSBarry Smith PetscErrorCode PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol) 27185317021SBarry Smith { 2724ac538c5SBarry Smith PetscErrorCode ierr; 27385317021SBarry Smith 27485317021SBarry Smith PetscFunctionBegin; 2750700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 276c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,rtol,2); 2774ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr); 27885317021SBarry Smith PetscFunctionReturn(0); 27985317021SBarry Smith } 28085317021SBarry Smith 28185317021SBarry Smith #undef __FUNCT__ 28285317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage" 283bf6011e8SBarry Smith /*@C 28485317021SBarry Smith PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization 28585317021SBarry Smith 286ad4df100SBarry Smith Logically Collective on PC 28785317021SBarry Smith 28885317021SBarry Smith Input Parameters: 28985317021SBarry Smith + pc - the preconditioner context 290f60c3dc2SHong Zhang - stype - for example, superlu, superlu_dist 29185317021SBarry Smith 29285317021SBarry Smith Options Database Key: 293f60c3dc2SHong Zhang . -pc_factor_mat_solver_package <stype> - petsc, superlu, superlu_dist, mumps, cusparse 29485317021SBarry Smith 29585317021SBarry Smith Level: intermediate 29685317021SBarry Smith 29785317021SBarry Smith Note: 29885317021SBarry Smith By default this will use the PETSc factorization if it exists 29985317021SBarry Smith 30085317021SBarry Smith 30185317021SBarry Smith .keywords: PC, set, factorization, direct, fill 30285317021SBarry Smith 3037112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 30485317021SBarry Smith 30585317021SBarry Smith @*/ 3067087cfbeSBarry Smith PetscErrorCode PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype) 30785317021SBarry Smith { 3084ac538c5SBarry Smith PetscErrorCode ierr; 30985317021SBarry Smith 31085317021SBarry Smith PetscFunctionBegin; 3110700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 3124ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr); 31385317021SBarry Smith PetscFunctionReturn(0); 31485317021SBarry Smith } 31585317021SBarry Smith 31685317021SBarry Smith #undef __FUNCT__ 3177112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage" 318bf6011e8SBarry Smith /*@C 3197112b564SBarry Smith PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization 3207112b564SBarry Smith 321c5eb9154SBarry Smith Not Collective 3227112b564SBarry Smith 3237112b564SBarry Smith Input Parameter: 3247112b564SBarry Smith . pc - the preconditioner context 3257112b564SBarry Smith 3267112b564SBarry Smith Output Parameter: 3270298fd71SBarry Smith . stype - for example, superlu, superlu_dist (NULL if the PC does not have a solver package) 3287112b564SBarry Smith 3297112b564SBarry Smith Level: intermediate 3307112b564SBarry Smith 3317112b564SBarry Smith 3327112b564SBarry Smith .keywords: PC, set, factorization, direct, fill 3337112b564SBarry Smith 3347112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 3357112b564SBarry Smith 3367112b564SBarry Smith @*/ 3377087cfbeSBarry Smith PetscErrorCode PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype) 3387112b564SBarry Smith { 3398b5c83b4SJed Brown PetscErrorCode ierr,(*f)(PC,const MatSolverPackage*); 3407112b564SBarry Smith 3417112b564SBarry Smith PetscFunctionBegin; 3420700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 3430005d66cSJed Brown ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorGetMatSolverPackage_C",&f);CHKERRQ(ierr); 3448b5c83b4SJed Brown if (f) { 3458b5c83b4SJed Brown ierr = (*f)(pc,stype);CHKERRQ(ierr); 3468b5c83b4SJed Brown } else { 3470298fd71SBarry Smith *stype = NULL; 3488b5c83b4SJed Brown } 3497112b564SBarry Smith PetscFunctionReturn(0); 3507112b564SBarry Smith } 3517112b564SBarry Smith 3527112b564SBarry Smith #undef __FUNCT__ 35385317021SBarry Smith #define __FUNCT__ "PCFactorSetFill" 35485317021SBarry Smith /*@ 35585317021SBarry Smith PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix, 35685317021SBarry Smith fill = number nonzeros in factor/number nonzeros in original matrix. 35785317021SBarry Smith 358c5eb9154SBarry Smith Not Collective, each process can expect a different amount of fill 35985317021SBarry Smith 36085317021SBarry Smith Input Parameters: 36185317021SBarry Smith + pc - the preconditioner context 36285317021SBarry Smith - fill - amount of expected fill 36385317021SBarry Smith 36485317021SBarry Smith Options Database Key: 36585317021SBarry Smith . -pc_factor_fill <fill> - Sets fill amount 36685317021SBarry Smith 36785317021SBarry Smith Level: intermediate 36885317021SBarry Smith 36985317021SBarry Smith Note: 37085317021SBarry Smith For sparse matrix factorizations it is difficult to predict how much 37185317021SBarry Smith fill to expect. By running with the option -info PETSc will print the 37285317021SBarry Smith actual amount of fill used; allowing you to set the value accurately for 37385317021SBarry Smith future runs. Default PETSc uses a value of 5.0 37485317021SBarry Smith 37501a79839SBarry Smith This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels. 37601a79839SBarry Smith 37701a79839SBarry Smith 37885317021SBarry Smith .keywords: PC, set, factorization, direct, fill 37985317021SBarry Smith 38085317021SBarry Smith @*/ 3817087cfbeSBarry Smith PetscErrorCode PCFactorSetFill(PC pc,PetscReal fill) 38285317021SBarry Smith { 3834ac538c5SBarry Smith PetscErrorCode ierr; 38485317021SBarry Smith 38585317021SBarry Smith PetscFunctionBegin; 3860700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 387ce94432eSBarry Smith if (fill < 1.0) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0"); 3884ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr); 38985317021SBarry Smith PetscFunctionReturn(0); 39085317021SBarry Smith } 39185317021SBarry Smith 39285317021SBarry Smith #undef __FUNCT__ 39385317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace" 39485317021SBarry Smith /*@ 39585317021SBarry Smith PCFactorSetUseInPlace - Tells the system to do an in-place factorization. 39685317021SBarry Smith For dense matrices, this enables the solution of much larger problems. 39785317021SBarry Smith For sparse matrices the factorization cannot be done truly in-place 39885317021SBarry Smith so this does not save memory during the factorization, but after the matrix 39985317021SBarry Smith is factored, the original unfactored matrix is freed, thus recovering that 40085317021SBarry Smith space. 40185317021SBarry Smith 402ad4df100SBarry Smith Logically Collective on PC 40385317021SBarry Smith 40485317021SBarry Smith Input Parameters: 405*8e37d05fSBarry Smith + pc - the preconditioner context 406*8e37d05fSBarry Smith - flg - PETSC_TRUE to enable, PETSC_FALSE to disable 40785317021SBarry Smith 40885317021SBarry Smith Options Database Key: 409*8e37d05fSBarry Smith . -pc_factor_in_place <true,false>- Activate/deactivate in-place factorization 41085317021SBarry Smith 41185317021SBarry Smith Notes: 41285317021SBarry Smith PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when 41385317021SBarry Smith a different matrix is provided for the multiply and the preconditioner in 41485317021SBarry Smith a call to KSPSetOperators(). 41585317021SBarry Smith This is because the Krylov space methods require an application of the 41685317021SBarry Smith matrix multiplication, which is not possible here because the matrix has 41785317021SBarry Smith been factored in-place, replacing the original matrix. 41885317021SBarry Smith 41985317021SBarry Smith Level: intermediate 42085317021SBarry Smith 42185317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU 42285317021SBarry Smith 423*8e37d05fSBarry Smith .seealso: PCFactorGetUseInPlace() 42485317021SBarry Smith @*/ 425*8e37d05fSBarry Smith PetscErrorCode PCFactorSetUseInPlace(PC pc,PetscBool flg) 42685317021SBarry Smith { 4274ac538c5SBarry Smith PetscErrorCode ierr; 42885317021SBarry Smith 42985317021SBarry Smith PetscFunctionBegin; 4300700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 431*8e37d05fSBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC,PetscBool),(pc,flg));CHKERRQ(ierr); 432*8e37d05fSBarry Smith PetscFunctionReturn(0); 433*8e37d05fSBarry Smith } 434*8e37d05fSBarry Smith 435*8e37d05fSBarry Smith #undef __FUNCT__ 436*8e37d05fSBarry Smith #define __FUNCT__ "PCFactorGetUseInPlace" 437*8e37d05fSBarry Smith /*@ 438*8e37d05fSBarry Smith PCFactorGetUseInPlace - Determines if an in-place factorization is being used. 439*8e37d05fSBarry Smith 440*8e37d05fSBarry Smith Logically Collective on PC 441*8e37d05fSBarry Smith 442*8e37d05fSBarry Smith Input Parameter: 443*8e37d05fSBarry Smith . pc - the preconditioner context 444*8e37d05fSBarry Smith 445*8e37d05fSBarry Smith Output Parameter: 446*8e37d05fSBarry Smith . flg - PETSC_TRUE to enable, PETSC_FALSE to disable 447*8e37d05fSBarry Smith 448*8e37d05fSBarry Smith Level: intermediate 449*8e37d05fSBarry Smith 450*8e37d05fSBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU 451*8e37d05fSBarry Smith 452*8e37d05fSBarry Smith .seealso: PCFactorSetUseInPlace() 453*8e37d05fSBarry Smith @*/ 454*8e37d05fSBarry Smith PetscErrorCode PCFactorGetUseInPlace(PC pc,PetscBool *flg) 455*8e37d05fSBarry Smith { 456*8e37d05fSBarry Smith PetscErrorCode ierr; 457*8e37d05fSBarry Smith 458*8e37d05fSBarry Smith PetscFunctionBegin; 459*8e37d05fSBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 460*8e37d05fSBarry Smith ierr = PetscTryMethod(pc,"PCFactorGetUseInPlace_C",(PC,PetscBool*),(pc,flg));CHKERRQ(ierr); 46185317021SBarry Smith PetscFunctionReturn(0); 46285317021SBarry Smith } 46385317021SBarry Smith 46485317021SBarry Smith #undef __FUNCT__ 46585317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType" 46685317021SBarry Smith /*@C 46785317021SBarry Smith PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to 46885317021SBarry Smith be used in the LU factorization. 46985317021SBarry Smith 470ad4df100SBarry Smith Logically Collective on PC 47185317021SBarry Smith 47285317021SBarry Smith Input Parameters: 47385317021SBarry Smith + pc - the preconditioner context 4742692d6eeSBarry Smith - ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM 47585317021SBarry Smith 47685317021SBarry Smith Options Database Key: 47785317021SBarry Smith . -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine 47885317021SBarry Smith 47985317021SBarry Smith Level: intermediate 48085317021SBarry Smith 48185317021SBarry Smith Notes: nested dissection is used by default 48285317021SBarry Smith 48385317021SBarry Smith For Cholesky and ICC and the SBAIJ format reorderings are not available, 48485317021SBarry Smith since only the upper triangular part of the matrix is stored. You can use the 48585317021SBarry Smith SeqAIJ format in this case to get reorderings. 48685317021SBarry Smith 48785317021SBarry Smith @*/ 48819fd82e9SBarry Smith PetscErrorCode PCFactorSetMatOrderingType(PC pc,MatOrderingType ordering) 48985317021SBarry Smith { 4904ac538c5SBarry Smith PetscErrorCode ierr; 49185317021SBarry Smith 49285317021SBarry Smith PetscFunctionBegin; 493c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 49419fd82e9SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,MatOrderingType),(pc,ordering));CHKERRQ(ierr); 49585317021SBarry Smith PetscFunctionReturn(0); 49685317021SBarry Smith } 49785317021SBarry Smith 49885317021SBarry Smith #undef __FUNCT__ 4998ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot" 50085317021SBarry Smith /*@ 5018ff23777SHong Zhang PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization. 50285317021SBarry Smith For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices 503e3c5b3baSBarry Smith it is never done. For the MATLAB and SuperLU factorization this is used. 50485317021SBarry Smith 505ad4df100SBarry Smith Logically Collective on PC 50685317021SBarry Smith 50785317021SBarry Smith Input Parameters: 50885317021SBarry Smith + pc - the preconditioner context 50985317021SBarry Smith - dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable) 51085317021SBarry Smith 51185317021SBarry Smith Options Database Key: 51285317021SBarry Smith . -pc_factor_pivoting <dtcol> 51385317021SBarry Smith 51485317021SBarry Smith Level: intermediate 51585317021SBarry Smith 51685317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks() 51785317021SBarry Smith @*/ 5187087cfbeSBarry Smith PetscErrorCode PCFactorSetColumnPivot(PC pc,PetscReal dtcol) 51985317021SBarry Smith { 5204ac538c5SBarry Smith PetscErrorCode ierr; 52185317021SBarry Smith 52285317021SBarry Smith PetscFunctionBegin; 523c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 524c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,dtcol,2); 5254ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr); 52685317021SBarry Smith PetscFunctionReturn(0); 52785317021SBarry Smith } 52885317021SBarry Smith 52985317021SBarry Smith #undef __FUNCT__ 53085317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks" 53185317021SBarry Smith /*@ 53285317021SBarry Smith PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block 53385317021SBarry Smith with BAIJ or SBAIJ matrices 53485317021SBarry Smith 535ad4df100SBarry Smith Logically Collective on PC 53685317021SBarry Smith 53785317021SBarry Smith Input Parameters: 53885317021SBarry Smith + pc - the preconditioner context 53985317021SBarry Smith - pivot - PETSC_TRUE or PETSC_FALSE 54085317021SBarry Smith 54185317021SBarry Smith Options Database Key: 54285317021SBarry Smith . -pc_factor_pivot_in_blocks <true,false> 54385317021SBarry Smith 54485317021SBarry Smith Level: intermediate 54585317021SBarry Smith 5468ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot() 54785317021SBarry Smith @*/ 5487087cfbeSBarry Smith PetscErrorCode PCFactorSetPivotInBlocks(PC pc,PetscBool pivot) 54985317021SBarry Smith { 5504ac538c5SBarry Smith PetscErrorCode ierr; 55185317021SBarry Smith 55285317021SBarry Smith PetscFunctionBegin; 553c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 554acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,pivot,2); 5554ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr); 55685317021SBarry Smith PetscFunctionReturn(0); 55785317021SBarry Smith } 55885317021SBarry Smith 55985317021SBarry Smith #undef __FUNCT__ 56085317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill" 56185317021SBarry Smith /*@ 56285317021SBarry Smith PCFactorSetReuseFill - When matrices with same different nonzero structure are factored, 56385317021SBarry Smith this causes later ones to use the fill ratio computed in the initial factorization. 56485317021SBarry Smith 565ad4df100SBarry Smith Logically Collective on PC 56685317021SBarry Smith 56785317021SBarry Smith Input Parameters: 56885317021SBarry Smith + pc - the preconditioner context 56985317021SBarry Smith - flag - PETSC_TRUE to reuse else PETSC_FALSE 57085317021SBarry Smith 57185317021SBarry Smith Options Database Key: 57285317021SBarry Smith . -pc_factor_reuse_fill - Activates PCFactorSetReuseFill() 57385317021SBarry Smith 57485317021SBarry Smith Level: intermediate 57585317021SBarry Smith 57685317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky 57785317021SBarry Smith 57885317021SBarry Smith .seealso: PCFactorSetReuseOrdering() 57985317021SBarry Smith @*/ 5807087cfbeSBarry Smith PetscErrorCode PCFactorSetReuseFill(PC pc,PetscBool flag) 58185317021SBarry Smith { 5824ac538c5SBarry Smith PetscErrorCode ierr; 58385317021SBarry Smith 58485317021SBarry Smith PetscFunctionBegin; 5850700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,2); 586acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,flag,2); 5874ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr); 58885317021SBarry Smith PetscFunctionReturn(0); 58985317021SBarry Smith } 590