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); 185*c60c7ad4SBarry Smith ierr = PetscUseMethod(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 22992e9c092SBarry Smith - flg - PETSC_TRUE to turn on, PETSC_FALSE to turn off 23085317021SBarry Smith 23185317021SBarry Smith Options Database Key: 23285317021SBarry Smith . -pc_factor_diagonal_fill 23385317021SBarry Smith 23485317021SBarry Smith Notes: 23585317021SBarry Smith Does not apply with 0 fill. 23685317021SBarry Smith 23785317021SBarry Smith Level: intermediate 23885317021SBarry Smith 23985317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 24092e9c092SBarry Smith 24192e9c092SBarry Smith .seealso: PCFactorGetAllowDiagonalFill() 24292e9c092SBarry Smith 24385317021SBarry Smith @*/ 24492e9c092SBarry Smith PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc,PetscBool flg) 24585317021SBarry Smith { 2464ac538c5SBarry Smith PetscErrorCode ierr; 24785317021SBarry Smith 24885317021SBarry Smith PetscFunctionBegin; 2490700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 25092e9c092SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC,PetscBool),(pc,flg));CHKERRQ(ierr); 25192e9c092SBarry Smith PetscFunctionReturn(0); 25292e9c092SBarry Smith } 25392e9c092SBarry Smith 25492e9c092SBarry Smith #undef __FUNCT__ 25592e9c092SBarry Smith #define __FUNCT__ "PCFactorGetAllowDiagonalFill" 25692e9c092SBarry Smith /*@ 25792e9c092SBarry Smith PCFactorGetAllowDiagonalFill - Determines if all diagonal matrix entries are 25892e9c092SBarry Smith treated as level 0 fill even if there is no non-zero location. 25992e9c092SBarry Smith 26092e9c092SBarry Smith Logically Collective on PC 26192e9c092SBarry Smith 26292e9c092SBarry Smith Input Parameter: 26392e9c092SBarry Smith . pc - the preconditioner context 26492e9c092SBarry Smith 26592e9c092SBarry Smith Output Parameter: 26692e9c092SBarry Smith . flg - PETSC_TRUE to turn on, PETSC_FALSE to turn off 26792e9c092SBarry Smith 26892e9c092SBarry Smith Options Database Key: 26992e9c092SBarry Smith . -pc_factor_diagonal_fill 27092e9c092SBarry Smith 27192e9c092SBarry Smith Notes: 27292e9c092SBarry Smith Does not apply with 0 fill. 27392e9c092SBarry Smith 27492e9c092SBarry Smith Level: intermediate 27592e9c092SBarry Smith 27692e9c092SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 27792e9c092SBarry Smith 27892e9c092SBarry Smith .seealso: PCFactorSetAllowDiagonalFill() 27992e9c092SBarry Smith 28092e9c092SBarry Smith @*/ 28192e9c092SBarry Smith PetscErrorCode PCFactorGetAllowDiagonalFill(PC pc,PetscBool *flg) 28292e9c092SBarry Smith { 28392e9c092SBarry Smith PetscErrorCode ierr; 28492e9c092SBarry Smith 28592e9c092SBarry Smith PetscFunctionBegin; 28692e9c092SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 287*c60c7ad4SBarry Smith ierr = PetscUseMethod(pc,"PCFactorGetAllowDiagonalFill_C",(PC,PetscBool*),(pc,flg));CHKERRQ(ierr); 28885317021SBarry Smith PetscFunctionReturn(0); 28985317021SBarry Smith } 29085317021SBarry Smith 29185317021SBarry Smith #undef __FUNCT__ 29285317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal" 29385317021SBarry Smith /*@ 29485317021SBarry Smith PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal 29585317021SBarry Smith 296ad4df100SBarry Smith Logically Collective on PC 29785317021SBarry Smith 29885317021SBarry Smith Input Parameters: 29985317021SBarry Smith + pc - the preconditioner context 30085317021SBarry Smith - tol - diagonal entries smaller than this in absolute value are considered zero 30185317021SBarry Smith 30285317021SBarry Smith Options Database Key: 30392e9c092SBarry Smith . -pc_factor_nonzeros_along_diagonal <tol> 30485317021SBarry Smith 30585317021SBarry Smith Level: intermediate 30685317021SBarry Smith 30785317021SBarry Smith .keywords: PC, set, factorization, direct, fill 30885317021SBarry Smith 30985317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal() 31085317021SBarry Smith @*/ 3117087cfbeSBarry Smith PetscErrorCode PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol) 31285317021SBarry Smith { 3134ac538c5SBarry Smith PetscErrorCode ierr; 31485317021SBarry Smith 31585317021SBarry Smith PetscFunctionBegin; 3160700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 317c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,rtol,2); 3184ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr); 31985317021SBarry Smith PetscFunctionReturn(0); 32085317021SBarry Smith } 32185317021SBarry Smith 32285317021SBarry Smith #undef __FUNCT__ 32385317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage" 324bf6011e8SBarry Smith /*@C 32585317021SBarry Smith PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization 32685317021SBarry Smith 327ad4df100SBarry Smith Logically Collective on PC 32885317021SBarry Smith 32985317021SBarry Smith Input Parameters: 33085317021SBarry Smith + pc - the preconditioner context 331f60c3dc2SHong Zhang - stype - for example, superlu, superlu_dist 33285317021SBarry Smith 33385317021SBarry Smith Options Database Key: 334f60c3dc2SHong Zhang . -pc_factor_mat_solver_package <stype> - petsc, superlu, superlu_dist, mumps, cusparse 33585317021SBarry Smith 33685317021SBarry Smith Level: intermediate 33785317021SBarry Smith 33885317021SBarry Smith Note: 33985317021SBarry Smith By default this will use the PETSc factorization if it exists 34085317021SBarry Smith 34185317021SBarry Smith 34285317021SBarry Smith .keywords: PC, set, factorization, direct, fill 34385317021SBarry Smith 3447112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 34585317021SBarry Smith 34685317021SBarry Smith @*/ 3477087cfbeSBarry Smith PetscErrorCode PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype) 34885317021SBarry Smith { 3494ac538c5SBarry Smith PetscErrorCode ierr; 35085317021SBarry Smith 35185317021SBarry Smith PetscFunctionBegin; 3520700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 3534ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr); 35485317021SBarry Smith PetscFunctionReturn(0); 35585317021SBarry Smith } 35685317021SBarry Smith 35785317021SBarry Smith #undef __FUNCT__ 3587112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage" 359bf6011e8SBarry Smith /*@C 3607112b564SBarry Smith PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization 3617112b564SBarry Smith 362c5eb9154SBarry Smith Not Collective 3637112b564SBarry Smith 3647112b564SBarry Smith Input Parameter: 3657112b564SBarry Smith . pc - the preconditioner context 3667112b564SBarry Smith 3677112b564SBarry Smith Output Parameter: 3680298fd71SBarry Smith . stype - for example, superlu, superlu_dist (NULL if the PC does not have a solver package) 3697112b564SBarry Smith 3707112b564SBarry Smith Level: intermediate 3717112b564SBarry Smith 3727112b564SBarry Smith 3737112b564SBarry Smith .keywords: PC, set, factorization, direct, fill 3747112b564SBarry Smith 3757112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 3767112b564SBarry Smith 3777112b564SBarry Smith @*/ 3787087cfbeSBarry Smith PetscErrorCode PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype) 3797112b564SBarry Smith { 3808b5c83b4SJed Brown PetscErrorCode ierr,(*f)(PC,const MatSolverPackage*); 3817112b564SBarry Smith 3827112b564SBarry Smith PetscFunctionBegin; 3830700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 3840005d66cSJed Brown ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorGetMatSolverPackage_C",&f);CHKERRQ(ierr); 3858b5c83b4SJed Brown if (f) { 3868b5c83b4SJed Brown ierr = (*f)(pc,stype);CHKERRQ(ierr); 3878b5c83b4SJed Brown } else { 3880298fd71SBarry Smith *stype = NULL; 3898b5c83b4SJed Brown } 3907112b564SBarry Smith PetscFunctionReturn(0); 3917112b564SBarry Smith } 3927112b564SBarry Smith 3937112b564SBarry Smith #undef __FUNCT__ 39485317021SBarry Smith #define __FUNCT__ "PCFactorSetFill" 39585317021SBarry Smith /*@ 39685317021SBarry Smith PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix, 39785317021SBarry Smith fill = number nonzeros in factor/number nonzeros in original matrix. 39885317021SBarry Smith 399c5eb9154SBarry Smith Not Collective, each process can expect a different amount of fill 40085317021SBarry Smith 40185317021SBarry Smith Input Parameters: 40285317021SBarry Smith + pc - the preconditioner context 40385317021SBarry Smith - fill - amount of expected fill 40485317021SBarry Smith 40585317021SBarry Smith Options Database Key: 40685317021SBarry Smith . -pc_factor_fill <fill> - Sets fill amount 40785317021SBarry Smith 40885317021SBarry Smith Level: intermediate 40985317021SBarry Smith 41085317021SBarry Smith Note: 41185317021SBarry Smith For sparse matrix factorizations it is difficult to predict how much 41285317021SBarry Smith fill to expect. By running with the option -info PETSc will print the 41385317021SBarry Smith actual amount of fill used; allowing you to set the value accurately for 41485317021SBarry Smith future runs. Default PETSc uses a value of 5.0 41585317021SBarry Smith 41601a79839SBarry Smith This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels. 41701a79839SBarry Smith 41801a79839SBarry Smith 41985317021SBarry Smith .keywords: PC, set, factorization, direct, fill 42085317021SBarry Smith 42185317021SBarry Smith @*/ 4227087cfbeSBarry Smith PetscErrorCode PCFactorSetFill(PC pc,PetscReal fill) 42385317021SBarry Smith { 4244ac538c5SBarry Smith PetscErrorCode ierr; 42585317021SBarry Smith 42685317021SBarry Smith PetscFunctionBegin; 4270700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 428ce94432eSBarry Smith if (fill < 1.0) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0"); 4294ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr); 43085317021SBarry Smith PetscFunctionReturn(0); 43185317021SBarry Smith } 43285317021SBarry Smith 43385317021SBarry Smith #undef __FUNCT__ 43485317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace" 43585317021SBarry Smith /*@ 43685317021SBarry Smith PCFactorSetUseInPlace - Tells the system to do an in-place factorization. 43785317021SBarry Smith For dense matrices, this enables the solution of much larger problems. 43885317021SBarry Smith For sparse matrices the factorization cannot be done truly in-place 43985317021SBarry Smith so this does not save memory during the factorization, but after the matrix 44085317021SBarry Smith is factored, the original unfactored matrix is freed, thus recovering that 44185317021SBarry Smith space. 44285317021SBarry Smith 443ad4df100SBarry Smith Logically Collective on PC 44485317021SBarry Smith 44585317021SBarry Smith Input Parameters: 4468e37d05fSBarry Smith + pc - the preconditioner context 4478e37d05fSBarry Smith - flg - PETSC_TRUE to enable, PETSC_FALSE to disable 44885317021SBarry Smith 44985317021SBarry Smith Options Database Key: 4508e37d05fSBarry Smith . -pc_factor_in_place <true,false>- Activate/deactivate in-place factorization 45185317021SBarry Smith 45285317021SBarry Smith Notes: 45385317021SBarry Smith PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when 45485317021SBarry Smith a different matrix is provided for the multiply and the preconditioner in 45585317021SBarry Smith a call to KSPSetOperators(). 45685317021SBarry Smith This is because the Krylov space methods require an application of the 45785317021SBarry Smith matrix multiplication, which is not possible here because the matrix has 45885317021SBarry Smith been factored in-place, replacing the original matrix. 45985317021SBarry Smith 46085317021SBarry Smith Level: intermediate 46185317021SBarry Smith 46285317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU 46385317021SBarry Smith 4648e37d05fSBarry Smith .seealso: PCFactorGetUseInPlace() 46585317021SBarry Smith @*/ 4668e37d05fSBarry Smith PetscErrorCode PCFactorSetUseInPlace(PC pc,PetscBool flg) 46785317021SBarry Smith { 4684ac538c5SBarry Smith PetscErrorCode ierr; 46985317021SBarry Smith 47085317021SBarry Smith PetscFunctionBegin; 4710700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 4728e37d05fSBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC,PetscBool),(pc,flg));CHKERRQ(ierr); 4738e37d05fSBarry Smith PetscFunctionReturn(0); 4748e37d05fSBarry Smith } 4758e37d05fSBarry Smith 4768e37d05fSBarry Smith #undef __FUNCT__ 4778e37d05fSBarry Smith #define __FUNCT__ "PCFactorGetUseInPlace" 4788e37d05fSBarry Smith /*@ 4798e37d05fSBarry Smith PCFactorGetUseInPlace - Determines if an in-place factorization is being used. 4808e37d05fSBarry Smith 4818e37d05fSBarry Smith Logically Collective on PC 4828e37d05fSBarry Smith 4838e37d05fSBarry Smith Input Parameter: 4848e37d05fSBarry Smith . pc - the preconditioner context 4858e37d05fSBarry Smith 4868e37d05fSBarry Smith Output Parameter: 4878e37d05fSBarry Smith . flg - PETSC_TRUE to enable, PETSC_FALSE to disable 4888e37d05fSBarry Smith 4898e37d05fSBarry Smith Level: intermediate 4908e37d05fSBarry Smith 4918e37d05fSBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU 4928e37d05fSBarry Smith 4938e37d05fSBarry Smith .seealso: PCFactorSetUseInPlace() 4948e37d05fSBarry Smith @*/ 4958e37d05fSBarry Smith PetscErrorCode PCFactorGetUseInPlace(PC pc,PetscBool *flg) 4968e37d05fSBarry Smith { 4978e37d05fSBarry Smith PetscErrorCode ierr; 4988e37d05fSBarry Smith 4998e37d05fSBarry Smith PetscFunctionBegin; 5008e37d05fSBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 501*c60c7ad4SBarry Smith ierr = PetscUseMethod(pc,"PCFactorGetUseInPlace_C",(PC,PetscBool*),(pc,flg));CHKERRQ(ierr); 50285317021SBarry Smith PetscFunctionReturn(0); 50385317021SBarry Smith } 50485317021SBarry Smith 50585317021SBarry Smith #undef __FUNCT__ 50685317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType" 50785317021SBarry Smith /*@C 50885317021SBarry Smith PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to 50985317021SBarry Smith be used in the LU factorization. 51085317021SBarry Smith 511ad4df100SBarry Smith Logically Collective on PC 51285317021SBarry Smith 51385317021SBarry Smith Input Parameters: 51485317021SBarry Smith + pc - the preconditioner context 5152692d6eeSBarry Smith - ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM 51685317021SBarry Smith 51785317021SBarry Smith Options Database Key: 51885317021SBarry Smith . -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine 51985317021SBarry Smith 52085317021SBarry Smith Level: intermediate 52185317021SBarry Smith 52285317021SBarry Smith Notes: nested dissection is used by default 52385317021SBarry Smith 52485317021SBarry Smith For Cholesky and ICC and the SBAIJ format reorderings are not available, 52585317021SBarry Smith since only the upper triangular part of the matrix is stored. You can use the 52685317021SBarry Smith SeqAIJ format in this case to get reorderings. 52785317021SBarry Smith 52885317021SBarry Smith @*/ 52919fd82e9SBarry Smith PetscErrorCode PCFactorSetMatOrderingType(PC pc,MatOrderingType ordering) 53085317021SBarry Smith { 5314ac538c5SBarry Smith PetscErrorCode ierr; 53285317021SBarry Smith 53385317021SBarry Smith PetscFunctionBegin; 534c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 53519fd82e9SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,MatOrderingType),(pc,ordering));CHKERRQ(ierr); 53685317021SBarry Smith PetscFunctionReturn(0); 53785317021SBarry Smith } 53885317021SBarry Smith 53985317021SBarry Smith #undef __FUNCT__ 5408ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot" 54185317021SBarry Smith /*@ 5428ff23777SHong Zhang PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization. 54385317021SBarry Smith For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices 544e3c5b3baSBarry Smith it is never done. For the MATLAB and SuperLU factorization this is used. 54585317021SBarry Smith 546ad4df100SBarry Smith Logically Collective on PC 54785317021SBarry Smith 54885317021SBarry Smith Input Parameters: 54985317021SBarry Smith + pc - the preconditioner context 55085317021SBarry Smith - dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable) 55185317021SBarry Smith 55285317021SBarry Smith Options Database Key: 55385317021SBarry Smith . -pc_factor_pivoting <dtcol> 55485317021SBarry Smith 55585317021SBarry Smith Level: intermediate 55685317021SBarry Smith 55785317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks() 55885317021SBarry Smith @*/ 5597087cfbeSBarry Smith PetscErrorCode PCFactorSetColumnPivot(PC pc,PetscReal dtcol) 56085317021SBarry Smith { 5614ac538c5SBarry Smith PetscErrorCode ierr; 56285317021SBarry Smith 56385317021SBarry Smith PetscFunctionBegin; 564c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 565c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,dtcol,2); 5664ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr); 56785317021SBarry Smith PetscFunctionReturn(0); 56885317021SBarry Smith } 56985317021SBarry Smith 57085317021SBarry Smith #undef __FUNCT__ 57185317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks" 57285317021SBarry Smith /*@ 57385317021SBarry Smith PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block 57485317021SBarry Smith with BAIJ or SBAIJ matrices 57585317021SBarry Smith 576ad4df100SBarry Smith Logically Collective on PC 57785317021SBarry Smith 57885317021SBarry Smith Input Parameters: 57985317021SBarry Smith + pc - the preconditioner context 58085317021SBarry Smith - pivot - PETSC_TRUE or PETSC_FALSE 58185317021SBarry Smith 58285317021SBarry Smith Options Database Key: 58385317021SBarry Smith . -pc_factor_pivot_in_blocks <true,false> 58485317021SBarry Smith 58585317021SBarry Smith Level: intermediate 58685317021SBarry Smith 5878ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot() 58885317021SBarry Smith @*/ 5897087cfbeSBarry Smith PetscErrorCode PCFactorSetPivotInBlocks(PC pc,PetscBool pivot) 59085317021SBarry Smith { 5914ac538c5SBarry Smith PetscErrorCode ierr; 59285317021SBarry Smith 59385317021SBarry Smith PetscFunctionBegin; 594c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 595acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,pivot,2); 5964ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr); 59785317021SBarry Smith PetscFunctionReturn(0); 59885317021SBarry Smith } 59985317021SBarry Smith 60085317021SBarry Smith #undef __FUNCT__ 60185317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill" 60285317021SBarry Smith /*@ 60385317021SBarry Smith PCFactorSetReuseFill - When matrices with same different nonzero structure are factored, 60485317021SBarry Smith this causes later ones to use the fill ratio computed in the initial factorization. 60585317021SBarry Smith 606ad4df100SBarry Smith Logically Collective on PC 60785317021SBarry Smith 60885317021SBarry Smith Input Parameters: 60985317021SBarry Smith + pc - the preconditioner context 61085317021SBarry Smith - flag - PETSC_TRUE to reuse else PETSC_FALSE 61185317021SBarry Smith 61285317021SBarry Smith Options Database Key: 61385317021SBarry Smith . -pc_factor_reuse_fill - Activates PCFactorSetReuseFill() 61485317021SBarry Smith 61585317021SBarry Smith Level: intermediate 61685317021SBarry Smith 61785317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky 61885317021SBarry Smith 61985317021SBarry Smith .seealso: PCFactorSetReuseOrdering() 62085317021SBarry Smith @*/ 6217087cfbeSBarry Smith PetscErrorCode PCFactorSetReuseFill(PC pc,PetscBool flag) 62285317021SBarry Smith { 6234ac538c5SBarry Smith PetscErrorCode ierr; 62485317021SBarry Smith 62585317021SBarry Smith PetscFunctionBegin; 6260700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,2); 627acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,flag,2); 6284ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr); 62985317021SBarry Smith PetscFunctionReturn(0); 63085317021SBarry Smith } 631