xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision 01a79839fc82a7dabb7a87cd2a8bb532c6bfa88d)
1dba47a55SKris Buschelman #define PETSCKSP_DLL
25e8efad8SHong Zhang 
37c4f633dSBarry Smith #include "../src/ksp/pc/impls/factor/factor.h"  /*I "petscpc.h" I*/
45e8efad8SHong Zhang 
5ee45ca4aSHong Zhang #undef __FUNCT__
6f8260c8fSBarry Smith #define __FUNCT__ "PCFactorSetUpMatSolverPackage"
7f8260c8fSBarry Smith /*@
8f8260c8fSBarry Smith     PCFactorSetUpMatSolverPackage - Can be called after KSPSetOperators() or PCSetOperators(), causes MatGetFactor() to be called so then one may
9f8260c8fSBarry Smith        set the options for that particular factorization object.
10f8260c8fSBarry Smith 
11f8260c8fSBarry Smith   Input Parameter:
12f8260c8fSBarry Smith .  pc  - the preconditioner context
13f8260c8fSBarry Smith 
14f8260c8fSBarry 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.
15f8260c8fSBarry Smith 
16f8260c8fSBarry Smith .seealso: PCFactorSetMatSolverPackage(), PCFactorGetMatrix()
17f8260c8fSBarry Smith 
18f8260c8fSBarry Smith @*/
19f8260c8fSBarry Smith PetscErrorCode PCFactorSetUpMatSolverPackage(PC pc)
20f8260c8fSBarry Smith {
21f8260c8fSBarry Smith   PetscErrorCode ierr;
22f8260c8fSBarry Smith 
23f8260c8fSBarry Smith   PetscFunctionBegin;
24f8260c8fSBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
25f8260c8fSBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetUpMatSolverPackage_C",(PC),(pc));CHKERRQ(ierr);
26b3a44c85SBarry Smith   PetscFunctionReturn(0);
27f8260c8fSBarry Smith }
28f8260c8fSBarry Smith 
29f8260c8fSBarry Smith #undef __FUNCT__
30ee45ca4aSHong Zhang #define __FUNCT__ "PCFactorSetZeroPivot"
31ee45ca4aSHong Zhang /*@
32ee45ca4aSHong Zhang    PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero
33ee45ca4aSHong Zhang 
34ad4df100SBarry Smith    Logically Collective on PC
35ee45ca4aSHong Zhang 
36ee45ca4aSHong Zhang    Input Parameters:
37afaefe49SHong Zhang +  pc - the preconditioner context
38afaefe49SHong Zhang -  zero - all pivots smaller than this will be considered zero
39ee45ca4aSHong Zhang 
40ee45ca4aSHong Zhang    Options Database Key:
41ee45ca4aSHong Zhang .  -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot
42ee45ca4aSHong Zhang 
43ee45ca4aSHong Zhang    Level: intermediate
44ee45ca4aSHong Zhang 
45ee45ca4aSHong Zhang .keywords: PC, set, factorization, direct, fill
46ee45ca4aSHong Zhang 
47daa17b54SHong Zhang .seealso: PCFactorSetShiftType(), PCFactorSetShiftAmount()
48ee45ca4aSHong Zhang @*/
497087cfbeSBarry Smith PetscErrorCode  PCFactorSetZeroPivot(PC pc,PetscReal zero)
50ee45ca4aSHong Zhang {
514ac538c5SBarry Smith   PetscErrorCode ierr;
52afaefe49SHong Zhang 
53ee45ca4aSHong Zhang   PetscFunctionBegin;
540700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
55c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,zero,2);
564ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetZeroPivot_C",(PC,PetscReal),(pc,zero));CHKERRQ(ierr);
57ee45ca4aSHong Zhang   PetscFunctionReturn(0);
58ee45ca4aSHong Zhang }
59ee45ca4aSHong Zhang 
605e8efad8SHong Zhang #undef __FUNCT__
61d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftType"
62915743fcSHong Zhang /*@
63915743fcSHong Zhang    PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during
64915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
65915743fcSHong Zhang 
66ad4df100SBarry Smith    Logically Collective on PC
67915743fcSHong Zhang 
68915743fcSHong Zhang    Input Parameters:
69915743fcSHong Zhang +  pc - the preconditioner context
70915743fcSHong Zhang -  shifttype - type of shift; one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO,  MAT_SHIFT_POSITIVE_DEFINITE, MAT_SHIFT_INBLOCKS
71915743fcSHong Zhang 
72915743fcSHong Zhang    Options Database Key:
73915743fcSHong Zhang .  -pc_factor_shift_type <shifttype> - Sets shift type or PETSC_DECIDE for the default; use '-help' for a list of available types
74915743fcSHong Zhang 
75915743fcSHong Zhang    Level: intermediate
76915743fcSHong Zhang 
77915743fcSHong Zhang .keywords: PC, set, factorization,
78915743fcSHong Zhang 
79915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftAmount()
80915743fcSHong Zhang @*/
817087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftType(PC pc,MatFactorShiftType shifttype)
82d90ac83dSHong Zhang {
834ac538c5SBarry Smith   PetscErrorCode ierr;
84d90ac83dSHong Zhang 
85d90ac83dSHong Zhang   PetscFunctionBegin;
860700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
87c5eb9154SBarry Smith   PetscValidLogicalCollectiveEnum(pc,shifttype,2);
884ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftType_C",(PC,MatFactorShiftType),(pc,shifttype));CHKERRQ(ierr);
89d90ac83dSHong Zhang   PetscFunctionReturn(0);
90d90ac83dSHong Zhang }
91d90ac83dSHong Zhang 
92d90ac83dSHong Zhang #undef __FUNCT__
93d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftAmount"
94915743fcSHong Zhang /*@
95915743fcSHong Zhang    PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during
96915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
97915743fcSHong Zhang 
98ad4df100SBarry Smith    Logically Collective on PC
99915743fcSHong Zhang 
100915743fcSHong Zhang    Input Parameters:
101915743fcSHong Zhang +  pc - the preconditioner context
102915743fcSHong Zhang -  shiftamount - amount of shift
103915743fcSHong Zhang 
104915743fcSHong Zhang    Options Database Key:
105915743fcSHong Zhang .  -pc_factor_shift_amount <shiftamount> - Sets shift amount or PETSC_DECIDE for the default
106915743fcSHong Zhang 
107915743fcSHong Zhang    Level: intermediate
108915743fcSHong Zhang 
109915743fcSHong Zhang .keywords: PC, set, factorization,
110915743fcSHong Zhang 
111915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftType()
112915743fcSHong Zhang @*/
1137087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftAmount(PC pc,PetscReal shiftamount)
114d90ac83dSHong Zhang {
1154ac538c5SBarry Smith   PetscErrorCode ierr;
116d90ac83dSHong Zhang 
117d90ac83dSHong Zhang   PetscFunctionBegin;
1180700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
119c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,shiftamount,2);
1204ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftAmount_C",(PC,PetscReal),(pc,shiftamount));CHKERRQ(ierr);
121d90ac83dSHong Zhang   PetscFunctionReturn(0);
122d90ac83dSHong Zhang }
123d90ac83dSHong Zhang 
124d90ac83dSHong Zhang #undef __FUNCT__
125b7c853c4SBarry Smith #define __FUNCT__ "PCFactorSetDropTolerance"
12678fc6b22SHong Zhang /*
127b7c853c4SBarry Smith    PCFactorSetDropTolerance - The preconditioner will use an ILU
12878fc6b22SHong Zhang    based on a drop tolerance. (Under development)
12985317021SBarry Smith 
130ad4df100SBarry Smith    Logically Collective on PC
13185317021SBarry Smith 
13285317021SBarry Smith    Input Parameters:
13385317021SBarry Smith +  pc - the preconditioner context
13485317021SBarry Smith .  dt - the drop tolerance, try from 1.e-10 to .1
13585317021SBarry Smith .  dtcol - tolerance for column pivot, good values [0.1 to 0.01]
13685317021SBarry Smith -  maxrowcount - the max number of nonzeros allowed in a row, best value
13785317021SBarry Smith                  depends on the number of nonzeros in row of original matrix
13885317021SBarry Smith 
13985317021SBarry Smith    Options Database Key:
140b7c853c4SBarry Smith .  -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance
14185317021SBarry Smith 
14285317021SBarry Smith    Level: intermediate
14385317021SBarry Smith 
14485317021SBarry Smith       There are NO default values for the 3 parameters, you must set them with reasonable values for your
14585317021SBarry Smith       matrix. We don't know how to compute reasonable values.
14685317021SBarry Smith 
14785317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, ILU
14878fc6b22SHong Zhang */
1497087cfbeSBarry Smith PetscErrorCode  PCFactorSetDropTolerance(PC pc,PetscReal dt,PetscReal dtcol,PetscInt maxrowcount)
15085317021SBarry Smith {
1514ac538c5SBarry Smith   PetscErrorCode ierr;
15285317021SBarry Smith 
15385317021SBarry Smith   PetscFunctionBegin;
1540700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
155c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
156c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,maxrowcount,3);
1574ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetDropTolerance_C",(PC,PetscReal,PetscReal,PetscInt),(pc,dt,dtcol,maxrowcount));CHKERRQ(ierr);
15885317021SBarry Smith   PetscFunctionReturn(0);
15985317021SBarry Smith }
16085317021SBarry Smith 
16185317021SBarry Smith #undef __FUNCT__
16285317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels"
16385317021SBarry Smith /*@
16485317021SBarry Smith    PCFactorSetLevels - Sets the number of levels of fill to use.
16585317021SBarry Smith 
166ad4df100SBarry Smith    Logically Collective on PC
16785317021SBarry Smith 
16885317021SBarry Smith    Input Parameters:
16985317021SBarry Smith +  pc - the preconditioner context
17085317021SBarry Smith -  levels - number of levels of fill
17185317021SBarry Smith 
17285317021SBarry Smith    Options Database Key:
17385317021SBarry Smith .  -pc_factor_levels <levels> - Sets fill level
17485317021SBarry Smith 
17585317021SBarry Smith    Level: intermediate
17685317021SBarry Smith 
17785317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
17885317021SBarry Smith @*/
1797087cfbeSBarry Smith PetscErrorCode  PCFactorSetLevels(PC pc,PetscInt levels)
18085317021SBarry Smith {
1814ac538c5SBarry Smith   PetscErrorCode ierr;
18285317021SBarry Smith 
18385317021SBarry Smith   PetscFunctionBegin;
1840700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
185e7e72b3dSBarry Smith   if (levels < 0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"negative levels");
186c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,levels,2);
1874ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetLevels_C",(PC,PetscInt),(pc,levels));CHKERRQ(ierr);
18885317021SBarry Smith   PetscFunctionReturn(0);
18985317021SBarry Smith }
19085317021SBarry Smith 
19185317021SBarry Smith #undef __FUNCT__
19285317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill"
19385317021SBarry Smith /*@
19485317021SBarry Smith    PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
19585317021SBarry Smith    treated as level 0 fill even if there is no non-zero location.
19685317021SBarry Smith 
197ad4df100SBarry Smith    Logically Collective on PC
19885317021SBarry Smith 
19985317021SBarry Smith    Input Parameters:
20085317021SBarry Smith +  pc - the preconditioner context
20185317021SBarry Smith 
20285317021SBarry Smith    Options Database Key:
20385317021SBarry Smith .  -pc_factor_diagonal_fill
20485317021SBarry Smith 
20585317021SBarry Smith    Notes:
20685317021SBarry Smith    Does not apply with 0 fill.
20785317021SBarry Smith 
20885317021SBarry Smith    Level: intermediate
20985317021SBarry Smith 
21085317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
21185317021SBarry Smith @*/
2127087cfbeSBarry Smith PetscErrorCode  PCFactorSetAllowDiagonalFill(PC pc)
21385317021SBarry Smith {
2144ac538c5SBarry Smith   PetscErrorCode ierr;
21585317021SBarry Smith 
21685317021SBarry Smith   PetscFunctionBegin;
2170700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2184ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC),(pc));CHKERRQ(ierr);
21985317021SBarry Smith   PetscFunctionReturn(0);
22085317021SBarry Smith }
22185317021SBarry Smith 
22285317021SBarry Smith #undef __FUNCT__
22385317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal"
22485317021SBarry Smith /*@
22585317021SBarry Smith    PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal
22685317021SBarry Smith 
227ad4df100SBarry Smith    Logically Collective on PC
22885317021SBarry Smith 
22985317021SBarry Smith    Input Parameters:
23085317021SBarry Smith +  pc - the preconditioner context
23185317021SBarry Smith -  tol - diagonal entries smaller than this in absolute value are considered zero
23285317021SBarry Smith 
23385317021SBarry Smith    Options Database Key:
23485317021SBarry Smith .  -pc_factor_nonzeros_along_diagonal
23585317021SBarry Smith 
23685317021SBarry Smith    Level: intermediate
23785317021SBarry Smith 
23885317021SBarry Smith .keywords: PC, set, factorization, direct, fill
23985317021SBarry Smith 
24085317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal()
24185317021SBarry Smith @*/
2427087cfbeSBarry Smith PetscErrorCode  PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol)
24385317021SBarry Smith {
2444ac538c5SBarry Smith   PetscErrorCode ierr;
24585317021SBarry Smith 
24685317021SBarry Smith   PetscFunctionBegin;
2470700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
248c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,rtol,2);
2494ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr);
25085317021SBarry Smith   PetscFunctionReturn(0);
25185317021SBarry Smith }
25285317021SBarry Smith 
25385317021SBarry Smith #undef __FUNCT__
25485317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage"
255bf6011e8SBarry Smith /*@C
25685317021SBarry Smith    PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization
25785317021SBarry Smith 
258ad4df100SBarry Smith    Logically Collective on PC
25985317021SBarry Smith 
26085317021SBarry Smith    Input Parameters:
26185317021SBarry Smith +  pc - the preconditioner context
26285317021SBarry Smith -  stype - for example, spooles, superlu, superlu_dist
26385317021SBarry Smith 
26485317021SBarry Smith    Options Database Key:
26585317021SBarry Smith .  -pc_factor_mat_solver_package <stype> - spooles, petsc, superlu, superlu_dist, mumps
26685317021SBarry Smith 
26785317021SBarry Smith    Level: intermediate
26885317021SBarry Smith 
26985317021SBarry Smith    Note:
27085317021SBarry Smith      By default this will use the PETSc factorization if it exists
27185317021SBarry Smith 
27285317021SBarry Smith 
27385317021SBarry Smith .keywords: PC, set, factorization, direct, fill
27485317021SBarry Smith 
2757112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
27685317021SBarry Smith 
27785317021SBarry Smith @*/
2787087cfbeSBarry Smith PetscErrorCode  PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype)
27985317021SBarry Smith {
2804ac538c5SBarry Smith   PetscErrorCode ierr;
28185317021SBarry Smith 
28285317021SBarry Smith   PetscFunctionBegin;
2830700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2844ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr);
28585317021SBarry Smith   PetscFunctionReturn(0);
28685317021SBarry Smith }
28785317021SBarry Smith 
28885317021SBarry Smith #undef __FUNCT__
2897112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage"
290bf6011e8SBarry Smith /*@C
2917112b564SBarry Smith    PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization
2927112b564SBarry Smith 
293c5eb9154SBarry Smith    Not Collective
2947112b564SBarry Smith 
2957112b564SBarry Smith    Input Parameter:
2967112b564SBarry Smith .  pc - the preconditioner context
2977112b564SBarry Smith 
2987112b564SBarry Smith    Output Parameter:
2997112b564SBarry Smith .   stype - for example, spooles, superlu, superlu_dist
3007112b564SBarry Smith 
3017112b564SBarry Smith    Level: intermediate
3027112b564SBarry Smith 
3037112b564SBarry Smith 
3047112b564SBarry Smith .keywords: PC, set, factorization, direct, fill
3057112b564SBarry Smith 
3067112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
3077112b564SBarry Smith 
3087112b564SBarry Smith @*/
3097087cfbeSBarry Smith PetscErrorCode  PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype)
3107112b564SBarry Smith {
3114ac538c5SBarry Smith   PetscErrorCode ierr;
3127112b564SBarry Smith 
3137112b564SBarry Smith   PetscFunctionBegin;
3140700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
3154ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorGetMatSolverPackage_C",(PC,const MatSolverPackage*),(pc,stype));CHKERRQ(ierr);
3167112b564SBarry Smith   PetscFunctionReturn(0);
3177112b564SBarry Smith }
3187112b564SBarry Smith 
3197112b564SBarry Smith #undef __FUNCT__
32085317021SBarry Smith #define __FUNCT__ "PCFactorSetFill"
32185317021SBarry Smith /*@
32285317021SBarry Smith    PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix,
32385317021SBarry Smith    fill = number nonzeros in factor/number nonzeros in original matrix.
32485317021SBarry Smith 
325c5eb9154SBarry Smith    Not Collective, each process can expect a different amount of fill
32685317021SBarry Smith 
32785317021SBarry Smith    Input Parameters:
32885317021SBarry Smith +  pc - the preconditioner context
32985317021SBarry Smith -  fill - amount of expected fill
33085317021SBarry Smith 
33185317021SBarry Smith    Options Database Key:
33285317021SBarry Smith .  -pc_factor_fill <fill> - Sets fill amount
33385317021SBarry Smith 
33485317021SBarry Smith    Level: intermediate
33585317021SBarry Smith 
33685317021SBarry Smith    Note:
33785317021SBarry Smith    For sparse matrix factorizations it is difficult to predict how much
33885317021SBarry Smith    fill to expect. By running with the option -info PETSc will print the
33985317021SBarry Smith    actual amount of fill used; allowing you to set the value accurately for
34085317021SBarry Smith    future runs. Default PETSc uses a value of 5.0
34185317021SBarry Smith 
342*01a79839SBarry Smith    This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels.
343*01a79839SBarry Smith 
344*01a79839SBarry Smith 
34585317021SBarry Smith .keywords: PC, set, factorization, direct, fill
34685317021SBarry Smith 
34785317021SBarry Smith @*/
3487087cfbeSBarry Smith PetscErrorCode  PCFactorSetFill(PC pc,PetscReal fill)
34985317021SBarry Smith {
3504ac538c5SBarry Smith   PetscErrorCode ierr;
35185317021SBarry Smith 
35285317021SBarry Smith   PetscFunctionBegin;
3530700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
354e7e72b3dSBarry Smith   if (fill < 1.0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0");
3554ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr);
35685317021SBarry Smith   PetscFunctionReturn(0);
35785317021SBarry Smith }
35885317021SBarry Smith 
35985317021SBarry Smith #undef __FUNCT__
36085317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace"
36185317021SBarry Smith /*@
36285317021SBarry Smith    PCFactorSetUseInPlace - Tells the system to do an in-place factorization.
36385317021SBarry Smith    For dense matrices, this enables the solution of much larger problems.
36485317021SBarry Smith    For sparse matrices the factorization cannot be done truly in-place
36585317021SBarry Smith    so this does not save memory during the factorization, but after the matrix
36685317021SBarry Smith    is factored, the original unfactored matrix is freed, thus recovering that
36785317021SBarry Smith    space.
36885317021SBarry Smith 
369ad4df100SBarry Smith    Logically Collective on PC
37085317021SBarry Smith 
37185317021SBarry Smith    Input Parameters:
37285317021SBarry Smith .  pc - the preconditioner context
37385317021SBarry Smith 
37485317021SBarry Smith    Options Database Key:
37585317021SBarry Smith .  -pc_factor_in_place - Activates in-place factorization
37685317021SBarry Smith 
37785317021SBarry Smith    Notes:
37885317021SBarry Smith    PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when
37985317021SBarry Smith    a different matrix is provided for the multiply and the preconditioner in
38085317021SBarry Smith    a call to KSPSetOperators().
38185317021SBarry Smith    This is because the Krylov space methods require an application of the
38285317021SBarry Smith    matrix multiplication, which is not possible here because the matrix has
38385317021SBarry Smith    been factored in-place, replacing the original matrix.
38485317021SBarry Smith 
38585317021SBarry Smith    Level: intermediate
38685317021SBarry Smith 
38785317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU
38885317021SBarry Smith 
38985317021SBarry Smith .seealso: PCILUSetUseInPlace()
39085317021SBarry Smith @*/
3917087cfbeSBarry Smith PetscErrorCode  PCFactorSetUseInPlace(PC pc)
39285317021SBarry Smith {
3934ac538c5SBarry Smith   PetscErrorCode ierr;
39485317021SBarry Smith 
39585317021SBarry Smith   PetscFunctionBegin;
3960700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
3974ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC),(pc));CHKERRQ(ierr);
39885317021SBarry Smith   PetscFunctionReturn(0);
39985317021SBarry Smith }
40085317021SBarry Smith 
40185317021SBarry Smith #undef __FUNCT__
40285317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType"
40385317021SBarry Smith /*@C
40485317021SBarry Smith     PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to
40585317021SBarry Smith     be used in the LU factorization.
40685317021SBarry Smith 
407ad4df100SBarry Smith     Logically Collective on PC
40885317021SBarry Smith 
40985317021SBarry Smith     Input Parameters:
41085317021SBarry Smith +   pc - the preconditioner context
4112692d6eeSBarry Smith -   ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM
41285317021SBarry Smith 
41385317021SBarry Smith     Options Database Key:
41485317021SBarry Smith .   -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine
41585317021SBarry Smith 
41685317021SBarry Smith     Level: intermediate
41785317021SBarry Smith 
41885317021SBarry Smith     Notes: nested dissection is used by default
41985317021SBarry Smith 
42085317021SBarry Smith     For Cholesky and ICC and the SBAIJ format reorderings are not available,
42185317021SBarry Smith     since only the upper triangular part of the matrix is stored. You can use the
42285317021SBarry Smith     SeqAIJ format in this case to get reorderings.
42385317021SBarry Smith 
42485317021SBarry Smith @*/
4257087cfbeSBarry Smith PetscErrorCode  PCFactorSetMatOrderingType(PC pc,const MatOrderingType ordering)
42685317021SBarry Smith {
4274ac538c5SBarry Smith   PetscErrorCode ierr;
42885317021SBarry Smith 
42985317021SBarry Smith   PetscFunctionBegin;
430c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
4314ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,const MatOrderingType),(pc,ordering));CHKERRQ(ierr);
43285317021SBarry Smith   PetscFunctionReturn(0);
43385317021SBarry Smith }
43485317021SBarry Smith 
43585317021SBarry Smith #undef __FUNCT__
4368ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot"
43785317021SBarry Smith /*@
4388ff23777SHong Zhang     PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization.
43985317021SBarry Smith       For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices
440e3c5b3baSBarry Smith       it is never done. For the MATLAB and SuperLU factorization this is used.
44185317021SBarry Smith 
442ad4df100SBarry Smith     Logically Collective on PC
44385317021SBarry Smith 
44485317021SBarry Smith     Input Parameters:
44585317021SBarry Smith +   pc - the preconditioner context
44685317021SBarry Smith -   dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable)
44785317021SBarry Smith 
44885317021SBarry Smith     Options Database Key:
44985317021SBarry Smith .   -pc_factor_pivoting <dtcol>
45085317021SBarry Smith 
45185317021SBarry Smith     Level: intermediate
45285317021SBarry Smith 
45385317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks()
45485317021SBarry Smith @*/
4557087cfbeSBarry Smith PetscErrorCode  PCFactorSetColumnPivot(PC pc,PetscReal dtcol)
45685317021SBarry Smith {
4574ac538c5SBarry Smith   PetscErrorCode ierr;
45885317021SBarry Smith 
45985317021SBarry Smith   PetscFunctionBegin;
460c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
461c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
4624ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr);
46385317021SBarry Smith   PetscFunctionReturn(0);
46485317021SBarry Smith }
46585317021SBarry Smith 
46685317021SBarry Smith #undef __FUNCT__
46785317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks"
46885317021SBarry Smith /*@
46985317021SBarry Smith     PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block
47085317021SBarry Smith       with BAIJ or SBAIJ matrices
47185317021SBarry Smith 
472ad4df100SBarry Smith     Logically Collective on PC
47385317021SBarry Smith 
47485317021SBarry Smith     Input Parameters:
47585317021SBarry Smith +   pc - the preconditioner context
47685317021SBarry Smith -   pivot - PETSC_TRUE or PETSC_FALSE
47785317021SBarry Smith 
47885317021SBarry Smith     Options Database Key:
47985317021SBarry Smith .   -pc_factor_pivot_in_blocks <true,false>
48085317021SBarry Smith 
48185317021SBarry Smith     Level: intermediate
48285317021SBarry Smith 
4838ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot()
48485317021SBarry Smith @*/
4857087cfbeSBarry Smith PetscErrorCode  PCFactorSetPivotInBlocks(PC pc,PetscBool  pivot)
48685317021SBarry Smith {
4874ac538c5SBarry Smith   PetscErrorCode ierr;
48885317021SBarry Smith 
48985317021SBarry Smith   PetscFunctionBegin;
490c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
491acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,pivot,2);
4924ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr);
49385317021SBarry Smith   PetscFunctionReturn(0);
49485317021SBarry Smith }
49585317021SBarry Smith 
49685317021SBarry Smith #undef __FUNCT__
49785317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill"
49885317021SBarry Smith /*@
49985317021SBarry Smith    PCFactorSetReuseFill - When matrices with same different nonzero structure are factored,
50085317021SBarry Smith    this causes later ones to use the fill ratio computed in the initial factorization.
50185317021SBarry Smith 
502ad4df100SBarry Smith    Logically Collective on PC
50385317021SBarry Smith 
50485317021SBarry Smith    Input Parameters:
50585317021SBarry Smith +  pc - the preconditioner context
50685317021SBarry Smith -  flag - PETSC_TRUE to reuse else PETSC_FALSE
50785317021SBarry Smith 
50885317021SBarry Smith    Options Database Key:
50985317021SBarry Smith .  -pc_factor_reuse_fill - Activates PCFactorSetReuseFill()
51085317021SBarry Smith 
51185317021SBarry Smith    Level: intermediate
51285317021SBarry Smith 
51385317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky
51485317021SBarry Smith 
51585317021SBarry Smith .seealso: PCFactorSetReuseOrdering()
51685317021SBarry Smith @*/
5177087cfbeSBarry Smith PetscErrorCode  PCFactorSetReuseFill(PC pc,PetscBool  flag)
51885317021SBarry Smith {
5194ac538c5SBarry Smith   PetscErrorCode ierr;
52085317021SBarry Smith 
52185317021SBarry Smith   PetscFunctionBegin;
5220700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,2);
523acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,flag,2);
5244ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr);
52585317021SBarry Smith   PetscFunctionReturn(0);
52685317021SBarry Smith }
527