xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision c6db04a5321582041def2b1e244c75985478b3ef)
15e8efad8SHong Zhang 
2*c6db04a5SJed 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 
17f8260c8fSBarry Smith @*/
18f8260c8fSBarry Smith PetscErrorCode PCFactorSetUpMatSolverPackage(PC pc)
19f8260c8fSBarry Smith {
20f8260c8fSBarry Smith   PetscErrorCode ierr;
21f8260c8fSBarry Smith 
22f8260c8fSBarry Smith   PetscFunctionBegin;
23f8260c8fSBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
24f8260c8fSBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetUpMatSolverPackage_C",(PC),(pc));CHKERRQ(ierr);
25b3a44c85SBarry Smith   PetscFunctionReturn(0);
26f8260c8fSBarry Smith }
27f8260c8fSBarry Smith 
28f8260c8fSBarry Smith #undef __FUNCT__
29ee45ca4aSHong Zhang #define __FUNCT__ "PCFactorSetZeroPivot"
30ee45ca4aSHong Zhang /*@
31ee45ca4aSHong Zhang    PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero
32ee45ca4aSHong Zhang 
33ad4df100SBarry Smith    Logically Collective on PC
34ee45ca4aSHong Zhang 
35ee45ca4aSHong Zhang    Input Parameters:
36afaefe49SHong Zhang +  pc - the preconditioner context
37afaefe49SHong Zhang -  zero - all pivots smaller than this will be considered zero
38ee45ca4aSHong Zhang 
39ee45ca4aSHong Zhang    Options Database Key:
40ee45ca4aSHong Zhang .  -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot
41ee45ca4aSHong Zhang 
42ee45ca4aSHong Zhang    Level: intermediate
43ee45ca4aSHong Zhang 
44ee45ca4aSHong Zhang .keywords: PC, set, factorization, direct, fill
45ee45ca4aSHong Zhang 
46daa17b54SHong Zhang .seealso: PCFactorSetShiftType(), PCFactorSetShiftAmount()
47ee45ca4aSHong Zhang @*/
487087cfbeSBarry Smith PetscErrorCode  PCFactorSetZeroPivot(PC pc,PetscReal zero)
49ee45ca4aSHong Zhang {
504ac538c5SBarry Smith   PetscErrorCode ierr;
51afaefe49SHong Zhang 
52ee45ca4aSHong Zhang   PetscFunctionBegin;
530700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
54c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,zero,2);
554ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetZeroPivot_C",(PC,PetscReal),(pc,zero));CHKERRQ(ierr);
56ee45ca4aSHong Zhang   PetscFunctionReturn(0);
57ee45ca4aSHong Zhang }
58ee45ca4aSHong Zhang 
595e8efad8SHong Zhang #undef __FUNCT__
60d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftType"
61915743fcSHong Zhang /*@
62915743fcSHong Zhang    PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during
63915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
64915743fcSHong Zhang 
65ad4df100SBarry Smith    Logically Collective on PC
66915743fcSHong Zhang 
67915743fcSHong Zhang    Input Parameters:
68915743fcSHong Zhang +  pc - the preconditioner context
69915743fcSHong Zhang -  shifttype - type of shift; one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO,  MAT_SHIFT_POSITIVE_DEFINITE, MAT_SHIFT_INBLOCKS
70915743fcSHong Zhang 
71915743fcSHong Zhang    Options Database Key:
72915743fcSHong Zhang .  -pc_factor_shift_type <shifttype> - Sets shift type or PETSC_DECIDE for the default; use '-help' for a list of available types
73915743fcSHong Zhang 
74915743fcSHong Zhang    Level: intermediate
75915743fcSHong Zhang 
76915743fcSHong Zhang .keywords: PC, set, factorization,
77915743fcSHong Zhang 
78915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftAmount()
79915743fcSHong Zhang @*/
807087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftType(PC pc,MatFactorShiftType shifttype)
81d90ac83dSHong Zhang {
824ac538c5SBarry Smith   PetscErrorCode ierr;
83d90ac83dSHong Zhang 
84d90ac83dSHong Zhang   PetscFunctionBegin;
850700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
86c5eb9154SBarry Smith   PetscValidLogicalCollectiveEnum(pc,shifttype,2);
874ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftType_C",(PC,MatFactorShiftType),(pc,shifttype));CHKERRQ(ierr);
88d90ac83dSHong Zhang   PetscFunctionReturn(0);
89d90ac83dSHong Zhang }
90d90ac83dSHong Zhang 
91d90ac83dSHong Zhang #undef __FUNCT__
92d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftAmount"
93915743fcSHong Zhang /*@
94915743fcSHong Zhang    PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during
95915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
96915743fcSHong Zhang 
97ad4df100SBarry Smith    Logically Collective on PC
98915743fcSHong Zhang 
99915743fcSHong Zhang    Input Parameters:
100915743fcSHong Zhang +  pc - the preconditioner context
101915743fcSHong Zhang -  shiftamount - amount of shift
102915743fcSHong Zhang 
103915743fcSHong Zhang    Options Database Key:
104915743fcSHong Zhang .  -pc_factor_shift_amount <shiftamount> - Sets shift amount or PETSC_DECIDE for the default
105915743fcSHong Zhang 
106915743fcSHong Zhang    Level: intermediate
107915743fcSHong Zhang 
108915743fcSHong Zhang .keywords: PC, set, factorization,
109915743fcSHong Zhang 
110915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftType()
111915743fcSHong Zhang @*/
1127087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftAmount(PC pc,PetscReal shiftamount)
113d90ac83dSHong Zhang {
1144ac538c5SBarry Smith   PetscErrorCode ierr;
115d90ac83dSHong Zhang 
116d90ac83dSHong Zhang   PetscFunctionBegin;
1170700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
118c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,shiftamount,2);
1194ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftAmount_C",(PC,PetscReal),(pc,shiftamount));CHKERRQ(ierr);
120d90ac83dSHong Zhang   PetscFunctionReturn(0);
121d90ac83dSHong Zhang }
122d90ac83dSHong Zhang 
123d90ac83dSHong Zhang #undef __FUNCT__
124b7c853c4SBarry Smith #define __FUNCT__ "PCFactorSetDropTolerance"
12578fc6b22SHong Zhang /*
126b7c853c4SBarry Smith    PCFactorSetDropTolerance - The preconditioner will use an ILU
12778fc6b22SHong Zhang    based on a drop tolerance. (Under development)
12885317021SBarry Smith 
129ad4df100SBarry Smith    Logically Collective on PC
13085317021SBarry Smith 
13185317021SBarry Smith    Input Parameters:
13285317021SBarry Smith +  pc - the preconditioner context
13385317021SBarry Smith .  dt - the drop tolerance, try from 1.e-10 to .1
13485317021SBarry Smith .  dtcol - tolerance for column pivot, good values [0.1 to 0.01]
13585317021SBarry Smith -  maxrowcount - the max number of nonzeros allowed in a row, best value
13685317021SBarry Smith                  depends on the number of nonzeros in row of original matrix
13785317021SBarry Smith 
13885317021SBarry Smith    Options Database Key:
139b7c853c4SBarry Smith .  -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance
14085317021SBarry Smith 
14185317021SBarry Smith    Level: intermediate
14285317021SBarry Smith 
14385317021SBarry Smith       There are NO default values for the 3 parameters, you must set them with reasonable values for your
14485317021SBarry Smith       matrix. We don't know how to compute reasonable values.
14585317021SBarry Smith 
14685317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, ILU
14778fc6b22SHong Zhang */
1487087cfbeSBarry Smith PetscErrorCode  PCFactorSetDropTolerance(PC pc,PetscReal dt,PetscReal dtcol,PetscInt maxrowcount)
14985317021SBarry Smith {
1504ac538c5SBarry Smith   PetscErrorCode ierr;
15185317021SBarry Smith 
15285317021SBarry Smith   PetscFunctionBegin;
1530700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
154c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
155c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,maxrowcount,3);
1564ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetDropTolerance_C",(PC,PetscReal,PetscReal,PetscInt),(pc,dt,dtcol,maxrowcount));CHKERRQ(ierr);
15785317021SBarry Smith   PetscFunctionReturn(0);
15885317021SBarry Smith }
15985317021SBarry Smith 
16085317021SBarry Smith #undef __FUNCT__
16185317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels"
16285317021SBarry Smith /*@
16385317021SBarry Smith    PCFactorSetLevels - Sets the number of levels of fill to use.
16485317021SBarry Smith 
165ad4df100SBarry Smith    Logically Collective on PC
16685317021SBarry Smith 
16785317021SBarry Smith    Input Parameters:
16885317021SBarry Smith +  pc - the preconditioner context
16985317021SBarry Smith -  levels - number of levels of fill
17085317021SBarry Smith 
17185317021SBarry Smith    Options Database Key:
17285317021SBarry Smith .  -pc_factor_levels <levels> - Sets fill level
17385317021SBarry Smith 
17485317021SBarry Smith    Level: intermediate
17585317021SBarry Smith 
17685317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
17785317021SBarry Smith @*/
1787087cfbeSBarry Smith PetscErrorCode  PCFactorSetLevels(PC pc,PetscInt levels)
17985317021SBarry Smith {
1804ac538c5SBarry Smith   PetscErrorCode ierr;
18185317021SBarry Smith 
18285317021SBarry Smith   PetscFunctionBegin;
1830700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
184e7e72b3dSBarry Smith   if (levels < 0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"negative levels");
185c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,levels,2);
1864ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetLevels_C",(PC,PetscInt),(pc,levels));CHKERRQ(ierr);
18785317021SBarry Smith   PetscFunctionReturn(0);
18885317021SBarry Smith }
18985317021SBarry Smith 
19085317021SBarry Smith #undef __FUNCT__
19185317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill"
19285317021SBarry Smith /*@
19385317021SBarry Smith    PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
19485317021SBarry Smith    treated as level 0 fill even if there is no non-zero location.
19585317021SBarry Smith 
196ad4df100SBarry Smith    Logically Collective on PC
19785317021SBarry Smith 
19885317021SBarry Smith    Input Parameters:
19985317021SBarry Smith +  pc - the preconditioner context
20085317021SBarry Smith 
20185317021SBarry Smith    Options Database Key:
20285317021SBarry Smith .  -pc_factor_diagonal_fill
20385317021SBarry Smith 
20485317021SBarry Smith    Notes:
20585317021SBarry Smith    Does not apply with 0 fill.
20685317021SBarry Smith 
20785317021SBarry Smith    Level: intermediate
20885317021SBarry Smith 
20985317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
21085317021SBarry Smith @*/
2117087cfbeSBarry Smith PetscErrorCode  PCFactorSetAllowDiagonalFill(PC pc)
21285317021SBarry Smith {
2134ac538c5SBarry Smith   PetscErrorCode ierr;
21485317021SBarry Smith 
21585317021SBarry Smith   PetscFunctionBegin;
2160700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2174ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC),(pc));CHKERRQ(ierr);
21885317021SBarry Smith   PetscFunctionReturn(0);
21985317021SBarry Smith }
22085317021SBarry Smith 
22185317021SBarry Smith #undef __FUNCT__
22285317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal"
22385317021SBarry Smith /*@
22485317021SBarry Smith    PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal
22585317021SBarry Smith 
226ad4df100SBarry Smith    Logically Collective on PC
22785317021SBarry Smith 
22885317021SBarry Smith    Input Parameters:
22985317021SBarry Smith +  pc - the preconditioner context
23085317021SBarry Smith -  tol - diagonal entries smaller than this in absolute value are considered zero
23185317021SBarry Smith 
23285317021SBarry Smith    Options Database Key:
23385317021SBarry Smith .  -pc_factor_nonzeros_along_diagonal
23485317021SBarry Smith 
23585317021SBarry Smith    Level: intermediate
23685317021SBarry Smith 
23785317021SBarry Smith .keywords: PC, set, factorization, direct, fill
23885317021SBarry Smith 
23985317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal()
24085317021SBarry Smith @*/
2417087cfbeSBarry Smith PetscErrorCode  PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol)
24285317021SBarry Smith {
2434ac538c5SBarry Smith   PetscErrorCode ierr;
24485317021SBarry Smith 
24585317021SBarry Smith   PetscFunctionBegin;
2460700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
247c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,rtol,2);
2484ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr);
24985317021SBarry Smith   PetscFunctionReturn(0);
25085317021SBarry Smith }
25185317021SBarry Smith 
25285317021SBarry Smith #undef __FUNCT__
25385317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage"
254bf6011e8SBarry Smith /*@C
25585317021SBarry Smith    PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization
25685317021SBarry Smith 
257ad4df100SBarry Smith    Logically Collective on PC
25885317021SBarry Smith 
25985317021SBarry Smith    Input Parameters:
26085317021SBarry Smith +  pc - the preconditioner context
26185317021SBarry Smith -  stype - for example, spooles, superlu, superlu_dist
26285317021SBarry Smith 
26385317021SBarry Smith    Options Database Key:
26485317021SBarry Smith .  -pc_factor_mat_solver_package <stype> - spooles, petsc, superlu, superlu_dist, mumps
26585317021SBarry Smith 
26685317021SBarry Smith    Level: intermediate
26785317021SBarry Smith 
26885317021SBarry Smith    Note:
26985317021SBarry Smith      By default this will use the PETSc factorization if it exists
27085317021SBarry Smith 
27185317021SBarry Smith 
27285317021SBarry Smith .keywords: PC, set, factorization, direct, fill
27385317021SBarry Smith 
2747112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
27585317021SBarry Smith 
27685317021SBarry Smith @*/
2777087cfbeSBarry Smith PetscErrorCode  PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype)
27885317021SBarry Smith {
2794ac538c5SBarry Smith   PetscErrorCode ierr;
28085317021SBarry Smith 
28185317021SBarry Smith   PetscFunctionBegin;
2820700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2834ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr);
28485317021SBarry Smith   PetscFunctionReturn(0);
28585317021SBarry Smith }
28685317021SBarry Smith 
28785317021SBarry Smith #undef __FUNCT__
2887112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage"
289bf6011e8SBarry Smith /*@C
2907112b564SBarry Smith    PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization
2917112b564SBarry Smith 
292c5eb9154SBarry Smith    Not Collective
2937112b564SBarry Smith 
2947112b564SBarry Smith    Input Parameter:
2957112b564SBarry Smith .  pc - the preconditioner context
2967112b564SBarry Smith 
2977112b564SBarry Smith    Output Parameter:
2987112b564SBarry Smith .   stype - for example, spooles, superlu, superlu_dist
2997112b564SBarry Smith 
3007112b564SBarry Smith    Level: intermediate
3017112b564SBarry Smith 
3027112b564SBarry Smith 
3037112b564SBarry Smith .keywords: PC, set, factorization, direct, fill
3047112b564SBarry Smith 
3057112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
3067112b564SBarry Smith 
3077112b564SBarry Smith @*/
3087087cfbeSBarry Smith PetscErrorCode  PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype)
3097112b564SBarry Smith {
3104ac538c5SBarry Smith   PetscErrorCode ierr;
3117112b564SBarry Smith 
3127112b564SBarry Smith   PetscFunctionBegin;
3130700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
3144ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorGetMatSolverPackage_C",(PC,const MatSolverPackage*),(pc,stype));CHKERRQ(ierr);
3157112b564SBarry Smith   PetscFunctionReturn(0);
3167112b564SBarry Smith }
3177112b564SBarry Smith 
3187112b564SBarry Smith #undef __FUNCT__
31985317021SBarry Smith #define __FUNCT__ "PCFactorSetFill"
32085317021SBarry Smith /*@
32185317021SBarry Smith    PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix,
32285317021SBarry Smith    fill = number nonzeros in factor/number nonzeros in original matrix.
32385317021SBarry Smith 
324c5eb9154SBarry Smith    Not Collective, each process can expect a different amount of fill
32585317021SBarry Smith 
32685317021SBarry Smith    Input Parameters:
32785317021SBarry Smith +  pc - the preconditioner context
32885317021SBarry Smith -  fill - amount of expected fill
32985317021SBarry Smith 
33085317021SBarry Smith    Options Database Key:
33185317021SBarry Smith .  -pc_factor_fill <fill> - Sets fill amount
33285317021SBarry Smith 
33385317021SBarry Smith    Level: intermediate
33485317021SBarry Smith 
33585317021SBarry Smith    Note:
33685317021SBarry Smith    For sparse matrix factorizations it is difficult to predict how much
33785317021SBarry Smith    fill to expect. By running with the option -info PETSc will print the
33885317021SBarry Smith    actual amount of fill used; allowing you to set the value accurately for
33985317021SBarry Smith    future runs. Default PETSc uses a value of 5.0
34085317021SBarry Smith 
34101a79839SBarry Smith    This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels.
34201a79839SBarry Smith 
34301a79839SBarry Smith 
34485317021SBarry Smith .keywords: PC, set, factorization, direct, fill
34585317021SBarry Smith 
34685317021SBarry Smith @*/
3477087cfbeSBarry Smith PetscErrorCode  PCFactorSetFill(PC pc,PetscReal fill)
34885317021SBarry Smith {
3494ac538c5SBarry Smith   PetscErrorCode ierr;
35085317021SBarry Smith 
35185317021SBarry Smith   PetscFunctionBegin;
3520700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
353e7e72b3dSBarry Smith   if (fill < 1.0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0");
3544ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr);
35585317021SBarry Smith   PetscFunctionReturn(0);
35685317021SBarry Smith }
35785317021SBarry Smith 
35885317021SBarry Smith #undef __FUNCT__
35985317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace"
36085317021SBarry Smith /*@
36185317021SBarry Smith    PCFactorSetUseInPlace - Tells the system to do an in-place factorization.
36285317021SBarry Smith    For dense matrices, this enables the solution of much larger problems.
36385317021SBarry Smith    For sparse matrices the factorization cannot be done truly in-place
36485317021SBarry Smith    so this does not save memory during the factorization, but after the matrix
36585317021SBarry Smith    is factored, the original unfactored matrix is freed, thus recovering that
36685317021SBarry Smith    space.
36785317021SBarry Smith 
368ad4df100SBarry Smith    Logically Collective on PC
36985317021SBarry Smith 
37085317021SBarry Smith    Input Parameters:
37185317021SBarry Smith .  pc - the preconditioner context
37285317021SBarry Smith 
37385317021SBarry Smith    Options Database Key:
37485317021SBarry Smith .  -pc_factor_in_place - Activates in-place factorization
37585317021SBarry Smith 
37685317021SBarry Smith    Notes:
37785317021SBarry Smith    PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when
37885317021SBarry Smith    a different matrix is provided for the multiply and the preconditioner in
37985317021SBarry Smith    a call to KSPSetOperators().
38085317021SBarry Smith    This is because the Krylov space methods require an application of the
38185317021SBarry Smith    matrix multiplication, which is not possible here because the matrix has
38285317021SBarry Smith    been factored in-place, replacing the original matrix.
38385317021SBarry Smith 
38485317021SBarry Smith    Level: intermediate
38585317021SBarry Smith 
38685317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU
38785317021SBarry Smith 
38885317021SBarry Smith .seealso: PCILUSetUseInPlace()
38985317021SBarry Smith @*/
3907087cfbeSBarry Smith PetscErrorCode  PCFactorSetUseInPlace(PC pc)
39185317021SBarry Smith {
3924ac538c5SBarry Smith   PetscErrorCode ierr;
39385317021SBarry Smith 
39485317021SBarry Smith   PetscFunctionBegin;
3950700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
3964ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC),(pc));CHKERRQ(ierr);
39785317021SBarry Smith   PetscFunctionReturn(0);
39885317021SBarry Smith }
39985317021SBarry Smith 
40085317021SBarry Smith #undef __FUNCT__
40185317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType"
40285317021SBarry Smith /*@C
40385317021SBarry Smith     PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to
40485317021SBarry Smith     be used in the LU factorization.
40585317021SBarry Smith 
406ad4df100SBarry Smith     Logically Collective on PC
40785317021SBarry Smith 
40885317021SBarry Smith     Input Parameters:
40985317021SBarry Smith +   pc - the preconditioner context
4102692d6eeSBarry Smith -   ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM
41185317021SBarry Smith 
41285317021SBarry Smith     Options Database Key:
41385317021SBarry Smith .   -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine
41485317021SBarry Smith 
41585317021SBarry Smith     Level: intermediate
41685317021SBarry Smith 
41785317021SBarry Smith     Notes: nested dissection is used by default
41885317021SBarry Smith 
41985317021SBarry Smith     For Cholesky and ICC and the SBAIJ format reorderings are not available,
42085317021SBarry Smith     since only the upper triangular part of the matrix is stored. You can use the
42185317021SBarry Smith     SeqAIJ format in this case to get reorderings.
42285317021SBarry Smith 
42385317021SBarry Smith @*/
4247087cfbeSBarry Smith PetscErrorCode  PCFactorSetMatOrderingType(PC pc,const MatOrderingType ordering)
42585317021SBarry Smith {
4264ac538c5SBarry Smith   PetscErrorCode ierr;
42785317021SBarry Smith 
42885317021SBarry Smith   PetscFunctionBegin;
429c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
4304ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,const MatOrderingType),(pc,ordering));CHKERRQ(ierr);
43185317021SBarry Smith   PetscFunctionReturn(0);
43285317021SBarry Smith }
43385317021SBarry Smith 
43485317021SBarry Smith #undef __FUNCT__
4358ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot"
43685317021SBarry Smith /*@
4378ff23777SHong Zhang     PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization.
43885317021SBarry Smith       For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices
439e3c5b3baSBarry Smith       it is never done. For the MATLAB and SuperLU factorization this is used.
44085317021SBarry Smith 
441ad4df100SBarry Smith     Logically Collective on PC
44285317021SBarry Smith 
44385317021SBarry Smith     Input Parameters:
44485317021SBarry Smith +   pc - the preconditioner context
44585317021SBarry Smith -   dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable)
44685317021SBarry Smith 
44785317021SBarry Smith     Options Database Key:
44885317021SBarry Smith .   -pc_factor_pivoting <dtcol>
44985317021SBarry Smith 
45085317021SBarry Smith     Level: intermediate
45185317021SBarry Smith 
45285317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks()
45385317021SBarry Smith @*/
4547087cfbeSBarry Smith PetscErrorCode  PCFactorSetColumnPivot(PC pc,PetscReal dtcol)
45585317021SBarry Smith {
4564ac538c5SBarry Smith   PetscErrorCode ierr;
45785317021SBarry Smith 
45885317021SBarry Smith   PetscFunctionBegin;
459c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
460c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
4614ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr);
46285317021SBarry Smith   PetscFunctionReturn(0);
46385317021SBarry Smith }
46485317021SBarry Smith 
46585317021SBarry Smith #undef __FUNCT__
46685317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks"
46785317021SBarry Smith /*@
46885317021SBarry Smith     PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block
46985317021SBarry Smith       with BAIJ or SBAIJ matrices
47085317021SBarry Smith 
471ad4df100SBarry Smith     Logically Collective on PC
47285317021SBarry Smith 
47385317021SBarry Smith     Input Parameters:
47485317021SBarry Smith +   pc - the preconditioner context
47585317021SBarry Smith -   pivot - PETSC_TRUE or PETSC_FALSE
47685317021SBarry Smith 
47785317021SBarry Smith     Options Database Key:
47885317021SBarry Smith .   -pc_factor_pivot_in_blocks <true,false>
47985317021SBarry Smith 
48085317021SBarry Smith     Level: intermediate
48185317021SBarry Smith 
4828ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot()
48385317021SBarry Smith @*/
4847087cfbeSBarry Smith PetscErrorCode  PCFactorSetPivotInBlocks(PC pc,PetscBool  pivot)
48585317021SBarry Smith {
4864ac538c5SBarry Smith   PetscErrorCode ierr;
48785317021SBarry Smith 
48885317021SBarry Smith   PetscFunctionBegin;
489c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
490acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,pivot,2);
4914ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr);
49285317021SBarry Smith   PetscFunctionReturn(0);
49385317021SBarry Smith }
49485317021SBarry Smith 
49585317021SBarry Smith #undef __FUNCT__
49685317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill"
49785317021SBarry Smith /*@
49885317021SBarry Smith    PCFactorSetReuseFill - When matrices with same different nonzero structure are factored,
49985317021SBarry Smith    this causes later ones to use the fill ratio computed in the initial factorization.
50085317021SBarry Smith 
501ad4df100SBarry Smith    Logically Collective on PC
50285317021SBarry Smith 
50385317021SBarry Smith    Input Parameters:
50485317021SBarry Smith +  pc - the preconditioner context
50585317021SBarry Smith -  flag - PETSC_TRUE to reuse else PETSC_FALSE
50685317021SBarry Smith 
50785317021SBarry Smith    Options Database Key:
50885317021SBarry Smith .  -pc_factor_reuse_fill - Activates PCFactorSetReuseFill()
50985317021SBarry Smith 
51085317021SBarry Smith    Level: intermediate
51185317021SBarry Smith 
51285317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky
51385317021SBarry Smith 
51485317021SBarry Smith .seealso: PCFactorSetReuseOrdering()
51585317021SBarry Smith @*/
5167087cfbeSBarry Smith PetscErrorCode  PCFactorSetReuseFill(PC pc,PetscBool  flag)
51785317021SBarry Smith {
5184ac538c5SBarry Smith   PetscErrorCode ierr;
51985317021SBarry Smith 
52085317021SBarry Smith   PetscFunctionBegin;
5210700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,2);
522acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,flag,2);
5234ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr);
52485317021SBarry Smith   PetscFunctionReturn(0);
52585317021SBarry Smith }
526