xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision acfcf0e5ba359b58e6a8a7af3f239cd7334278e8)
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__
6ee45ca4aSHong Zhang #define __FUNCT__ "PCFactorSetZeroPivot"
7ee45ca4aSHong Zhang /*@
8ee45ca4aSHong Zhang    PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero
9ee45ca4aSHong Zhang 
10ad4df100SBarry Smith    Logically Collective on PC
11ee45ca4aSHong Zhang 
12ee45ca4aSHong Zhang    Input Parameters:
13afaefe49SHong Zhang +  pc - the preconditioner context
14afaefe49SHong Zhang -  zero - all pivots smaller than this will be considered zero
15ee45ca4aSHong Zhang 
16ee45ca4aSHong Zhang    Options Database Key:
17ee45ca4aSHong Zhang .  -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot
18ee45ca4aSHong Zhang 
19ee45ca4aSHong Zhang    Level: intermediate
20ee45ca4aSHong Zhang 
21ee45ca4aSHong Zhang .keywords: PC, set, factorization, direct, fill
22ee45ca4aSHong Zhang 
23daa17b54SHong Zhang .seealso: PCFactorSetShiftType(), PCFactorSetShiftAmount()
24ee45ca4aSHong Zhang @*/
25dba47a55SKris Buschelman PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetZeroPivot(PC pc,PetscReal zero)
26ee45ca4aSHong Zhang {
274ac538c5SBarry Smith   PetscErrorCode ierr;
28afaefe49SHong Zhang 
29ee45ca4aSHong Zhang   PetscFunctionBegin;
300700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
31c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,zero,2);
324ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetZeroPivot_C",(PC,PetscReal),(pc,zero));CHKERRQ(ierr);
33ee45ca4aSHong Zhang   PetscFunctionReturn(0);
34ee45ca4aSHong Zhang }
35ee45ca4aSHong Zhang 
365e8efad8SHong Zhang #undef __FUNCT__
37d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftType"
38915743fcSHong Zhang /*@
39915743fcSHong Zhang    PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during
40915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
41915743fcSHong Zhang 
42ad4df100SBarry Smith    Logically Collective on PC
43915743fcSHong Zhang 
44915743fcSHong Zhang    Input Parameters:
45915743fcSHong Zhang +  pc - the preconditioner context
46915743fcSHong Zhang -  shifttype - type of shift; one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO,  MAT_SHIFT_POSITIVE_DEFINITE, MAT_SHIFT_INBLOCKS
47915743fcSHong Zhang 
48915743fcSHong Zhang    Options Database Key:
49915743fcSHong Zhang .  -pc_factor_shift_type <shifttype> - Sets shift type or PETSC_DECIDE for the default; use '-help' for a list of available types
50915743fcSHong Zhang 
51915743fcSHong Zhang    Level: intermediate
52915743fcSHong Zhang 
53915743fcSHong Zhang .keywords: PC, set, factorization,
54915743fcSHong Zhang 
55915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftAmount()
56915743fcSHong Zhang @*/
57d90ac83dSHong Zhang PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftType(PC pc,MatFactorShiftType shifttype)
58d90ac83dSHong Zhang {
594ac538c5SBarry Smith   PetscErrorCode ierr;
60d90ac83dSHong Zhang 
61d90ac83dSHong Zhang   PetscFunctionBegin;
620700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
63c5eb9154SBarry Smith   PetscValidLogicalCollectiveEnum(pc,shifttype,2);
644ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftType_C",(PC,MatFactorShiftType),(pc,shifttype));CHKERRQ(ierr);
65d90ac83dSHong Zhang   PetscFunctionReturn(0);
66d90ac83dSHong Zhang }
67d90ac83dSHong Zhang 
68d90ac83dSHong Zhang #undef __FUNCT__
69d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftAmount"
70915743fcSHong Zhang /*@
71915743fcSHong Zhang    PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during
72915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
73915743fcSHong Zhang 
74ad4df100SBarry Smith    Logically Collective on PC
75915743fcSHong Zhang 
76915743fcSHong Zhang    Input Parameters:
77915743fcSHong Zhang +  pc - the preconditioner context
78915743fcSHong Zhang -  shiftamount - amount of shift
79915743fcSHong Zhang 
80915743fcSHong Zhang    Options Database Key:
81915743fcSHong Zhang .  -pc_factor_shift_amount <shiftamount> - Sets shift amount or PETSC_DECIDE for the default
82915743fcSHong Zhang 
83915743fcSHong Zhang    Level: intermediate
84915743fcSHong Zhang 
85915743fcSHong Zhang .keywords: PC, set, factorization,
86915743fcSHong Zhang 
87915743fcSHong Zhang .seealso: PCFactorSetZeroPivot(), PCFactorSetShiftType()
88915743fcSHong Zhang @*/
89d90ac83dSHong Zhang PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetShiftAmount(PC pc,PetscReal shiftamount)
90d90ac83dSHong Zhang {
914ac538c5SBarry Smith   PetscErrorCode ierr;
92d90ac83dSHong Zhang 
93d90ac83dSHong Zhang   PetscFunctionBegin;
940700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
95c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,shiftamount,2);
964ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetShiftAmount_C",(PC,PetscReal),(pc,shiftamount));CHKERRQ(ierr);
97d90ac83dSHong Zhang   PetscFunctionReturn(0);
98d90ac83dSHong Zhang }
99d90ac83dSHong Zhang 
100d90ac83dSHong Zhang #undef __FUNCT__
101b7c853c4SBarry Smith #define __FUNCT__ "PCFactorSetDropTolerance"
10278fc6b22SHong Zhang /*
103b7c853c4SBarry Smith    PCFactorSetDropTolerance - The preconditioner will use an ILU
10478fc6b22SHong Zhang    based on a drop tolerance. (Under development)
10585317021SBarry Smith 
106ad4df100SBarry Smith    Logically Collective on PC
10785317021SBarry Smith 
10885317021SBarry Smith    Input Parameters:
10985317021SBarry Smith +  pc - the preconditioner context
11085317021SBarry Smith .  dt - the drop tolerance, try from 1.e-10 to .1
11185317021SBarry Smith .  dtcol - tolerance for column pivot, good values [0.1 to 0.01]
11285317021SBarry Smith -  maxrowcount - the max number of nonzeros allowed in a row, best value
11385317021SBarry Smith                  depends on the number of nonzeros in row of original matrix
11485317021SBarry Smith 
11585317021SBarry Smith    Options Database Key:
116b7c853c4SBarry Smith .  -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance
11785317021SBarry Smith 
11885317021SBarry Smith    Level: intermediate
11985317021SBarry Smith 
12085317021SBarry Smith       There are NO default values for the 3 parameters, you must set them with reasonable values for your
12185317021SBarry Smith       matrix. We don't know how to compute reasonable values.
12285317021SBarry Smith 
12385317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, ILU
12478fc6b22SHong Zhang */
125b7c853c4SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetDropTolerance(PC pc,PetscReal dt,PetscReal dtcol,PetscInt maxrowcount)
12685317021SBarry Smith {
1274ac538c5SBarry Smith   PetscErrorCode ierr;
12885317021SBarry Smith 
12985317021SBarry Smith   PetscFunctionBegin;
1300700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
131c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
132c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,maxrowcount,3);
1334ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetDropTolerance_C",(PC,PetscReal,PetscReal,PetscInt),(pc,dt,dtcol,maxrowcount));CHKERRQ(ierr);
13485317021SBarry Smith   PetscFunctionReturn(0);
13585317021SBarry Smith }
13685317021SBarry Smith 
13785317021SBarry Smith #undef __FUNCT__
13885317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels"
13985317021SBarry Smith /*@
14085317021SBarry Smith    PCFactorSetLevels - Sets the number of levels of fill to use.
14185317021SBarry Smith 
142ad4df100SBarry Smith    Logically Collective on PC
14385317021SBarry Smith 
14485317021SBarry Smith    Input Parameters:
14585317021SBarry Smith +  pc - the preconditioner context
14685317021SBarry Smith -  levels - number of levels of fill
14785317021SBarry Smith 
14885317021SBarry Smith    Options Database Key:
14985317021SBarry Smith .  -pc_factor_levels <levels> - Sets fill level
15085317021SBarry Smith 
15185317021SBarry Smith    Level: intermediate
15285317021SBarry Smith 
15385317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
15485317021SBarry Smith @*/
15585317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetLevels(PC pc,PetscInt levels)
15685317021SBarry Smith {
1574ac538c5SBarry Smith   PetscErrorCode ierr;
15885317021SBarry Smith 
15985317021SBarry Smith   PetscFunctionBegin;
1600700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
161e7e72b3dSBarry Smith   if (levels < 0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"negative levels");
162c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc,levels,2);
1634ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetLevels_C",(PC,PetscInt),(pc,levels));CHKERRQ(ierr);
16485317021SBarry Smith   PetscFunctionReturn(0);
16585317021SBarry Smith }
16685317021SBarry Smith 
16785317021SBarry Smith #undef __FUNCT__
16885317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill"
16985317021SBarry Smith /*@
17085317021SBarry Smith    PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
17185317021SBarry Smith    treated as level 0 fill even if there is no non-zero location.
17285317021SBarry Smith 
173ad4df100SBarry Smith    Logically Collective on PC
17485317021SBarry Smith 
17585317021SBarry Smith    Input Parameters:
17685317021SBarry Smith +  pc - the preconditioner context
17785317021SBarry Smith 
17885317021SBarry Smith    Options Database Key:
17985317021SBarry Smith .  -pc_factor_diagonal_fill
18085317021SBarry Smith 
18185317021SBarry Smith    Notes:
18285317021SBarry Smith    Does not apply with 0 fill.
18385317021SBarry Smith 
18485317021SBarry Smith    Level: intermediate
18585317021SBarry Smith 
18685317021SBarry Smith .keywords: PC, levels, fill, factorization, incomplete, ILU
18785317021SBarry Smith @*/
18885317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetAllowDiagonalFill(PC pc)
18985317021SBarry Smith {
1904ac538c5SBarry Smith   PetscErrorCode ierr;
19185317021SBarry Smith 
19285317021SBarry Smith   PetscFunctionBegin;
1930700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
1944ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetAllowDiagonalFill_C",(PC),(pc));CHKERRQ(ierr);
19585317021SBarry Smith   PetscFunctionReturn(0);
19685317021SBarry Smith }
19785317021SBarry Smith 
19885317021SBarry Smith #undef __FUNCT__
19985317021SBarry Smith #define __FUNCT__ "PCFactorReorderForNonzeroDiagonal"
20085317021SBarry Smith /*@
20185317021SBarry Smith    PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal
20285317021SBarry Smith 
203ad4df100SBarry Smith    Logically Collective on PC
20485317021SBarry Smith 
20585317021SBarry Smith    Input Parameters:
20685317021SBarry Smith +  pc - the preconditioner context
20785317021SBarry Smith -  tol - diagonal entries smaller than this in absolute value are considered zero
20885317021SBarry Smith 
20985317021SBarry Smith    Options Database Key:
21085317021SBarry Smith .  -pc_factor_nonzeros_along_diagonal
21185317021SBarry Smith 
21285317021SBarry Smith    Level: intermediate
21385317021SBarry Smith 
21485317021SBarry Smith .keywords: PC, set, factorization, direct, fill
21585317021SBarry Smith 
21685317021SBarry Smith .seealso: PCFactorSetFill(), PCFactorSetShiftNonzero(), PCFactorSetZeroPivot(), MatReorderForNonzeroDiagonal()
21785317021SBarry Smith @*/
21885317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorReorderForNonzeroDiagonal(PC pc,PetscReal rtol)
21985317021SBarry Smith {
2204ac538c5SBarry Smith   PetscErrorCode ierr;
22185317021SBarry Smith 
22285317021SBarry Smith   PetscFunctionBegin;
2230700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
224c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,rtol,2);
2254ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorReorderForNonzeroDiagonal_C",(PC,PetscReal),(pc,rtol));CHKERRQ(ierr);
22685317021SBarry Smith   PetscFunctionReturn(0);
22785317021SBarry Smith }
22885317021SBarry Smith 
22985317021SBarry Smith #undef __FUNCT__
23085317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage"
231bf6011e8SBarry Smith /*@C
23285317021SBarry Smith    PCFactorSetMatSolverPackage - sets the software that is used to perform the factorization
23385317021SBarry Smith 
234ad4df100SBarry Smith    Logically Collective on PC
23585317021SBarry Smith 
23685317021SBarry Smith    Input Parameters:
23785317021SBarry Smith +  pc - the preconditioner context
23885317021SBarry Smith -  stype - for example, spooles, superlu, superlu_dist
23985317021SBarry Smith 
24085317021SBarry Smith    Options Database Key:
24185317021SBarry Smith .  -pc_factor_mat_solver_package <stype> - spooles, petsc, superlu, superlu_dist, mumps
24285317021SBarry Smith 
24385317021SBarry Smith    Level: intermediate
24485317021SBarry Smith 
24585317021SBarry Smith    Note:
24685317021SBarry Smith      By default this will use the PETSc factorization if it exists
24785317021SBarry Smith 
24885317021SBarry Smith 
24985317021SBarry Smith .keywords: PC, set, factorization, direct, fill
25085317021SBarry Smith 
2517112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
25285317021SBarry Smith 
25385317021SBarry Smith @*/
25485317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetMatSolverPackage(PC pc,const MatSolverPackage stype)
25585317021SBarry Smith {
2564ac538c5SBarry Smith   PetscErrorCode ierr;
25785317021SBarry Smith 
25885317021SBarry Smith   PetscFunctionBegin;
2590700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2604ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatSolverPackage_C",(PC,const MatSolverPackage),(pc,stype));CHKERRQ(ierr);
26185317021SBarry Smith   PetscFunctionReturn(0);
26285317021SBarry Smith }
26385317021SBarry Smith 
26485317021SBarry Smith #undef __FUNCT__
2657112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage"
266bf6011e8SBarry Smith /*@C
2677112b564SBarry Smith    PCFactorGetMatSolverPackage - gets the software that is used to perform the factorization
2687112b564SBarry Smith 
269c5eb9154SBarry Smith    Not Collective
2707112b564SBarry Smith 
2717112b564SBarry Smith    Input Parameter:
2727112b564SBarry Smith .  pc - the preconditioner context
2737112b564SBarry Smith 
2747112b564SBarry Smith    Output Parameter:
2757112b564SBarry Smith .   stype - for example, spooles, superlu, superlu_dist
2767112b564SBarry Smith 
2777112b564SBarry Smith    Level: intermediate
2787112b564SBarry Smith 
2797112b564SBarry Smith 
2807112b564SBarry Smith .keywords: PC, set, factorization, direct, fill
2817112b564SBarry Smith 
2827112b564SBarry Smith .seealso: MatGetFactor(), MatSolverPackage, PCFactorGetMatSolverPackage()
2837112b564SBarry Smith 
2847112b564SBarry Smith @*/
2857112b564SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorGetMatSolverPackage(PC pc,const MatSolverPackage *stype)
2867112b564SBarry Smith {
2874ac538c5SBarry Smith   PetscErrorCode ierr;
2887112b564SBarry Smith 
2897112b564SBarry Smith   PetscFunctionBegin;
2900700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
2914ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorGetMatSolverPackage_C",(PC,const MatSolverPackage*),(pc,stype));CHKERRQ(ierr);
2927112b564SBarry Smith   PetscFunctionReturn(0);
2937112b564SBarry Smith }
2947112b564SBarry Smith 
2957112b564SBarry Smith #undef __FUNCT__
29685317021SBarry Smith #define __FUNCT__ "PCFactorSetFill"
29785317021SBarry Smith /*@
29885317021SBarry Smith    PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix,
29985317021SBarry Smith    fill = number nonzeros in factor/number nonzeros in original matrix.
30085317021SBarry Smith 
301c5eb9154SBarry Smith    Not Collective, each process can expect a different amount of fill
30285317021SBarry Smith 
30385317021SBarry Smith    Input Parameters:
30485317021SBarry Smith +  pc - the preconditioner context
30585317021SBarry Smith -  fill - amount of expected fill
30685317021SBarry Smith 
30785317021SBarry Smith    Options Database Key:
30885317021SBarry Smith .  -pc_factor_fill <fill> - Sets fill amount
30985317021SBarry Smith 
31085317021SBarry Smith    Level: intermediate
31185317021SBarry Smith 
31285317021SBarry Smith    Note:
31385317021SBarry Smith    For sparse matrix factorizations it is difficult to predict how much
31485317021SBarry Smith    fill to expect. By running with the option -info PETSc will print the
31585317021SBarry Smith    actual amount of fill used; allowing you to set the value accurately for
31685317021SBarry Smith    future runs. Default PETSc uses a value of 5.0
31785317021SBarry Smith 
31885317021SBarry Smith .keywords: PC, set, factorization, direct, fill
31985317021SBarry Smith 
32085317021SBarry Smith @*/
32185317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetFill(PC pc,PetscReal fill)
32285317021SBarry Smith {
3234ac538c5SBarry Smith   PetscErrorCode ierr;
32485317021SBarry Smith 
32585317021SBarry Smith   PetscFunctionBegin;
3260700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
327e7e72b3dSBarry Smith   if (fill < 1.0) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_OUTOFRANGE,"Fill factor cannot be less then 1.0");
3284ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetFill_C",(PC,PetscReal),(pc,fill));CHKERRQ(ierr);
32985317021SBarry Smith   PetscFunctionReturn(0);
33085317021SBarry Smith }
33185317021SBarry Smith 
33285317021SBarry Smith #undef __FUNCT__
33385317021SBarry Smith #define __FUNCT__ "PCFactorSetUseInPlace"
33485317021SBarry Smith /*@
33585317021SBarry Smith    PCFactorSetUseInPlace - Tells the system to do an in-place factorization.
33685317021SBarry Smith    For dense matrices, this enables the solution of much larger problems.
33785317021SBarry Smith    For sparse matrices the factorization cannot be done truly in-place
33885317021SBarry Smith    so this does not save memory during the factorization, but after the matrix
33985317021SBarry Smith    is factored, the original unfactored matrix is freed, thus recovering that
34085317021SBarry Smith    space.
34185317021SBarry Smith 
342ad4df100SBarry Smith    Logically Collective on PC
34385317021SBarry Smith 
34485317021SBarry Smith    Input Parameters:
34585317021SBarry Smith .  pc - the preconditioner context
34685317021SBarry Smith 
34785317021SBarry Smith    Options Database Key:
34885317021SBarry Smith .  -pc_factor_in_place - Activates in-place factorization
34985317021SBarry Smith 
35085317021SBarry Smith    Notes:
35185317021SBarry Smith    PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when
35285317021SBarry Smith    a different matrix is provided for the multiply and the preconditioner in
35385317021SBarry Smith    a call to KSPSetOperators().
35485317021SBarry Smith    This is because the Krylov space methods require an application of the
35585317021SBarry Smith    matrix multiplication, which is not possible here because the matrix has
35685317021SBarry Smith    been factored in-place, replacing the original matrix.
35785317021SBarry Smith 
35885317021SBarry Smith    Level: intermediate
35985317021SBarry Smith 
36085317021SBarry Smith .keywords: PC, set, factorization, direct, inplace, in-place, LU
36185317021SBarry Smith 
36285317021SBarry Smith .seealso: PCILUSetUseInPlace()
36385317021SBarry Smith @*/
36485317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetUseInPlace(PC pc)
36585317021SBarry Smith {
3664ac538c5SBarry Smith   PetscErrorCode ierr;
36785317021SBarry Smith 
36885317021SBarry Smith   PetscFunctionBegin;
3690700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
3704ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetUseInPlace_C",(PC),(pc));CHKERRQ(ierr);
37185317021SBarry Smith   PetscFunctionReturn(0);
37285317021SBarry Smith }
37385317021SBarry Smith 
37485317021SBarry Smith #undef __FUNCT__
37585317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType"
37685317021SBarry Smith /*@C
37785317021SBarry Smith     PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to
37885317021SBarry Smith     be used in the LU factorization.
37985317021SBarry Smith 
380ad4df100SBarry Smith     Logically Collective on PC
38185317021SBarry Smith 
38285317021SBarry Smith     Input Parameters:
38385317021SBarry Smith +   pc - the preconditioner context
3842692d6eeSBarry Smith -   ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM
38585317021SBarry Smith 
38685317021SBarry Smith     Options Database Key:
38785317021SBarry Smith .   -pc_factor_mat_ordering_type <nd,rcm,...> - Sets ordering routine
38885317021SBarry Smith 
38985317021SBarry Smith     Level: intermediate
39085317021SBarry Smith 
39185317021SBarry Smith     Notes: nested dissection is used by default
39285317021SBarry Smith 
39385317021SBarry Smith     For Cholesky and ICC and the SBAIJ format reorderings are not available,
39485317021SBarry Smith     since only the upper triangular part of the matrix is stored. You can use the
39585317021SBarry Smith     SeqAIJ format in this case to get reorderings.
39685317021SBarry Smith 
39785317021SBarry Smith @*/
39885317021SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetMatOrderingType(PC pc,const MatOrderingType ordering)
39985317021SBarry Smith {
4004ac538c5SBarry Smith   PetscErrorCode ierr;
40185317021SBarry Smith 
40285317021SBarry Smith   PetscFunctionBegin;
403c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
4044ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetMatOrderingType_C",(PC,const MatOrderingType),(pc,ordering));CHKERRQ(ierr);
40585317021SBarry Smith   PetscFunctionReturn(0);
40685317021SBarry Smith }
40785317021SBarry Smith 
40885317021SBarry Smith #undef __FUNCT__
4098ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot"
41085317021SBarry Smith /*@
4118ff23777SHong Zhang     PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization.
41285317021SBarry Smith       For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices
41385317021SBarry Smith       it is never done. For the Matlab and SuperLU factorization this is used.
41485317021SBarry Smith 
415ad4df100SBarry Smith     Logically Collective on PC
41685317021SBarry Smith 
41785317021SBarry Smith     Input Parameters:
41885317021SBarry Smith +   pc - the preconditioner context
41985317021SBarry Smith -   dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable)
42085317021SBarry Smith 
42185317021SBarry Smith     Options Database Key:
42285317021SBarry Smith .   -pc_factor_pivoting <dtcol>
42385317021SBarry Smith 
42485317021SBarry Smith     Level: intermediate
42585317021SBarry Smith 
42685317021SBarry Smith .seealso: PCILUSetMatOrdering(), PCFactorSetPivotInBlocks()
42785317021SBarry Smith @*/
4288ff23777SHong Zhang PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetColumnPivot(PC pc,PetscReal dtcol)
42985317021SBarry Smith {
4304ac538c5SBarry Smith   PetscErrorCode ierr;
43185317021SBarry Smith 
43285317021SBarry Smith   PetscFunctionBegin;
433c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
434c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc,dtcol,2);
4354ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetColumnPivot_C",(PC,PetscReal),(pc,dtcol));CHKERRQ(ierr);
43685317021SBarry Smith   PetscFunctionReturn(0);
43785317021SBarry Smith }
43885317021SBarry Smith 
43985317021SBarry Smith #undef __FUNCT__
44085317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks"
44185317021SBarry Smith /*@
44285317021SBarry Smith     PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block
44385317021SBarry Smith       with BAIJ or SBAIJ matrices
44485317021SBarry Smith 
445ad4df100SBarry Smith     Logically Collective on PC
44685317021SBarry Smith 
44785317021SBarry Smith     Input Parameters:
44885317021SBarry Smith +   pc - the preconditioner context
44985317021SBarry Smith -   pivot - PETSC_TRUE or PETSC_FALSE
45085317021SBarry Smith 
45185317021SBarry Smith     Options Database Key:
45285317021SBarry Smith .   -pc_factor_pivot_in_blocks <true,false>
45385317021SBarry Smith 
45485317021SBarry Smith     Level: intermediate
45585317021SBarry Smith 
4568ff23777SHong Zhang .seealso: PCILUSetMatOrdering(), PCFactorSetColumnPivot()
45785317021SBarry Smith @*/
458ace3abfcSBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetPivotInBlocks(PC pc,PetscBool  pivot)
45985317021SBarry Smith {
4604ac538c5SBarry Smith   PetscErrorCode ierr;
46185317021SBarry Smith 
46285317021SBarry Smith   PetscFunctionBegin;
463c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
464*acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,pivot,2);
4654ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetPivotInBlocks_C",(PC,PetscBool),(pc,pivot));CHKERRQ(ierr);
46685317021SBarry Smith   PetscFunctionReturn(0);
46785317021SBarry Smith }
46885317021SBarry Smith 
46985317021SBarry Smith #undef __FUNCT__
47085317021SBarry Smith #define __FUNCT__ "PCFactorSetReuseFill"
47185317021SBarry Smith /*@
47285317021SBarry Smith    PCFactorSetReuseFill - When matrices with same different nonzero structure are factored,
47385317021SBarry Smith    this causes later ones to use the fill ratio computed in the initial factorization.
47485317021SBarry Smith 
475ad4df100SBarry Smith    Logically Collective on PC
47685317021SBarry Smith 
47785317021SBarry Smith    Input Parameters:
47885317021SBarry Smith +  pc - the preconditioner context
47985317021SBarry Smith -  flag - PETSC_TRUE to reuse else PETSC_FALSE
48085317021SBarry Smith 
48185317021SBarry Smith    Options Database Key:
48285317021SBarry Smith .  -pc_factor_reuse_fill - Activates PCFactorSetReuseFill()
48385317021SBarry Smith 
48485317021SBarry Smith    Level: intermediate
48585317021SBarry Smith 
48685317021SBarry Smith .keywords: PC, levels, reordering, factorization, incomplete, Cholesky
48785317021SBarry Smith 
48885317021SBarry Smith .seealso: PCFactorSetReuseOrdering()
48985317021SBarry Smith @*/
490ace3abfcSBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCFactorSetReuseFill(PC pc,PetscBool  flag)
49185317021SBarry Smith {
4924ac538c5SBarry Smith   PetscErrorCode ierr;
49385317021SBarry Smith 
49485317021SBarry Smith   PetscFunctionBegin;
4950700a824SBarry Smith   PetscValidHeaderSpecific(pc,PC_CLASSID,2);
496*acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc,flag,2);
4974ac538c5SBarry Smith   ierr = PetscTryMethod(pc,"PCFactorSetReuseFill_C",(PC,PetscBool),(pc,flag));CHKERRQ(ierr);
49885317021SBarry Smith   PetscFunctionReturn(0);
49985317021SBarry Smith }
500