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 17*2bd2b0e6SSatish Balay Level: intermediate 18*2bd2b0e6SSatish 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__ 16385317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels" 16485317021SBarry Smith /*@ 16585317021SBarry Smith PCFactorSetLevels - Sets the number of levels of fill to use. 16685317021SBarry Smith 167ad4df100SBarry Smith Logically Collective on PC 16885317021SBarry Smith 16985317021SBarry Smith Input Parameters: 17085317021SBarry Smith + pc - the preconditioner context 17185317021SBarry Smith - levels - number of levels of fill 17285317021SBarry Smith 17385317021SBarry Smith Options Database Key: 17485317021SBarry Smith . -pc_factor_levels <levels> - Sets fill level 17585317021SBarry Smith 17685317021SBarry Smith Level: intermediate 17785317021SBarry Smith 17885317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 17985317021SBarry Smith @*/ 1807087cfbeSBarry Smith PetscErrorCode PCFactorSetLevels(PC pc,PetscInt levels) 18185317021SBarry Smith { 1824ac538c5SBarry Smith PetscErrorCode ierr; 18385317021SBarry Smith 18485317021SBarry Smith PetscFunctionBegin; 1850700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 186e7e72b3dSBarry Smith if (levels < 0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"negative levels"); 187c5eb9154SBarry Smith PetscValidLogicalCollectiveInt(pc,levels,2); 1884ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetLevels_C",(PC,PetscInt),(pc,levels));CHKERRQ(ierr); 18985317021SBarry Smith PetscFunctionReturn(0); 19085317021SBarry Smith } 19185317021SBarry Smith 19285317021SBarry Smith #undef __FUNCT__ 19385317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill" 19485317021SBarry Smith /*@ 19585317021SBarry Smith PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be 19685317021SBarry Smith treated as level 0 fill even if there is no non-zero location. 19785317021SBarry Smith 198ad4df100SBarry Smith Logically Collective on PC 19985317021SBarry Smith 20085317021SBarry Smith Input Parameters: 20185317021SBarry Smith + pc - the preconditioner context 20285317021SBarry Smith 20385317021SBarry Smith Options Database Key: 20485317021SBarry Smith . -pc_factor_diagonal_fill 20585317021SBarry Smith 20685317021SBarry Smith Notes: 20785317021SBarry Smith Does not apply with 0 fill. 20885317021SBarry Smith 20985317021SBarry Smith Level: intermediate 21085317021SBarry Smith 21185317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU 21285317021SBarry Smith @*/ 2137087cfbeSBarry Smith PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc) 21485317021SBarry Smith { 2154ac538c5SBarry Smith PetscErrorCode ierr; 21685317021SBarry Smith 21785317021SBarry Smith PetscFunctionBegin; 2180700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 2194ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC),(pc));CHKERRQ(ierr); 22085317021SBarry Smith PetscFunctionReturn(0); 22185317021SBarry Smith } 22285317021SBarry Smith 22385317021SBarry Smith #undef __FUNCT__ 22485317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal" 22585317021SBarry Smith /*@ 22685317021SBarry Smith PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal 22785317021SBarry Smith 228ad4df100SBarry Smith Logically Collective on PC 22985317021SBarry Smith 23085317021SBarry Smith Input Parameters: 23185317021SBarry Smith + pc - the preconditioner context 23285317021SBarry Smith - tol - diagonal entries smaller than this in absolute value are considered zero 23385317021SBarry Smith 23485317021SBarry Smith Options Database Key: 23585317021SBarry Smith . -pc_factor_nonzeros_along_diagonal 23685317021SBarry Smith 23785317021SBarry Smith Level: intermediate 23885317021SBarry Smith 23985317021SBarry Smith .keywords: PC, set, factorization, direct, fill 24085317021SBarry Smith 24185317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal() 24285317021SBarry Smith @*/ 2437087cfbeSBarry Smith PetscErrorCode PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol) 24485317021SBarry Smith { 2454ac538c5SBarry Smith PetscErrorCode ierr; 24685317021SBarry Smith 24785317021SBarry Smith PetscFunctionBegin; 2480700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 249c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,rtol,2); 2504ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr); 25185317021SBarry Smith PetscFunctionReturn(0); 25285317021SBarry Smith } 25385317021SBarry Smith 25485317021SBarry Smith #undef __FUNCT__ 25585317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage" 256bf6011e8SBarry Smith /*@C 25785317021SBarry Smith PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization 25885317021SBarry Smith 259ad4df100SBarry Smith Logically Collective on PC 26085317021SBarry Smith 26185317021SBarry Smith Input Parameters: 26285317021SBarry Smith + pc - the preconditioner context 26385317021SBarry Smith - stype - for example, spooles, superlu, superlu_dist 26485317021SBarry Smith 26585317021SBarry Smith Options Database Key: 26685317021SBarry Smith . -pc_factor_mat_solver_package <stype> - spooles, petsc, superlu, superlu_dist, mumps 26785317021SBarry Smith 26885317021SBarry Smith Level: intermediate 26985317021SBarry Smith 27085317021SBarry Smith Note: 27185317021SBarry Smith By default this will use the PETSc factorization if it exists 27285317021SBarry Smith 27385317021SBarry Smith 27485317021SBarry Smith .keywords: PC, set, factorization, direct, fill 27585317021SBarry Smith 2767112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 27785317021SBarry Smith 27885317021SBarry Smith @*/ 2797087cfbeSBarry Smith PetscErrorCode PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype) 28085317021SBarry Smith { 2814ac538c5SBarry Smith PetscErrorCode ierr; 28285317021SBarry Smith 28385317021SBarry Smith PetscFunctionBegin; 2840700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 2854ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr); 28685317021SBarry Smith PetscFunctionReturn(0); 28785317021SBarry Smith } 28885317021SBarry Smith 28985317021SBarry Smith #undef __FUNCT__ 2907112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage" 291bf6011e8SBarry Smith /*@C 2927112b564SBarry Smith PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization 2937112b564SBarry Smith 294c5eb9154SBarry Smith Not Collective 2957112b564SBarry Smith 2967112b564SBarry Smith Input Parameter: 2977112b564SBarry Smith . pc - the preconditioner context 2987112b564SBarry Smith 2997112b564SBarry Smith Output Parameter: 3008b5c83b4SJed Brown . stype - for example, spooles, superlu, superlu_dist (PETSC_NULL if the PC does not have a solver package) 3017112b564SBarry Smith 3027112b564SBarry Smith Level: intermediate 3037112b564SBarry Smith 3047112b564SBarry Smith 3057112b564SBarry Smith .keywords: PC, set, factorization, direct, fill 3067112b564SBarry Smith 3077112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage() 3087112b564SBarry Smith 3097112b564SBarry Smith @*/ 3107087cfbeSBarry Smith PetscErrorCode PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype) 3117112b564SBarry Smith { 3128b5c83b4SJed Brown PetscErrorCode ierr,(*f)(PC,const MatSolverPackage*); 3137112b564SBarry Smith 3147112b564SBarry Smith PetscFunctionBegin; 3150700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 3168b5c83b4SJed Brown ierr = PetscObjectQueryFunction((PetscObject)pc,"PCFactorGetMatSolverPackage_C",(void(**)(void))&f);CHKERRQ(ierr); 3178b5c83b4SJed Brown if (f) { 3188b5c83b4SJed Brown ierr = (*f)(pc,stype);CHKERRQ(ierr); 3198b5c83b4SJed Brown } else { 3208b5c83b4SJed Brown *stype = PETSC_NULL; 3218b5c83b4SJed Brown } 3227112b564SBarry Smith PetscFunctionReturn(0); 3237112b564SBarry Smith } 3247112b564SBarry Smith 3257112b564SBarry Smith #undef __FUNCT__ 32685317021SBarry Smith #define __FUNCT__ "PCFactorSetFill" 32785317021SBarry Smith /*@ 32885317021SBarry Smith PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix, 32985317021SBarry Smith fill = number nonzeros in factor/number nonzeros in original matrix. 33085317021SBarry Smith 331c5eb9154SBarry Smith Not Collective, each process can expect a different amount of fill 33285317021SBarry Smith 33385317021SBarry Smith Input Parameters: 33485317021SBarry Smith + pc - the preconditioner context 33585317021SBarry Smith - fill - amount of expected fill 33685317021SBarry Smith 33785317021SBarry Smith Options Database Key: 33885317021SBarry Smith . -pc_factor_fill <fill> - Sets fill amount 33985317021SBarry Smith 34085317021SBarry Smith Level: intermediate 34185317021SBarry Smith 34285317021SBarry Smith Note: 34385317021SBarry Smith For sparse matrix factorizations it is difficult to predict how much 34485317021SBarry Smith fill to expect. By running with the option -info PETSc will print the 34585317021SBarry Smith actual amount of fill used; allowing you to set the value accurately for 34685317021SBarry Smith future runs. Default PETSc uses a value of 5.0 34785317021SBarry Smith 34801a79839SBarry Smith This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels. 34901a79839SBarry Smith 35001a79839SBarry Smith 35185317021SBarry Smith .keywords: PC, set, factorization, direct, fill 35285317021SBarry Smith 35385317021SBarry Smith @*/ 3547087cfbeSBarry Smith PetscErrorCode PCFactorSetFill(PC pc,PetscReal fill) 35585317021SBarry Smith { 3564ac538c5SBarry Smith PetscErrorCode ierr; 35785317021SBarry Smith 35885317021SBarry Smith PetscFunctionBegin; 3590700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 360e7e72b3dSBarry Smith if (fill < 1.0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0"); 3614ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr); 36285317021SBarry Smith PetscFunctionReturn(0); 36385317021SBarry Smith } 36485317021SBarry Smith 36585317021SBarry Smith #undef __FUNCT__ 36685317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace" 36785317021SBarry Smith /*@ 36885317021SBarry Smith PCFactorSetUseInPlace - Tells the system to do an in-place factorization. 36985317021SBarry Smith For dense matrices, this enables the solution of much larger problems. 37085317021SBarry Smith For sparse matrices the factorization cannot be done truly in-place 37185317021SBarry Smith so this does not save memory during the factorization, but after the matrix 37285317021SBarry Smith is factored, the original unfactored matrix is freed, thus recovering that 37385317021SBarry Smith space. 37485317021SBarry Smith 375ad4df100SBarry Smith Logically Collective on PC 37685317021SBarry Smith 37785317021SBarry Smith Input Parameters: 37885317021SBarry Smith . pc - the preconditioner context 37985317021SBarry Smith 38085317021SBarry Smith Options Database Key: 38185317021SBarry Smith . -pc_factor_in_place - Activates in-place factorization 38285317021SBarry Smith 38385317021SBarry Smith Notes: 38485317021SBarry Smith PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when 38585317021SBarry Smith a different matrix is provided for the multiply and the preconditioner in 38685317021SBarry Smith a call to KSPSetOperators(). 38785317021SBarry Smith This is because the Krylov space methods require an application of the 38885317021SBarry Smith matrix multiplication, which is not possible here because the matrix has 38985317021SBarry Smith been factored in-place, replacing the original matrix. 39085317021SBarry Smith 39185317021SBarry Smith Level: intermediate 39285317021SBarry Smith 39385317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU 39485317021SBarry Smith 39585317021SBarry Smith .seealso: PCILUSetUseInPlace() 39685317021SBarry Smith @*/ 3977087cfbeSBarry Smith PetscErrorCode PCFactorSetUseInPlace(PC pc) 39885317021SBarry Smith { 3994ac538c5SBarry Smith PetscErrorCode ierr; 40085317021SBarry Smith 40185317021SBarry Smith PetscFunctionBegin; 4020700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 4034ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC),(pc));CHKERRQ(ierr); 40485317021SBarry Smith PetscFunctionReturn(0); 40585317021SBarry Smith } 40685317021SBarry Smith 40785317021SBarry Smith #undef __FUNCT__ 40885317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType" 40985317021SBarry Smith /*@C 41085317021SBarry Smith PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to 41185317021SBarry Smith be used in the LU factorization. 41285317021SBarry Smith 413ad4df100SBarry Smith Logically Collective on PC 41485317021SBarry Smith 41585317021SBarry Smith Input Parameters: 41685317021SBarry Smith + pc - the preconditioner context 4172692d6eeSBarry Smith - ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM 41885317021SBarry Smith 41985317021SBarry Smith Options Database Key: 42085317021SBarry Smith . -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine 42185317021SBarry Smith 42285317021SBarry Smith Level: intermediate 42385317021SBarry Smith 42485317021SBarry Smith Notes: nested dissection is used by default 42585317021SBarry Smith 42685317021SBarry Smith For Cholesky and ICC and the SBAIJ format reorderings are not available, 42785317021SBarry Smith since only the upper triangular part of the matrix is stored. You can use the 42885317021SBarry Smith SeqAIJ format in this case to get reorderings. 42985317021SBarry Smith 43085317021SBarry Smith @*/ 4317087cfbeSBarry Smith PetscErrorCode PCFactorSetMatOrderingType(PC pc,const MatOrderingType ordering) 43285317021SBarry Smith { 4334ac538c5SBarry Smith PetscErrorCode ierr; 43485317021SBarry Smith 43585317021SBarry Smith PetscFunctionBegin; 436c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 4374ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,const MatOrderingType),(pc,ordering));CHKERRQ(ierr); 43885317021SBarry Smith PetscFunctionReturn(0); 43985317021SBarry Smith } 44085317021SBarry Smith 44185317021SBarry Smith #undef __FUNCT__ 4428ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot" 44385317021SBarry Smith /*@ 4448ff23777SHong Zhang PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization. 44585317021SBarry Smith For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices 446e3c5b3baSBarry Smith it is never done. For the MATLAB and SuperLU factorization this is used. 44785317021SBarry Smith 448ad4df100SBarry Smith Logically Collective on PC 44985317021SBarry Smith 45085317021SBarry Smith Input Parameters: 45185317021SBarry Smith + pc - the preconditioner context 45285317021SBarry Smith - dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable) 45385317021SBarry Smith 45485317021SBarry Smith Options Database Key: 45585317021SBarry Smith . -pc_factor_pivoting <dtcol> 45685317021SBarry Smith 45785317021SBarry Smith Level: intermediate 45885317021SBarry Smith 45985317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks() 46085317021SBarry Smith @*/ 4617087cfbeSBarry Smith PetscErrorCode PCFactorSetColumnPivot(PC pc,PetscReal dtcol) 46285317021SBarry Smith { 4634ac538c5SBarry Smith PetscErrorCode ierr; 46485317021SBarry Smith 46585317021SBarry Smith PetscFunctionBegin; 466c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 467c5eb9154SBarry Smith PetscValidLogicalCollectiveReal(pc,dtcol,2); 4684ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr); 46985317021SBarry Smith PetscFunctionReturn(0); 47085317021SBarry Smith } 47185317021SBarry Smith 47285317021SBarry Smith #undef __FUNCT__ 47385317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks" 47485317021SBarry Smith /*@ 47585317021SBarry Smith PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block 47685317021SBarry Smith with BAIJ or SBAIJ matrices 47785317021SBarry Smith 478ad4df100SBarry Smith Logically Collective on PC 47985317021SBarry Smith 48085317021SBarry Smith Input Parameters: 48185317021SBarry Smith + pc - the preconditioner context 48285317021SBarry Smith - pivot - PETSC_TRUE or PETSC_FALSE 48385317021SBarry Smith 48485317021SBarry Smith Options Database Key: 48585317021SBarry Smith . -pc_factor_pivot_in_blocks <true,false> 48685317021SBarry Smith 48785317021SBarry Smith Level: intermediate 48885317021SBarry Smith 4898ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot() 49085317021SBarry Smith @*/ 4917087cfbeSBarry Smith PetscErrorCode PCFactorSetPivotInBlocks(PC pc,PetscBool pivot) 49285317021SBarry Smith { 4934ac538c5SBarry Smith PetscErrorCode ierr; 49485317021SBarry Smith 49585317021SBarry Smith PetscFunctionBegin; 496c5eb9154SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,1); 497acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,pivot,2); 4984ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr); 49985317021SBarry Smith PetscFunctionReturn(0); 50085317021SBarry Smith } 50185317021SBarry Smith 50285317021SBarry Smith #undef __FUNCT__ 50385317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill" 50485317021SBarry Smith /*@ 50585317021SBarry Smith PCFactorSetReuseFill - When matrices with same different nonzero structure are factored, 50685317021SBarry Smith this causes later ones to use the fill ratio computed in the initial factorization. 50785317021SBarry Smith 508ad4df100SBarry Smith Logically Collective on PC 50985317021SBarry Smith 51085317021SBarry Smith Input Parameters: 51185317021SBarry Smith + pc - the preconditioner context 51285317021SBarry Smith - flag - PETSC_TRUE to reuse else PETSC_FALSE 51385317021SBarry Smith 51485317021SBarry Smith Options Database Key: 51585317021SBarry Smith . -pc_factor_reuse_fill - Activates PCFactorSetReuseFill() 51685317021SBarry Smith 51785317021SBarry Smith Level: intermediate 51885317021SBarry Smith 51985317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky 52085317021SBarry Smith 52185317021SBarry Smith .seealso: PCFactorSetReuseOrdering() 52285317021SBarry Smith @*/ 5237087cfbeSBarry Smith PetscErrorCode PCFactorSetReuseFill(PC pc,PetscBool flag) 52485317021SBarry Smith { 5254ac538c5SBarry Smith PetscErrorCode ierr; 52685317021SBarry Smith 52785317021SBarry Smith PetscFunctionBegin; 5280700a824SBarry Smith PetscValidHeaderSpecific(pc,PC_CLASSID,2); 529acfcf0e5SJed Brown PetscValidLogicalCollectiveBool(pc,flag,2); 5304ac538c5SBarry Smith ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr); 53185317021SBarry Smith PetscFunctionReturn(0); 53285317021SBarry Smith } 533