xref: /petsc/src/ksp/pc/impls/factor/factor.c (revision 9371c9d470a9602b6d10a8bf50c9b2280a79e45a)
15e8efad8SHong Zhang 
2c6db04a5SJed Brown #include <../src/ksp/pc/impls/factor/factor.h> /*I "petscpc.h" I*/
3978beb7fSPierre Jolivet #include <petsc/private/matimpl.h>
45e8efad8SHong Zhang 
54ac6704cSBarry Smith /*
64ac6704cSBarry Smith     If an ordering is not yet set and the matrix is available determine a default ordering
74ac6704cSBarry Smith */
8*9371c9d4SSatish Balay PetscErrorCode PCFactorSetDefaultOrdering_Factor(PC pc) {
9978beb7fSPierre Jolivet   PetscBool   foundmtype, flg;
1026cc229bSBarry Smith   const char *prefix;
114ac6704cSBarry Smith 
124ac6704cSBarry Smith   PetscFunctionBegin;
134ac6704cSBarry Smith   if (pc->pmat) {
1426cc229bSBarry Smith     PetscCall(PCGetOptionsPrefix(pc, &prefix));
1526cc229bSBarry Smith     PetscCall(MatSetOptionsPrefixFactor(pc->pmat, prefix));
164ac6704cSBarry Smith     PC_Factor *fact = (PC_Factor *)pc->data;
179566063dSJacob Faibussowitsch     PetscCall(MatSolverTypeGet(fact->solvertype, ((PetscObject)pc->pmat)->type_name, fact->factortype, NULL, &foundmtype, NULL));
18978beb7fSPierre Jolivet     if (foundmtype) {
194ac6704cSBarry Smith       if (!fact->fact) {
209566063dSJacob Faibussowitsch         PetscCall(MatGetFactor(pc->pmat, fact->solvertype, fact->factortype, &fact->fact));
21978beb7fSPierre Jolivet       } else if (!fact->fact->assembled) {
229566063dSJacob Faibussowitsch         PetscCall(PetscStrcmp(fact->solvertype, fact->fact->solvertype, &flg));
23978beb7fSPierre Jolivet         if (!flg) {
2426cc229bSBarry Smith           Mat B;
259566063dSJacob Faibussowitsch           PetscCall(MatGetFactor(pc->pmat, fact->solvertype, fact->factortype, &B));
269566063dSJacob Faibussowitsch           PetscCall(MatHeaderReplace(fact->fact, &B));
27978beb7fSPierre Jolivet         }
284ac6704cSBarry Smith       }
294ac6704cSBarry Smith       if (!fact->ordering) {
304ac6704cSBarry Smith         PetscBool       canuseordering;
314ac6704cSBarry Smith         MatOrderingType otype;
324ac6704cSBarry Smith 
339566063dSJacob Faibussowitsch         PetscCall(MatFactorGetCanUseOrdering(fact->fact, &canuseordering));
344ac6704cSBarry Smith         if (canuseordering) {
359566063dSJacob Faibussowitsch           PetscCall(MatFactorGetPreferredOrdering(fact->fact, fact->factortype, &otype));
364ac6704cSBarry Smith         } else otype = MATORDERINGEXTERNAL;
379566063dSJacob Faibussowitsch         PetscCall(PetscStrallocpy(otype, (char **)&fact->ordering));
384ac6704cSBarry Smith       }
394ac6704cSBarry Smith     }
40978beb7fSPierre Jolivet   }
414ac6704cSBarry Smith   PetscFunctionReturn(0);
424ac6704cSBarry Smith }
434ac6704cSBarry Smith 
44*9371c9d4SSatish Balay static PetscErrorCode PCFactorSetReuseOrdering_Factor(PC pc, PetscBool flag) {
453d1c1ea0SBarry Smith   PC_Factor *lu = (PC_Factor *)pc->data;
463d1c1ea0SBarry Smith 
473d1c1ea0SBarry Smith   PetscFunctionBegin;
483d1c1ea0SBarry Smith   lu->reuseordering = flag;
493d1c1ea0SBarry Smith   PetscFunctionReturn(0);
503d1c1ea0SBarry Smith }
513d1c1ea0SBarry Smith 
52*9371c9d4SSatish Balay static PetscErrorCode PCFactorSetReuseFill_Factor(PC pc, PetscBool flag) {
533d1c1ea0SBarry Smith   PC_Factor *lu = (PC_Factor *)pc->data;
543d1c1ea0SBarry Smith 
553d1c1ea0SBarry Smith   PetscFunctionBegin;
563d1c1ea0SBarry Smith   lu->reusefill = flag;
573d1c1ea0SBarry Smith   PetscFunctionReturn(0);
583d1c1ea0SBarry Smith }
593d1c1ea0SBarry Smith 
60*9371c9d4SSatish Balay static PetscErrorCode PCFactorSetUseInPlace_Factor(PC pc, PetscBool flg) {
613d1c1ea0SBarry Smith   PC_Factor *dir = (PC_Factor *)pc->data;
623d1c1ea0SBarry Smith 
633d1c1ea0SBarry Smith   PetscFunctionBegin;
643d1c1ea0SBarry Smith   dir->inplace = flg;
653d1c1ea0SBarry Smith   PetscFunctionReturn(0);
663d1c1ea0SBarry Smith }
673d1c1ea0SBarry Smith 
68*9371c9d4SSatish Balay static PetscErrorCode PCFactorGetUseInPlace_Factor(PC pc, PetscBool *flg) {
693d1c1ea0SBarry Smith   PC_Factor *dir = (PC_Factor *)pc->data;
703d1c1ea0SBarry Smith 
713d1c1ea0SBarry Smith   PetscFunctionBegin;
723d1c1ea0SBarry Smith   *flg = dir->inplace;
733d1c1ea0SBarry Smith   PetscFunctionReturn(0);
743d1c1ea0SBarry Smith }
753d1c1ea0SBarry Smith 
76f8260c8fSBarry Smith /*@
773ca39a21SBarry Smith     PCFactorSetUpMatSolverType - Can be called after KSPSetOperators() or PCSetOperators(), causes MatGetFactor() to be called so then one may
78f8260c8fSBarry Smith        set the options for that particular factorization object.
79f8260c8fSBarry Smith 
80f8260c8fSBarry Smith   Input Parameter:
81f8260c8fSBarry Smith .  pc  - the preconditioner context
82f8260c8fSBarry Smith 
8395452b02SPatrick Sanan   Notes:
8495452b02SPatrick Sanan     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.
85f8260c8fSBarry Smith 
862bd2b0e6SSatish Balay   Level: intermediate
872bd2b0e6SSatish Balay 
88db781477SPatrick Sanan .seealso: `PCFactorSetMatSolverType()`, `PCFactorGetMatrix()`
89f8260c8fSBarry Smith @*/
90*9371c9d4SSatish Balay PetscErrorCode PCFactorSetUpMatSolverType(PC pc) {
91f8260c8fSBarry Smith   PetscFunctionBegin;
92f8260c8fSBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
93cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetUpMatSolverType_C", (PC), (pc));
94b3a44c85SBarry Smith   PetscFunctionReturn(0);
95f8260c8fSBarry Smith }
96f8260c8fSBarry Smith 
97ee45ca4aSHong Zhang /*@
98ee45ca4aSHong Zhang    PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero
99ee45ca4aSHong Zhang 
100ad4df100SBarry Smith    Logically Collective on PC
101ee45ca4aSHong Zhang 
102ee45ca4aSHong Zhang    Input Parameters:
103afaefe49SHong Zhang +  pc - the preconditioner context
104afaefe49SHong Zhang -  zero - all pivots smaller than this will be considered zero
105ee45ca4aSHong Zhang 
106ee45ca4aSHong Zhang    Options Database Key:
107ee45ca4aSHong Zhang .  -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot
108ee45ca4aSHong Zhang 
109ee45ca4aSHong Zhang    Level: intermediate
110ee45ca4aSHong Zhang 
111db781477SPatrick Sanan .seealso: `PCFactorSetShiftType()`, `PCFactorSetShiftAmount()`
112ee45ca4aSHong Zhang @*/
113*9371c9d4SSatish Balay PetscErrorCode PCFactorSetZeroPivot(PC pc, PetscReal zero) {
114ee45ca4aSHong Zhang   PetscFunctionBegin;
1150700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
116c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc, zero, 2);
117cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetZeroPivot_C", (PC, PetscReal), (pc, zero));
118ee45ca4aSHong Zhang   PetscFunctionReturn(0);
119ee45ca4aSHong Zhang }
120ee45ca4aSHong Zhang 
121915743fcSHong Zhang /*@
122915743fcSHong Zhang    PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during
123915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
124915743fcSHong Zhang 
125ad4df100SBarry Smith    Logically Collective on PC
126915743fcSHong Zhang 
127915743fcSHong Zhang    Input Parameters:
128915743fcSHong Zhang +  pc - the preconditioner context
129915743fcSHong Zhang -  shifttype - type of shift; one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO,  MAT_SHIFT_POSITIVE_DEFINITE, MAT_SHIFT_INBLOCKS
130915743fcSHong Zhang 
131915743fcSHong Zhang    Options Database Key:
13228d58a37SPierre Jolivet .  -pc_factor_shift_type <shifttype> - Sets shift type; use '-help' for a list of available types
133915743fcSHong Zhang 
134915743fcSHong Zhang    Level: intermediate
135915743fcSHong Zhang 
136db781477SPatrick Sanan .seealso: `PCFactorSetZeroPivot()`, `PCFactorSetShiftAmount()`
137915743fcSHong Zhang @*/
138*9371c9d4SSatish Balay PetscErrorCode PCFactorSetShiftType(PC pc, MatFactorShiftType shifttype) {
139d90ac83dSHong Zhang   PetscFunctionBegin;
1400700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
141c5eb9154SBarry Smith   PetscValidLogicalCollectiveEnum(pc, shifttype, 2);
142cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetShiftType_C", (PC, MatFactorShiftType), (pc, shifttype));
143d90ac83dSHong Zhang   PetscFunctionReturn(0);
144d90ac83dSHong Zhang }
145d90ac83dSHong Zhang 
146915743fcSHong Zhang /*@
147915743fcSHong Zhang    PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during
148915743fcSHong Zhang      numerical factorization, thus the matrix has nonzero pivots
149915743fcSHong Zhang 
150ad4df100SBarry Smith    Logically Collective on PC
151915743fcSHong Zhang 
152915743fcSHong Zhang    Input Parameters:
153915743fcSHong Zhang +  pc - the preconditioner context
154915743fcSHong Zhang -  shiftamount - amount of shift
155915743fcSHong Zhang 
156915743fcSHong Zhang    Options Database Key:
157915743fcSHong Zhang .  -pc_factor_shift_amount <shiftamount> - Sets shift amount or PETSC_DECIDE for the default
158915743fcSHong Zhang 
159915743fcSHong Zhang    Level: intermediate
160915743fcSHong Zhang 
161db781477SPatrick Sanan .seealso: `PCFactorSetZeroPivot()`, `PCFactorSetShiftType()`
162915743fcSHong Zhang @*/
163*9371c9d4SSatish Balay PetscErrorCode PCFactorSetShiftAmount(PC pc, PetscReal shiftamount) {
164d90ac83dSHong Zhang   PetscFunctionBegin;
1650700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
166c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc, shiftamount, 2);
167cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetShiftAmount_C", (PC, PetscReal), (pc, shiftamount));
168d90ac83dSHong Zhang   PetscFunctionReturn(0);
169d90ac83dSHong Zhang }
170d90ac83dSHong Zhang 
1716d33885cSprj- /*@
172b7c853c4SBarry Smith    PCFactorSetDropTolerance - The preconditioner will use an ILU
17378fc6b22SHong Zhang    based on a drop tolerance. (Under development)
17485317021SBarry Smith 
175ad4df100SBarry Smith    Logically Collective on PC
17685317021SBarry Smith 
17785317021SBarry Smith    Input Parameters:
17885317021SBarry Smith +  pc - the preconditioner context
17985317021SBarry Smith .  dt - the drop tolerance, try from 1.e-10 to .1
18085317021SBarry Smith .  dtcol - tolerance for column pivot, good values [0.1 to 0.01]
18185317021SBarry Smith -  maxrowcount - the max number of nonzeros allowed in a row, best value
18285317021SBarry Smith                  depends on the number of nonzeros in row of original matrix
18385317021SBarry Smith 
18485317021SBarry Smith    Options Database Key:
185b7c853c4SBarry Smith .  -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance
18685317021SBarry Smith 
18785317021SBarry Smith    Level: intermediate
18885317021SBarry Smith 
18985317021SBarry Smith       There are NO default values for the 3 parameters, you must set them with reasonable values for your
19085317021SBarry Smith       matrix. We don't know how to compute reasonable values.
19185317021SBarry Smith 
1926d33885cSprj- @*/
193*9371c9d4SSatish Balay PetscErrorCode PCFactorSetDropTolerance(PC pc, PetscReal dt, PetscReal dtcol, PetscInt maxrowcount) {
19485317021SBarry Smith   PetscFunctionBegin;
1950700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
196064a246eSJacob Faibussowitsch   PetscValidLogicalCollectiveReal(pc, dtcol, 3);
197064a246eSJacob Faibussowitsch   PetscValidLogicalCollectiveInt(pc, maxrowcount, 4);
198cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetDropTolerance_C", (PC, PetscReal, PetscReal, PetscInt), (pc, dt, dtcol, maxrowcount));
19985317021SBarry Smith   PetscFunctionReturn(0);
20085317021SBarry Smith }
20185317021SBarry Smith 
202c7f610a1SBarry Smith /*@
203c7f610a1SBarry Smith    PCFactorGetZeroPivot - Gets the tolerance used to define a zero privot
204c7f610a1SBarry Smith 
205c7f610a1SBarry Smith    Not Collective
206c7f610a1SBarry Smith 
207c7f610a1SBarry Smith    Input Parameters:
208c7f610a1SBarry Smith .  pc - the preconditioner context
209c7f610a1SBarry Smith 
210c7f610a1SBarry Smith    Output Parameter:
211c7f610a1SBarry Smith .  pivot - the tolerance
212c7f610a1SBarry Smith 
213c7f610a1SBarry Smith    Level: intermediate
214c7f610a1SBarry Smith 
215db781477SPatrick Sanan .seealso: `PCFactorSetZeroPivot()`
216c7f610a1SBarry Smith @*/
217*9371c9d4SSatish Balay PetscErrorCode PCFactorGetZeroPivot(PC pc, PetscReal *pivot) {
218c7f610a1SBarry Smith   PetscFunctionBegin;
219c7f610a1SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
220cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetZeroPivot_C", (PC, PetscReal *), (pc, pivot));
221c7f610a1SBarry Smith   PetscFunctionReturn(0);
222c7f610a1SBarry Smith }
223c7f610a1SBarry Smith 
224c7f610a1SBarry Smith /*@
225c7f610a1SBarry Smith    PCFactorGetShiftAmount - Gets the tolerance used to define a zero privot
226c7f610a1SBarry Smith 
227c7f610a1SBarry Smith    Not Collective
228c7f610a1SBarry Smith 
229c7f610a1SBarry Smith    Input Parameters:
230c7f610a1SBarry Smith .  pc - the preconditioner context
231c7f610a1SBarry Smith 
232c7f610a1SBarry Smith    Output Parameter:
233c7f610a1SBarry Smith .  shift - how much to shift the diagonal entry
234c7f610a1SBarry Smith 
235c7f610a1SBarry Smith    Level: intermediate
236c7f610a1SBarry Smith 
237db781477SPatrick Sanan .seealso: `PCFactorSetShiftAmount()`, `PCFactorSetShiftType()`, `PCFactorGetShiftType()`
238c7f610a1SBarry Smith @*/
239*9371c9d4SSatish Balay PetscErrorCode PCFactorGetShiftAmount(PC pc, PetscReal *shift) {
240c7f610a1SBarry Smith   PetscFunctionBegin;
241c7f610a1SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
242cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetShiftAmount_C", (PC, PetscReal *), (pc, shift));
243c7f610a1SBarry Smith   PetscFunctionReturn(0);
244c7f610a1SBarry Smith }
245c7f610a1SBarry Smith 
246c7f610a1SBarry Smith /*@
247c7f610a1SBarry Smith    PCFactorGetShiftType - Gets the type of shift, if any, done when a zero pivot is detected
248c7f610a1SBarry Smith 
249c7f610a1SBarry Smith    Not Collective
250c7f610a1SBarry Smith 
251c7f610a1SBarry Smith    Input Parameters:
252c7f610a1SBarry Smith .  pc - the preconditioner context
253c7f610a1SBarry Smith 
254c7f610a1SBarry Smith    Output Parameter:
255c7f610a1SBarry Smith .  type - one of MAT_SHIFT_NONE, MAT_SHIFT_NONZERO,  MAT_SHIFT_POSITIVE_DEFINITE, or MAT_SHIFT_INBLOCKS
256c7f610a1SBarry Smith 
257c7f610a1SBarry Smith    Level: intermediate
258c7f610a1SBarry Smith 
259db781477SPatrick Sanan .seealso: `PCFactorSetShiftType()`, `MatFactorShiftType`, `PCFactorSetShiftAmount()`, `PCFactorGetShiftAmount()`
260c7f610a1SBarry Smith @*/
261*9371c9d4SSatish Balay PetscErrorCode PCFactorGetShiftType(PC pc, MatFactorShiftType *type) {
262c7f610a1SBarry Smith   PetscFunctionBegin;
263c7f610a1SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
264cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetShiftType_C", (PC, MatFactorShiftType *), (pc, type));
265c7f610a1SBarry Smith   PetscFunctionReturn(0);
266c7f610a1SBarry Smith }
267c7f610a1SBarry Smith 
2682591b318SToby Isaac /*@
2692591b318SToby Isaac    PCFactorGetLevels - Gets the number of levels of fill to use.
2702591b318SToby Isaac 
2712591b318SToby Isaac    Logically Collective on PC
2722591b318SToby Isaac 
2732591b318SToby Isaac    Input Parameters:
2742591b318SToby Isaac .  pc - the preconditioner context
2752591b318SToby Isaac 
2762591b318SToby Isaac    Output Parameter:
2772591b318SToby Isaac .  levels - number of levels of fill
2782591b318SToby Isaac 
2792591b318SToby Isaac    Level: intermediate
2802591b318SToby Isaac 
2812591b318SToby Isaac @*/
282*9371c9d4SSatish Balay PetscErrorCode PCFactorGetLevels(PC pc, PetscInt *levels) {
2832591b318SToby Isaac   PetscFunctionBegin;
2842591b318SToby Isaac   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
285cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetLevels_C", (PC, PetscInt *), (pc, levels));
2862591b318SToby Isaac   PetscFunctionReturn(0);
2872591b318SToby Isaac }
2882591b318SToby Isaac 
28985317021SBarry Smith /*@
29085317021SBarry Smith    PCFactorSetLevels - Sets the number of levels of fill to use.
29185317021SBarry Smith 
292ad4df100SBarry Smith    Logically Collective on PC
29385317021SBarry Smith 
29485317021SBarry Smith    Input Parameters:
29585317021SBarry Smith +  pc - the preconditioner context
29685317021SBarry Smith -  levels - number of levels of fill
29785317021SBarry Smith 
29885317021SBarry Smith    Options Database Key:
29985317021SBarry Smith .  -pc_factor_levels <levels> - Sets fill level
30085317021SBarry Smith 
30185317021SBarry Smith    Level: intermediate
30285317021SBarry Smith 
30385317021SBarry Smith @*/
304*9371c9d4SSatish Balay PetscErrorCode PCFactorSetLevels(PC pc, PetscInt levels) {
30585317021SBarry Smith   PetscFunctionBegin;
3060700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
3075f80ce2aSJacob Faibussowitsch   PetscCheck(levels >= 0, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_OUTOFRANGE, "negative levels");
308c5eb9154SBarry Smith   PetscValidLogicalCollectiveInt(pc, levels, 2);
309cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetLevels_C", (PC, PetscInt), (pc, levels));
31085317021SBarry Smith   PetscFunctionReturn(0);
31185317021SBarry Smith }
31285317021SBarry Smith 
31385317021SBarry Smith /*@
31485317021SBarry Smith    PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
31585317021SBarry Smith    treated as level 0 fill even if there is no non-zero location.
31685317021SBarry Smith 
317ad4df100SBarry Smith    Logically Collective on PC
31885317021SBarry Smith 
31985317021SBarry Smith    Input Parameters:
32085317021SBarry Smith +  pc - the preconditioner context
32192e9c092SBarry Smith -  flg - PETSC_TRUE to turn on, PETSC_FALSE to turn off
32285317021SBarry Smith 
32385317021SBarry Smith    Options Database Key:
32467b8a455SSatish Balay .  -pc_factor_diagonal_fill <bool> - allow the diagonal fill
32585317021SBarry Smith 
32685317021SBarry Smith    Notes:
32785317021SBarry Smith    Does not apply with 0 fill.
32885317021SBarry Smith 
32985317021SBarry Smith    Level: intermediate
33085317021SBarry Smith 
331db781477SPatrick Sanan .seealso: `PCFactorGetAllowDiagonalFill()`
33285317021SBarry Smith @*/
333*9371c9d4SSatish Balay PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc, PetscBool flg) {
33485317021SBarry Smith   PetscFunctionBegin;
3350700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
336cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetAllowDiagonalFill_C", (PC, PetscBool), (pc, flg));
33792e9c092SBarry Smith   PetscFunctionReturn(0);
33892e9c092SBarry Smith }
33992e9c092SBarry Smith 
34092e9c092SBarry Smith /*@
34192e9c092SBarry Smith    PCFactorGetAllowDiagonalFill - Determines if all diagonal matrix entries are
34292e9c092SBarry Smith        treated as level 0 fill even if there is no non-zero location.
34392e9c092SBarry Smith 
34492e9c092SBarry Smith    Logically Collective on PC
34592e9c092SBarry Smith 
34692e9c092SBarry Smith    Input Parameter:
34792e9c092SBarry Smith .  pc - the preconditioner context
34892e9c092SBarry Smith 
34992e9c092SBarry Smith    Output Parameter:
35092e9c092SBarry Smith .   flg - PETSC_TRUE to turn on, PETSC_FALSE to turn off
35192e9c092SBarry Smith 
35292e9c092SBarry Smith    Notes:
35392e9c092SBarry Smith    Does not apply with 0 fill.
35492e9c092SBarry Smith 
35592e9c092SBarry Smith    Level: intermediate
35692e9c092SBarry Smith 
357db781477SPatrick Sanan .seealso: `PCFactorSetAllowDiagonalFill()`
35892e9c092SBarry Smith @*/
359*9371c9d4SSatish Balay PetscErrorCode PCFactorGetAllowDiagonalFill(PC pc, PetscBool *flg) {
36092e9c092SBarry Smith   PetscFunctionBegin;
36192e9c092SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
362cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetAllowDiagonalFill_C", (PC, PetscBool *), (pc, flg));
36385317021SBarry Smith   PetscFunctionReturn(0);
36485317021SBarry Smith }
36585317021SBarry Smith 
36685317021SBarry Smith /*@
36785317021SBarry Smith    PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal
36885317021SBarry Smith 
369ad4df100SBarry Smith    Logically Collective on PC
37085317021SBarry Smith 
37185317021SBarry Smith    Input Parameters:
37285317021SBarry Smith +  pc - the preconditioner context
37385317021SBarry Smith -  tol - diagonal entries smaller than this in absolute value are considered zero
37485317021SBarry Smith 
37585317021SBarry Smith    Options Database Key:
376147403d9SBarry Smith .  -pc_factor_nonzeros_along_diagonal <tol> - perform the reordering with the given tolerance
37785317021SBarry Smith 
37885317021SBarry Smith    Level: intermediate
37985317021SBarry Smith 
380db781477SPatrick Sanan .seealso: `PCFactorSetFill()`, `PCFactorSetShiftNonzero()`, `PCFactorSetZeroPivot()`, `MatReorderForNonzeroDiagonal()`
38185317021SBarry Smith @*/
382*9371c9d4SSatish Balay PetscErrorCode PCFactorReorderForNonzeroDiagonal(PC pc, PetscReal rtol) {
38385317021SBarry Smith   PetscFunctionBegin;
3840700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
385c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc, rtol, 2);
386cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorReorderForNonzeroDiagonal_C", (PC, PetscReal), (pc, rtol));
38785317021SBarry Smith   PetscFunctionReturn(0);
38885317021SBarry Smith }
38985317021SBarry Smith 
390bf6011e8SBarry Smith /*@C
3913ca39a21SBarry Smith    PCFactorSetMatSolverType - sets the software that is used to perform the factorization
39285317021SBarry Smith 
393ad4df100SBarry Smith    Logically Collective on PC
39485317021SBarry Smith 
39585317021SBarry Smith    Input Parameters:
39685317021SBarry Smith +  pc - the preconditioner context
397f60c3dc2SHong Zhang -  stype - for example, superlu, superlu_dist
39885317021SBarry Smith 
39985317021SBarry Smith    Options Database Key:
4003ca39a21SBarry Smith .  -pc_factor_mat_solver_type <stype> - petsc, superlu, superlu_dist, mumps, cusparse
40185317021SBarry Smith 
40285317021SBarry Smith    Level: intermediate
40385317021SBarry Smith 
40485317021SBarry Smith    Note:
40585317021SBarry Smith      By default this will use the PETSc factorization if it exists
40685317021SBarry Smith 
407db781477SPatrick Sanan .seealso: `MatGetFactor()`, `MatSolverType`, `PCFactorGetMatSolverType()`
40885317021SBarry Smith @*/
409*9371c9d4SSatish Balay PetscErrorCode PCFactorSetMatSolverType(PC pc, MatSolverType stype) {
41085317021SBarry Smith   PetscFunctionBegin;
4110700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
412cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetMatSolverType_C", (PC, MatSolverType), (pc, stype));
41385317021SBarry Smith   PetscFunctionReturn(0);
41485317021SBarry Smith }
41585317021SBarry Smith 
416bf6011e8SBarry Smith /*@C
4173ca39a21SBarry Smith    PCFactorGetMatSolverType - gets the software that is used to perform the factorization
4187112b564SBarry Smith 
419c5eb9154SBarry Smith    Not Collective
4207112b564SBarry Smith 
4217112b564SBarry Smith    Input Parameter:
4227112b564SBarry Smith .  pc - the preconditioner context
4237112b564SBarry Smith 
4247112b564SBarry Smith    Output Parameter:
4250298fd71SBarry Smith .   stype - for example, superlu, superlu_dist (NULL if the PC does not have a solver package)
4267112b564SBarry Smith 
4277112b564SBarry Smith    Level: intermediate
4287112b564SBarry Smith 
429db781477SPatrick Sanan .seealso: `MatGetFactor()`, `MatSolverType`, `PCFactorGetMatSolverType()`
4307112b564SBarry Smith @*/
431*9371c9d4SSatish Balay PetscErrorCode PCFactorGetMatSolverType(PC pc, MatSolverType *stype) {
4325f80ce2aSJacob Faibussowitsch   PetscErrorCode (*f)(PC, MatSolverType *);
4337112b564SBarry Smith 
4347112b564SBarry Smith   PetscFunctionBegin;
4350700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
4365f80ce2aSJacob Faibussowitsch   PetscValidPointer(stype, 2);
4379566063dSJacob Faibussowitsch   PetscCall(PetscObjectQueryFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", &f));
4389566063dSJacob Faibussowitsch   if (f) PetscCall((*f)(pc, stype));
4395f80ce2aSJacob Faibussowitsch   else *stype = NULL;
4407112b564SBarry Smith   PetscFunctionReturn(0);
4417112b564SBarry Smith }
4427112b564SBarry Smith 
44385317021SBarry Smith /*@
44485317021SBarry Smith    PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix,
44585317021SBarry Smith    fill = number nonzeros in factor/number nonzeros in original matrix.
44685317021SBarry Smith 
447c5eb9154SBarry Smith    Not Collective, each process can expect a different amount of fill
44885317021SBarry Smith 
44985317021SBarry Smith    Input Parameters:
45085317021SBarry Smith +  pc - the preconditioner context
45185317021SBarry Smith -  fill - amount of expected fill
45285317021SBarry Smith 
45385317021SBarry Smith    Options Database Key:
45485317021SBarry Smith .  -pc_factor_fill <fill> - Sets fill amount
45585317021SBarry Smith 
45685317021SBarry Smith    Level: intermediate
45785317021SBarry Smith 
45885317021SBarry Smith    Note:
45985317021SBarry Smith    For sparse matrix factorizations it is difficult to predict how much
46085317021SBarry Smith    fill to expect. By running with the option -info PETSc will print the
46185317021SBarry Smith    actual amount of fill used; allowing you to set the value accurately for
46285317021SBarry Smith    future runs. Default PETSc uses a value of 5.0
46385317021SBarry Smith 
46401a79839SBarry Smith    This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with PCFactorSetLevels() or -pc_factor_levels.
46501a79839SBarry Smith 
46685317021SBarry Smith @*/
467*9371c9d4SSatish Balay PetscErrorCode PCFactorSetFill(PC pc, PetscReal fill) {
46885317021SBarry Smith   PetscFunctionBegin;
4690700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
4705f80ce2aSJacob Faibussowitsch   PetscCheck(fill >= 1.0, PetscObjectComm((PetscObject)pc), PETSC_ERR_ARG_OUTOFRANGE, "Fill factor cannot be less then 1.0");
471cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetFill_C", (PC, PetscReal), (pc, fill));
47285317021SBarry Smith   PetscFunctionReturn(0);
47385317021SBarry Smith }
47485317021SBarry Smith 
47585317021SBarry Smith /*@
47685317021SBarry Smith    PCFactorSetUseInPlace - Tells the system to do an in-place factorization.
47785317021SBarry Smith    For dense matrices, this enables the solution of much larger problems.
47885317021SBarry Smith    For sparse matrices the factorization cannot be done truly in-place
47985317021SBarry Smith    so this does not save memory during the factorization, but after the matrix
48085317021SBarry Smith    is factored, the original unfactored matrix is freed, thus recovering that
481ec5066bdSBarry Smith    space. For ICC(0) and ILU(0) with the default natural ordering the factorization is done efficiently in-place.
48285317021SBarry Smith 
483ad4df100SBarry Smith    Logically Collective on PC
48485317021SBarry Smith 
48585317021SBarry Smith    Input Parameters:
4868e37d05fSBarry Smith +  pc - the preconditioner context
4878e37d05fSBarry Smith -  flg - PETSC_TRUE to enable, PETSC_FALSE to disable
48885317021SBarry Smith 
48985317021SBarry Smith    Options Database Key:
4908e37d05fSBarry Smith .  -pc_factor_in_place <true,false>- Activate/deactivate in-place factorization
49185317021SBarry Smith 
49285317021SBarry Smith    Notes:
49385317021SBarry Smith    PCFactorSetUseInplace() can only be used with the KSP method KSPPREONLY or when
49485317021SBarry Smith    a different matrix is provided for the multiply and the preconditioner in
49585317021SBarry Smith    a call to KSPSetOperators().
49685317021SBarry Smith    This is because the Krylov space methods require an application of the
49785317021SBarry Smith    matrix multiplication, which is not possible here because the matrix has
49885317021SBarry Smith    been factored in-place, replacing the original matrix.
49985317021SBarry Smith 
50085317021SBarry Smith    Level: intermediate
50185317021SBarry Smith 
502db781477SPatrick Sanan .seealso: `PCFactorGetUseInPlace()`
50385317021SBarry Smith @*/
504*9371c9d4SSatish Balay PetscErrorCode PCFactorSetUseInPlace(PC pc, PetscBool flg) {
50585317021SBarry Smith   PetscFunctionBegin;
5060700a824SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
507cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetUseInPlace_C", (PC, PetscBool), (pc, flg));
5088e37d05fSBarry Smith   PetscFunctionReturn(0);
5098e37d05fSBarry Smith }
5108e37d05fSBarry Smith 
5118e37d05fSBarry Smith /*@
5128e37d05fSBarry Smith    PCFactorGetUseInPlace - Determines if an in-place factorization is being used.
5138e37d05fSBarry Smith 
5148e37d05fSBarry Smith    Logically Collective on PC
5158e37d05fSBarry Smith 
5168e37d05fSBarry Smith    Input Parameter:
5178e37d05fSBarry Smith .  pc - the preconditioner context
5188e37d05fSBarry Smith 
5198e37d05fSBarry Smith    Output Parameter:
5208e37d05fSBarry Smith .  flg - PETSC_TRUE to enable, PETSC_FALSE to disable
5218e37d05fSBarry Smith 
5228e37d05fSBarry Smith    Level: intermediate
5238e37d05fSBarry Smith 
524db781477SPatrick Sanan .seealso: `PCFactorSetUseInPlace()`
5258e37d05fSBarry Smith @*/
526*9371c9d4SSatish Balay PetscErrorCode PCFactorGetUseInPlace(PC pc, PetscBool *flg) {
5278e37d05fSBarry Smith   PetscFunctionBegin;
5288e37d05fSBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
529cac4c232SBarry Smith   PetscUseMethod(pc, "PCFactorGetUseInPlace_C", (PC, PetscBool *), (pc, flg));
53085317021SBarry Smith   PetscFunctionReturn(0);
53185317021SBarry Smith }
53285317021SBarry Smith 
53385317021SBarry Smith /*@C
53485317021SBarry Smith     PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to
5352c7c0729SBarry Smith     be used in the LU, ILU, Cholesky, and ICC factorizations.
53685317021SBarry Smith 
537ad4df100SBarry Smith     Logically Collective on PC
53885317021SBarry Smith 
53985317021SBarry Smith     Input Parameters:
54085317021SBarry Smith +   pc - the preconditioner context
5412692d6eeSBarry Smith -   ordering - the matrix ordering name, for example, MATORDERINGND or MATORDERINGRCM
54285317021SBarry Smith 
54385317021SBarry Smith     Options Database Key:
5442c7c0729SBarry Smith .   -pc_factor_mat_ordering_type <nd,rcm,...,external> - Sets ordering routine
54585317021SBarry Smith 
54685317021SBarry Smith     Level: intermediate
54785317021SBarry Smith 
54895452b02SPatrick Sanan     Notes:
5494ac6704cSBarry Smith       Nested dissection is used by default for some of PETSc's sparse matrix formats
55085317021SBarry Smith 
5519bd791bbSBarry Smith      For Cholesky and ICC and the SBAIJ format the only reordering available is natural since only the upper half of the matrix is stored
5529bd791bbSBarry Smith      and reordering this matrix is very expensive.
5539bd791bbSBarry Smith 
5544ac6704cSBarry Smith       You can use a SeqAIJ matrix with Cholesky and ICC and use any ordering.
5559bd791bbSBarry Smith 
5564ac6704cSBarry Smith       MATORDERINGEXTERNAL means PETSc will not compute an ordering and the package will use its own ordering, usable with MATSOLVERCHOLMOD, MATSOLVERUMFPACK, and others.
5572c7c0729SBarry Smith 
558db781477SPatrick Sanan .seealso: `MatOrderingType`
55985317021SBarry Smith 
56085317021SBarry Smith @*/
561*9371c9d4SSatish Balay PetscErrorCode PCFactorSetMatOrderingType(PC pc, MatOrderingType ordering) {
56285317021SBarry Smith   PetscFunctionBegin;
563c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
564cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetMatOrderingType_C", (PC, MatOrderingType), (pc, ordering));
56585317021SBarry Smith   PetscFunctionReturn(0);
56685317021SBarry Smith }
56785317021SBarry Smith 
56885317021SBarry Smith /*@
5698ff23777SHong Zhang     PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization.
57085317021SBarry Smith       For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices
571e3c5b3baSBarry Smith       it is never done. For the MATLAB and SuperLU factorization this is used.
57285317021SBarry Smith 
573ad4df100SBarry Smith     Logically Collective on PC
57485317021SBarry Smith 
57585317021SBarry Smith     Input Parameters:
57685317021SBarry Smith +   pc - the preconditioner context
57785317021SBarry Smith -   dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable)
57885317021SBarry Smith 
57985317021SBarry Smith     Options Database Key:
580147403d9SBarry Smith .   -pc_factor_pivoting <dtcol> - perform the pivoting with the given tolerance
58185317021SBarry Smith 
58285317021SBarry Smith     Level: intermediate
58385317021SBarry Smith 
584db781477SPatrick Sanan .seealso: `PCILUSetMatOrdering()`, `PCFactorSetPivotInBlocks()`
58585317021SBarry Smith @*/
586*9371c9d4SSatish Balay PetscErrorCode PCFactorSetColumnPivot(PC pc, PetscReal dtcol) {
58785317021SBarry Smith   PetscFunctionBegin;
588c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
589c5eb9154SBarry Smith   PetscValidLogicalCollectiveReal(pc, dtcol, 2);
590cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetColumnPivot_C", (PC, PetscReal), (pc, dtcol));
59185317021SBarry Smith   PetscFunctionReturn(0);
59285317021SBarry Smith }
59385317021SBarry Smith 
59485317021SBarry Smith /*@
59585317021SBarry Smith     PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block
59685317021SBarry Smith       with BAIJ or SBAIJ matrices
59785317021SBarry Smith 
598ad4df100SBarry Smith     Logically Collective on PC
59985317021SBarry Smith 
60085317021SBarry Smith     Input Parameters:
60185317021SBarry Smith +   pc - the preconditioner context
60285317021SBarry Smith -   pivot - PETSC_TRUE or PETSC_FALSE
60385317021SBarry Smith 
60485317021SBarry Smith     Options Database Key:
60567b8a455SSatish Balay .   -pc_factor_pivot_in_blocks <true,false> - Pivot inside matrix dense blocks for BAIJ and SBAIJ
60685317021SBarry Smith 
60785317021SBarry Smith     Level: intermediate
60885317021SBarry Smith 
609db781477SPatrick Sanan .seealso: `PCILUSetMatOrdering()`, `PCFactorSetColumnPivot()`
61085317021SBarry Smith @*/
611*9371c9d4SSatish Balay PetscErrorCode PCFactorSetPivotInBlocks(PC pc, PetscBool pivot) {
61285317021SBarry Smith   PetscFunctionBegin;
613c5eb9154SBarry Smith   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
614acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc, pivot, 2);
615cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetPivotInBlocks_C", (PC, PetscBool), (pc, pivot));
61685317021SBarry Smith   PetscFunctionReturn(0);
61785317021SBarry Smith }
61885317021SBarry Smith 
61985317021SBarry Smith /*@
620288e7d53SBarry Smith    PCFactorSetReuseFill - When matrices with different nonzero structure are factored,
62185317021SBarry Smith    this causes later ones to use the fill ratio computed in the initial factorization.
62285317021SBarry Smith 
623ad4df100SBarry Smith    Logically Collective on PC
62485317021SBarry Smith 
62585317021SBarry Smith    Input Parameters:
62685317021SBarry Smith +  pc - the preconditioner context
62785317021SBarry Smith -  flag - PETSC_TRUE to reuse else PETSC_FALSE
62885317021SBarry Smith 
62985317021SBarry Smith    Options Database Key:
63085317021SBarry Smith .  -pc_factor_reuse_fill - Activates PCFactorSetReuseFill()
63185317021SBarry Smith 
63285317021SBarry Smith    Level: intermediate
63385317021SBarry Smith 
634db781477SPatrick Sanan .seealso: `PCFactorSetReuseOrdering()`
63585317021SBarry Smith @*/
636*9371c9d4SSatish Balay PetscErrorCode PCFactorSetReuseFill(PC pc, PetscBool flag) {
63785317021SBarry Smith   PetscFunctionBegin;
638064a246eSJacob Faibussowitsch   PetscValidHeaderSpecific(pc, PC_CLASSID, 1);
639acfcf0e5SJed Brown   PetscValidLogicalCollectiveBool(pc, flag, 2);
640cac4c232SBarry Smith   PetscTryMethod(pc, "PCFactorSetReuseFill_C", (PC, PetscBool), (pc, flag));
64185317021SBarry Smith   PetscFunctionReturn(0);
64285317021SBarry Smith }
6433d1c1ea0SBarry Smith 
644*9371c9d4SSatish Balay PetscErrorCode PCFactorInitialize(PC pc, MatFactorType ftype) {
6453d1c1ea0SBarry Smith   PC_Factor *fact = (PC_Factor *)pc->data;
6463d1c1ea0SBarry Smith 
6473d1c1ea0SBarry Smith   PetscFunctionBegin;
6489566063dSJacob Faibussowitsch   PetscCall(MatFactorInfoInitialize(&fact->info));
6494ac6704cSBarry Smith   fact->factortype           = ftype;
6503d1c1ea0SBarry Smith   fact->info.shifttype       = (PetscReal)MAT_SHIFT_NONE;
6513d1c1ea0SBarry Smith   fact->info.shiftamount     = 100.0 * PETSC_MACHINE_EPSILON;
6523d1c1ea0SBarry Smith   fact->info.zeropivot       = 100.0 * PETSC_MACHINE_EPSILON;
6533d1c1ea0SBarry Smith   fact->info.pivotinblocks   = 1.0;
6543d1c1ea0SBarry Smith   pc->ops->getfactoredmatrix = PCFactorGetMatrix_Factor;
6553d1c1ea0SBarry Smith 
6569566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetZeroPivot_C", PCFactorSetZeroPivot_Factor));
6579566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetZeroPivot_C", PCFactorGetZeroPivot_Factor));
6589566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", PCFactorSetShiftType_Factor));
6599566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftType_C", PCFactorGetShiftType_Factor));
6609566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftAmount_C", PCFactorSetShiftAmount_Factor));
6619566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftAmount_C", PCFactorGetShiftAmount_Factor));
6629566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", PCFactorGetMatSolverType_Factor));
6639566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatSolverType_C", PCFactorSetMatSolverType_Factor));
6649566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUpMatSolverType_C", PCFactorSetUpMatSolverType_Factor));
6659566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetFill_C", PCFactorSetFill_Factor));
6669566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatOrderingType_C", PCFactorSetMatOrderingType_Factor));
6679566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetLevels_C", PCFactorSetLevels_Factor));
6689566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetLevels_C", PCFactorGetLevels_Factor));
6699566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetAllowDiagonalFill_C", PCFactorSetAllowDiagonalFill_Factor));
6709566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetAllowDiagonalFill_C", PCFactorGetAllowDiagonalFill_Factor));
6719566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetPivotInBlocks_C", PCFactorSetPivotInBlocks_Factor));
6729566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUseInPlace_C", PCFactorSetUseInPlace_Factor));
6739566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetUseInPlace_C", PCFactorGetUseInPlace_Factor));
6749566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseOrdering_C", PCFactorSetReuseOrdering_Factor));
6759566063dSJacob Faibussowitsch   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseFill_C", PCFactorSetReuseFill_Factor));
6763d1c1ea0SBarry Smith   PetscFunctionReturn(0);
6773d1c1ea0SBarry Smith }
6782e956fe4SStefano Zampini 
679*9371c9d4SSatish Balay PetscErrorCode PCFactorClearComposedFunctions(PC pc) {
6802e956fe4SStefano Zampini   PetscFunctionBegin;
6812e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetZeroPivot_C", NULL));
6822e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetZeroPivot_C", NULL));
6832e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", NULL));
6842e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftType_C", NULL));
6852e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftAmount_C", NULL));
6862e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftAmount_C", NULL));
6872e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", NULL));
6882e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatSolverType_C", NULL));
6892e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUpMatSolverType_C", NULL));
6902e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetFill_C", NULL));
6912e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatOrderingType_C", NULL));
6922e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetLevels_C", NULL));
6932e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetLevels_C", NULL));
6942e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetAllowDiagonalFill_C", NULL));
6952e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetAllowDiagonalFill_C", NULL));
6962e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetPivotInBlocks_C", NULL));
6972e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUseInPlace_C", NULL));
6982e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetUseInPlace_C", NULL));
6992e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseOrdering_C", NULL));
7002e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseFill_C", NULL));
7012e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorReorderForNonzeroDiagonal_C", NULL));
7022e956fe4SStefano Zampini   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetDropTolerance_C", NULL));
7032e956fe4SStefano Zampini   PetscFunctionReturn(0);
7042e956fe4SStefano Zampini }
705