Actual source code: factor.c


  2: #include <../src/ksp/pc/impls/factor/factor.h>
  3: #include <petsc/private/matimpl.h>

  5: /*
  6:     If an ordering is not yet set and the matrix is available determine a default ordering
  7: */
  8: PetscErrorCode PCFactorSetDefaultOrdering_Factor(PC pc)
  9: {
 10:   PetscBool   foundmtype, flg;
 11:   const char *prefix;

 13:   if (pc->pmat) {
 14:     PCGetOptionsPrefix(pc, &prefix);
 15:     MatSetOptionsPrefixFactor(pc->pmat, prefix);
 16:     PC_Factor *fact = (PC_Factor *)pc->data;
 17:     MatSolverTypeGet(fact->solvertype, ((PetscObject)pc->pmat)->type_name, fact->factortype, NULL, &foundmtype, NULL);
 18:     if (foundmtype) {
 19:       if (!fact->fact) {
 20:         MatGetFactor(pc->pmat, fact->solvertype, fact->factortype, &fact->fact);
 21:       } else if (!fact->fact->assembled) {
 22:         PetscStrcmp(fact->solvertype, fact->fact->solvertype, &flg);
 23:         if (!flg) {
 24:           Mat B;
 25:           MatGetFactor(pc->pmat, fact->solvertype, fact->factortype, &B);
 26:           MatHeaderReplace(fact->fact, &B);
 27:         }
 28:       }
 29:       if (!fact->ordering) {
 30:         PetscBool       canuseordering;
 31:         MatOrderingType otype;

 33:         MatFactorGetCanUseOrdering(fact->fact, &canuseordering);
 34:         if (canuseordering) {
 35:           MatFactorGetPreferredOrdering(fact->fact, fact->factortype, &otype);
 36:         } else otype = MATORDERINGEXTERNAL;
 37:         PetscStrallocpy(otype, (char **)&fact->ordering);
 38:       }
 39:     }
 40:   }
 41:   return 0;
 42: }

 44: static PetscErrorCode PCFactorSetReuseOrdering_Factor(PC pc, PetscBool flag)
 45: {
 46:   PC_Factor *lu = (PC_Factor *)pc->data;

 48:   lu->reuseordering = flag;
 49:   return 0;
 50: }

 52: static PetscErrorCode PCFactorSetReuseFill_Factor(PC pc, PetscBool flag)
 53: {
 54:   PC_Factor *lu = (PC_Factor *)pc->data;

 56:   lu->reusefill = flag;
 57:   return 0;
 58: }

 60: static PetscErrorCode PCFactorSetUseInPlace_Factor(PC pc, PetscBool flg)
 61: {
 62:   PC_Factor *dir = (PC_Factor *)pc->data;

 64:   dir->inplace = flg;
 65:   return 0;
 66: }

 68: static PetscErrorCode PCFactorGetUseInPlace_Factor(PC pc, PetscBool *flg)
 69: {
 70:   PC_Factor *dir = (PC_Factor *)pc->data;

 72:   *flg = dir->inplace;
 73:   return 0;
 74: }

 76: /*@
 77:     PCFactorSetUpMatSolverType - Can be called after `KSPSetOperators()` or `PCSetOperators()`, causes `MatGetFactor()` to be called so then one may
 78:        set the options for that particular factorization object.

 80:   Input Parameter:
 81: .  pc  - the preconditioner context

 83:   Note:
 84:   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.

 86:   Level: intermediate

 88: .seealso: `PCCHOLESKY`, `PCLU`, `PCFactorSetMatSolverType()`, `PCFactorGetMatrix()`
 89: @*/
 90: PetscErrorCode PCFactorSetUpMatSolverType(PC pc)
 91: {
 93:   PetscTryMethod(pc, "PCFactorSetUpMatSolverType_C", (PC), (pc));
 94:   return 0;
 95: }

 97: /*@
 98:    PCFactorSetZeroPivot - Sets the size at which smaller pivots are declared to be zero

100:    Logically Collective

102:    Input Parameters:
103: +  pc - the preconditioner context
104: -  zero - all pivots smaller than this will be considered zero

106:    Options Database Key:
107: .  -pc_factor_zeropivot <zero> - Sets tolerance for what is considered a zero pivot

109:    Level: intermediate

111: .seealso: `PCCHOLESKY`, `PCLU`, `PCFactorSetShiftType()`, `PCFactorSetShiftAmount()`
112: @*/
113: PetscErrorCode PCFactorSetZeroPivot(PC pc, PetscReal zero)
114: {
117:   PetscTryMethod(pc, "PCFactorSetZeroPivot_C", (PC, PetscReal), (pc, zero));
118:   return 0;
119: }

121: /*@
122:    PCFactorSetShiftType - adds a particular type of quantity to the diagonal of the matrix during
123:      numerical factorization, thus the matrix has nonzero pivots

125:    Logically Collective

127:    Input Parameters:
128: +  pc - the preconditioner context
129: -  shifttype - type of shift; one of `MAT_SHIFT_NONE`, `MAT_SHIFT_NONZERO`, `MAT_SHIFT_POSITIVE_DEFINITE`, `MAT_SHIFT_INBLOCKS`

131:    Options Database Key:
132: .  -pc_factor_shift_type <shifttype> - Sets shift type; use '-help' for a list of available types

134:    Level: intermediate

136: .seealso: `PCCHOLESKY`, `PCLU`, `PCFactorSetZeroPivot()`, `PCFactorSetShiftAmount()`
137: @*/
138: PetscErrorCode PCFactorSetShiftType(PC pc, MatFactorShiftType shifttype)
139: {
142:   PetscTryMethod(pc, "PCFactorSetShiftType_C", (PC, MatFactorShiftType), (pc, shifttype));
143:   return 0;
144: }

146: /*@
147:    PCFactorSetShiftAmount - adds a quantity to the diagonal of the matrix during
148:      numerical factorization, thus the matrix has nonzero pivots

150:    Logically Collective

152:    Input Parameters:
153: +  pc - the preconditioner context
154: -  shiftamount - amount of shift or `PETSC_DECIDE` for the default

156:    Options Database Key:
157: .  -pc_factor_shift_amount <shiftamount> - Sets shift amount or -1 for the default

159:    Level: intermediate

161: .seealso: `PCCHOLESKY`, `PCLU`, ``PCFactorSetZeroPivot()`, `PCFactorSetShiftType()`
162: @*/
163: PetscErrorCode PCFactorSetShiftAmount(PC pc, PetscReal shiftamount)
164: {
167:   PetscTryMethod(pc, "PCFactorSetShiftAmount_C", (PC, PetscReal), (pc, shiftamount));
168:   return 0;
169: }

171: /*@
172:    PCFactorSetDropTolerance - The preconditioner will use an `PCILU`
173:    based on a drop tolerance.

175:    Logically Collective

177:    Input Parameters:
178: +  pc - the preconditioner context
179: .  dt - the drop tolerance, try from 1.e-10 to .1
180: .  dtcol - tolerance for column pivot, good values [0.1 to 0.01]
181: -  maxrowcount - the max number of nonzeros allowed in a row, best value
182:                  depends on the number of nonzeros in row of original matrix

184:    Options Database Key:
185: .  -pc_factor_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance

187:    Level: intermediate

189:    Note:
190:    There are NO default values for the 3 parameters, you must set them with reasonable values for your
191:    matrix. We don't know how to compute reasonable values.

193: .seealso: `PCILU`
194: @*/
195: PetscErrorCode PCFactorSetDropTolerance(PC pc, PetscReal dt, PetscReal dtcol, PetscInt maxrowcount)
196: {
200:   PetscTryMethod(pc, "PCFactorSetDropTolerance_C", (PC, PetscReal, PetscReal, PetscInt), (pc, dt, dtcol, maxrowcount));
201:   return 0;
202: }

204: /*@
205:    PCFactorGetZeroPivot - Gets the tolerance used to define a zero privot

207:    Not Collective

209:    Input Parameters:
210: .  pc - the preconditioner context

212:    Output Parameter:
213: .  pivot - the tolerance

215:    Level: intermediate

217: .seealso: `PCLU`, `PCCHOLESKY`, `PCFactorSetZeroPivot()`
218: @*/
219: PetscErrorCode PCFactorGetZeroPivot(PC pc, PetscReal *pivot)
220: {
222:   PetscUseMethod(pc, "PCFactorGetZeroPivot_C", (PC, PetscReal *), (pc, pivot));
223:   return 0;
224: }

226: /*@
227:    PCFactorGetShiftAmount - Gets the tolerance used to define a zero privot

229:    Not Collective

231:    Input Parameters:
232: .  pc - the preconditioner context

234:    Output Parameter:
235: .  shift - how much to shift the diagonal entry

237:    Level: intermediate

239: .seealso: `PCLU`, `PCCHOLESKY`, `PCFactorSetShiftAmount()`, `PCFactorSetShiftType()`, `PCFactorGetShiftType()`
240: @*/
241: PetscErrorCode PCFactorGetShiftAmount(PC pc, PetscReal *shift)
242: {
244:   PetscUseMethod(pc, "PCFactorGetShiftAmount_C", (PC, PetscReal *), (pc, shift));
245:   return 0;
246: }

248: /*@
249:    PCFactorGetShiftType - Gets the type of shift, if any, done when a zero pivot is detected

251:    Not Collective

253:    Input Parameter:
254: .  pc - the preconditioner context

256:    Output Parameter:
257: .  type - one of `MAT_SHIFT_NONE`, `MAT_SHIFT_NONZERO`, `MAT_SHIFT_POSITIVE_DEFINITE`, or `MAT_SHIFT_INBLOCKS`

259:    Level: intermediate

261: .seealso: `PCLU`, `PCCHOLESKY`, `PCFactorSetShiftType()`, `MatFactorShiftType`, `PCFactorSetShiftAmount()`, `PCFactorGetShiftAmount()`
262: @*/
263: PetscErrorCode PCFactorGetShiftType(PC pc, MatFactorShiftType *type)
264: {
266:   PetscUseMethod(pc, "PCFactorGetShiftType_C", (PC, MatFactorShiftType *), (pc, type));
267:   return 0;
268: }

270: /*@
271:    PCFactorGetLevels - Gets the number of levels of fill to use.

273:    Logically Collective

275:    Input Parameters:
276: .  pc - the preconditioner context

278:    Output Parameter:
279: .  levels - number of levels of fill

281:    Level: intermediate

283: .seealso: `PCILU`, `PCICC`, `PCFactorSetLevels()`
284: @*/
285: PetscErrorCode PCFactorGetLevels(PC pc, PetscInt *levels)
286: {
288:   PetscUseMethod(pc, "PCFactorGetLevels_C", (PC, PetscInt *), (pc, levels));
289:   return 0;
290: }

292: /*@
293:    PCFactorSetLevels - Sets the number of levels of fill to use.

295:    Logically Collective

297:    Input Parameters:
298: +  pc - the preconditioner context
299: -  levels - number of levels of fill

301:    Options Database Key:
302: .  -pc_factor_levels <levels> - Sets fill level

304:    Level: intermediate

306: .seealso: `PCILU`, `PCICC`, `PCFactorGetLevels()`
307: @*/
308: PetscErrorCode PCFactorSetLevels(PC pc, PetscInt levels)
309: {
313:   PetscTryMethod(pc, "PCFactorSetLevels_C", (PC, PetscInt), (pc, levels));
314:   return 0;
315: }

317: /*@
318:    PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
319:    treated as level 0 fill even if there is no non-zero location.

321:    Logically Collective

323:    Input Parameters:
324: +  pc - the preconditioner context
325: -  flg - `PETSC_TRUE` to turn on, `PETSC_FALSE` to turn off

327:    Options Database Key:
328: .  -pc_factor_diagonal_fill <bool> - allow the diagonal fill

330:    Note:
331:    Does not apply with 0 fill.

333:    Level: intermediate

335: .seealso: `PCILU`, `PCICC`, `PCFactorGetAllowDiagonalFill()`
336: @*/
337: PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc, PetscBool flg)
338: {
340:   PetscTryMethod(pc, "PCFactorSetAllowDiagonalFill_C", (PC, PetscBool), (pc, flg));
341:   return 0;
342: }

344: /*@
345:    PCFactorGetAllowDiagonalFill - Determines if all diagonal matrix entries are
346:        treated as level 0 fill even if there is no non-zero location.

348:    Logically Collective

350:    Input Parameter:
351: .  pc - the preconditioner context

353:    Output Parameter:
354: .   flg - `PETSC_TRUE` to turn on, `PETSC_FALSE` to turn off

356:    Note:
357:    Does not apply with 0 fill.

359:    Level: intermediate

361: .seealso:  `PCILU`, `PCICC`, `PCFactorSetAllowDiagonalFill()`
362: @*/
363: PetscErrorCode PCFactorGetAllowDiagonalFill(PC pc, PetscBool *flg)
364: {
366:   PetscUseMethod(pc, "PCFactorGetAllowDiagonalFill_C", (PC, PetscBool *), (pc, flg));
367:   return 0;
368: }

370: /*@
371:    PCFactorReorderForNonzeroDiagonal - reorders rows/columns of matrix to remove zeros from diagonal

373:    Logically Collective

375:    Input Parameters:
376: +  pc - the preconditioner context
377: -  tol - diagonal entries smaller than this in absolute value are considered zero

379:    Options Database Key:
380: .  -pc_factor_nonzeros_along_diagonal <tol> - perform the reordering with the given tolerance

382:    Level: intermediate

384: .seealso:  `PCILU`, `PCICC`, `PCFactorSetFill()`, `PCFactorSetShiftNonzero()`, `PCFactorSetZeroPivot()`, `MatReorderForNonzeroDiagonal()`
385: @*/
386: PetscErrorCode PCFactorReorderForNonzeroDiagonal(PC pc, PetscReal rtol)
387: {
390:   PetscTryMethod(pc, "PCFactorReorderForNonzeroDiagonal_C", (PC, PetscReal), (pc, rtol));
391:   return 0;
392: }

394: /*@C
395:    PCFactorSetMatSolverType - sets the solver package that is used to perform the factorization

397:    Logically Collective

399:    Input Parameters:
400: +  pc - the preconditioner context
401: -  stype - for example, `MATSOLVERSUPERLU`, `MATSOLVERSUPERLU_DIST`, `MATSOLVERMUMPS`

403:    Options Database Key:
404: .  -pc_factor_mat_solver_type <stype> - petsc, superlu, superlu_dist, mumps, cusparse

406:    Level: intermediate

408:    Note:
409:    By default this will use the PETSc factorization if it exists

411: .seealso: `PCLU`, `PCCHOLESKY`, `MatGetFactor()`, `MatSolverType`, `PCFactorGetMatSolverType()`, `MatSolverType`,
412:           `MATSOLVERSUPERLU`, `MATSOLVERSUPERLU_DIST`, `MATSOLVERMUMPS`
413: @*/
414: PetscErrorCode PCFactorSetMatSolverType(PC pc, MatSolverType stype)
415: {
417:   PetscTryMethod(pc, "PCFactorSetMatSolverType_C", (PC, MatSolverType), (pc, stype));
418:   return 0;
419: }

421: /*@C
422:    PCFactorGetMatSolverType - gets the solver package that is used to perform the factorization

424:    Not Collective

426:    Input Parameter:
427: .  pc - the preconditioner context

429:    Output Parameter:
430: .   stype - for example, `MATSOLVERSUPERLU`, `MATSOLVERSUPERLU_DIST`, `MATSOLVERMUMPS`

432:    Level: intermediate

434: .seealso: `PCLU`, `PCCHOLESKY`, `MatGetFactor()`, `MatSolverType`, `PCFactorGetMatSolverType()`, `MatSolverType`,
435:           `MATSOLVERSUPERLU`, `MATSOLVERSUPERLU_DIST`, `MATSOLVERMUMPS`
436: @*/
437: PetscErrorCode PCFactorGetMatSolverType(PC pc, MatSolverType *stype)
438: {
439:   PetscErrorCode (*f)(PC, MatSolverType *);

443:   PetscObjectQueryFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", &f);
444:   if (f) (*f)(pc, stype);
445:   else *stype = NULL;
446:   return 0;
447: }

449: /*@
450:    PCFactorSetFill - Indicate the amount of fill you expect in the factored matrix,
451:    fill = number nonzeros in factor/number nonzeros in original matrix.

453:    Not Collective, each process can expect a different amount of fill

455:    Input Parameters:
456: +  pc - the preconditioner context
457: -  fill - amount of expected fill

459:    Options Database Key:
460: .  -pc_factor_fill <fill> - Sets fill amount

462:    Level: intermediate

464:    Notes:
465:    For sparse matrix factorizations it is difficult to predict how much
466:    fill to expect. By running with the option -info PETSc will print the
467:    actual amount of fill used; allowing you to set the value accurately for
468:    future runs. Default PETSc uses a value of 5.0

470:    This is ignored for most solver packages

472:    This parameter has NOTHING to do with the levels-of-fill of ILU(). That is set with `PCFactorSetLevels()` or -pc_factor_levels.

474: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCFactorSetReuseFill()`
475: @*/
476: PetscErrorCode PCFactorSetFill(PC pc, PetscReal fill)
477: {
480:   PetscTryMethod(pc, "PCFactorSetFill_C", (PC, PetscReal), (pc, fill));
481:   return 0;
482: }

484: /*@
485:    PCFactorSetUseInPlace - Tells the system to do an in-place factorization.
486:    For dense matrices, this enables the solution of much larger problems.
487:    For sparse matrices the factorization cannot be done truly in-place
488:    so this does not save memory during the factorization, but after the matrix
489:    is factored, the original unfactored matrix is freed, thus recovering that
490:    space. For ICC(0) and ILU(0) with the default natural ordering the factorization is done efficiently in-place.

492:    Logically Collective

494:    Input Parameters:
495: +  pc - the preconditioner context
496: -  flg - `PETSC_TRUE` to enable, `PETSC_FALSE` to disable

498:    Options Database Key:
499: .  -pc_factor_in_place <true,false>- Activate/deactivate in-place factorization

501:    Note:
502:    `PCFactorSetUseInplace()` can only be used with the `KSP` method `KSPPREONLY` or when
503:    a different matrix is provided for the multiply and the preconditioner in
504:    a call to `KSPSetOperators()`.
505:    This is because the Krylov space methods require an application of the
506:    matrix multiplication, which is not possible here because the matrix has
507:    been factored in-place, replacing the original matrix.

509:    Level: intermediate

511: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCFactorGetUseInPlace()`
512: @*/
513: PetscErrorCode PCFactorSetUseInPlace(PC pc, PetscBool flg)
514: {
516:   PetscTryMethod(pc, "PCFactorSetUseInPlace_C", (PC, PetscBool), (pc, flg));
517:   return 0;
518: }

520: /*@
521:    PCFactorGetUseInPlace - Determines if an in-place factorization is being used.

523:    Logically Collective

525:    Input Parameter:
526: .  pc - the preconditioner context

528:    Output Parameter:
529: .  flg - `PETSC_TRUE` to enable, `PETSC_FALSE` to disable

531:    Level: intermediate

533: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCFactorSetUseInPlace()`
534: @*/
535: PetscErrorCode PCFactorGetUseInPlace(PC pc, PetscBool *flg)
536: {
538:   PetscUseMethod(pc, "PCFactorGetUseInPlace_C", (PC, PetscBool *), (pc, flg));
539:   return 0;
540: }

542: /*@C
543:     PCFactorSetMatOrderingType - Sets the ordering routine (to reduce fill) to
544:     be used in the `PCLU`, `PCCHOLESKY`, `PCILU`,  or `PCICC` preconditioners

546:     Logically Collective

548:     Input Parameters:
549: +   pc - the preconditioner context
550: -   ordering - the matrix ordering name, for example, `MATORDERINGND` or `MATORDERINGRCM`

552:     Options Database Key:
553: .   -pc_factor_mat_ordering_type <nd,rcm,...,external> - Sets ordering routine

555:     Level: intermediate

557:     Notes:
558:       Nested dissection is used by default for some of PETSc's sparse matrix formats

560:      For `PCCHOLESKY` and `PCICC` and the `MATSBAIJ` format the only reordering available is natural since only the upper half of the matrix is stored
561:      and reordering this matrix is very expensive.

563:     You can use a `MATSEQAIJ` matrix with Cholesky and ICC and use any ordering.

565:     `MATORDERINGEXTERNAL` means PETSc will not compute an ordering and the package will use its own ordering, usable with `MATSOLVERCHOLMOD`, `MATSOLVERUMFPACK`, and others.

567: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `MatOrderingType`, `MATORDERINGEXTERNAL`, `MATORDERINGND`, `MATORDERINGRCM`
568: @*/
569: PetscErrorCode PCFactorSetMatOrderingType(PC pc, MatOrderingType ordering)
570: {
572:   PetscTryMethod(pc, "PCFactorSetMatOrderingType_C", (PC, MatOrderingType), (pc, ordering));
573:   return 0;
574: }

576: /*@
577:     PCFactorSetColumnPivot - Determines when column pivoting is done during matrix factorization.
578:       For PETSc dense matrices column pivoting is always done, for PETSc sparse matrices
579:       it is never done. For the MATLAB and `MATSOLVERSUPERLU` factorization this is used.

581:     Logically Collective

583:     Input Parameters:
584: +   pc - the preconditioner context
585: -   dtcol - 0.0 implies no pivoting, 1.0 complete pivoting (slower, requires more memory but more stable)

587:     Options Database Key:
588: .   -pc_factor_pivoting <dtcol> - perform the pivoting with the given tolerance

590:     Level: intermediate

592: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCILUSetMatOrdering()`, `PCFactorSetPivotInBlocks()`
593: @*/
594: PetscErrorCode PCFactorSetColumnPivot(PC pc, PetscReal dtcol)
595: {
598:   PetscTryMethod(pc, "PCFactorSetColumnPivot_C", (PC, PetscReal), (pc, dtcol));
599:   return 0;
600: }

602: /*@
603:     PCFactorSetPivotInBlocks - Determines if pivoting is done while factoring each block
604:       with `MATBAIJ` or `MATSBAIJ` matrices

606:     Logically Collective

608:     Input Parameters:
609: +   pc - the preconditioner context
610: -   pivot - `PETSC_TRUE` or `PETSC_FALSE`

612:     Options Database Key:
613: .   -pc_factor_pivot_in_blocks <true,false> - Pivot inside matrix dense blocks for `MATBAIJ` and `MATSBAIJ`

615:     Level: intermediate

617: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCILUSetMatOrdering()`, `PCFactorSetColumnPivot()`
618: @*/
619: PetscErrorCode PCFactorSetPivotInBlocks(PC pc, PetscBool pivot)
620: {
623:   PetscTryMethod(pc, "PCFactorSetPivotInBlocks_C", (PC, PetscBool), (pc, pivot));
624:   return 0;
625: }

627: /*@
628:    PCFactorSetReuseFill - When matrices with different nonzero structure are factored,
629:    this causes later ones to use the fill ratio computed in the initial factorization.

631:    Logically Collective

633:    Input Parameters:
634: +  pc - the preconditioner context
635: -  flag - `PETSC_TRUE` to reuse else `PETSC_FALSE`

637:    Options Database Key:
638: .  -pc_factor_reuse_fill - Activates `PCFactorSetReuseFill()`

640:    Level: intermediate

642: .seealso: `PCLU`, `PCCHOLESKY`, `PCILU`, `PCICC`, `PCFactorSetReuseOrdering()`, `PCFactorSetFill()`
643: @*/
644: PetscErrorCode PCFactorSetReuseFill(PC pc, PetscBool flag)
645: {
648:   PetscTryMethod(pc, "PCFactorSetReuseFill_C", (PC, PetscBool), (pc, flag));
649:   return 0;
650: }

652: PetscErrorCode PCFactorInitialize(PC pc, MatFactorType ftype)
653: {
654:   PC_Factor *fact = (PC_Factor *)pc->data;

656:   MatFactorInfoInitialize(&fact->info);
657:   fact->factortype           = ftype;
658:   fact->info.shifttype       = (PetscReal)MAT_SHIFT_NONE;
659:   fact->info.shiftamount     = 100.0 * PETSC_MACHINE_EPSILON;
660:   fact->info.zeropivot       = 100.0 * PETSC_MACHINE_EPSILON;
661:   fact->info.pivotinblocks   = 1.0;
662:   pc->ops->getfactoredmatrix = PCFactorGetMatrix_Factor;

664:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetZeroPivot_C", PCFactorSetZeroPivot_Factor);
665:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetZeroPivot_C", PCFactorGetZeroPivot_Factor);
666:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", PCFactorSetShiftType_Factor);
667:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftType_C", PCFactorGetShiftType_Factor);
668:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftAmount_C", PCFactorSetShiftAmount_Factor);
669:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftAmount_C", PCFactorGetShiftAmount_Factor);
670:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", PCFactorGetMatSolverType_Factor);
671:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatSolverType_C", PCFactorSetMatSolverType_Factor);
672:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUpMatSolverType_C", PCFactorSetUpMatSolverType_Factor);
673:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetFill_C", PCFactorSetFill_Factor);
674:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatOrderingType_C", PCFactorSetMatOrderingType_Factor);
675:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetLevels_C", PCFactorSetLevels_Factor);
676:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetLevels_C", PCFactorGetLevels_Factor);
677:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetAllowDiagonalFill_C", PCFactorSetAllowDiagonalFill_Factor);
678:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetAllowDiagonalFill_C", PCFactorGetAllowDiagonalFill_Factor);
679:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetPivotInBlocks_C", PCFactorSetPivotInBlocks_Factor);
680:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUseInPlace_C", PCFactorSetUseInPlace_Factor);
681:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetUseInPlace_C", PCFactorGetUseInPlace_Factor);
682:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseOrdering_C", PCFactorSetReuseOrdering_Factor);
683:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseFill_C", PCFactorSetReuseFill_Factor);
684:   return 0;
685: }

687: PetscErrorCode PCFactorClearComposedFunctions(PC pc)
688: {
689:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetZeroPivot_C", NULL);
690:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetZeroPivot_C", NULL);
691:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftType_C", NULL);
692:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftType_C", NULL);
693:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetShiftAmount_C", NULL);
694:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetShiftAmount_C", NULL);
695:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetMatSolverType_C", NULL);
696:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatSolverType_C", NULL);
697:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUpMatSolverType_C", NULL);
698:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetFill_C", NULL);
699:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetMatOrderingType_C", NULL);
700:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetLevels_C", NULL);
701:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetLevels_C", NULL);
702:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetAllowDiagonalFill_C", NULL);
703:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetAllowDiagonalFill_C", NULL);
704:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetPivotInBlocks_C", NULL);
705:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetUseInPlace_C", NULL);
706:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorGetUseInPlace_C", NULL);
707:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseOrdering_C", NULL);
708:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetReuseFill_C", NULL);
709:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorReorderForNonzeroDiagonal_C", NULL);
710:   PetscObjectComposeFunction((PetscObject)pc, "PCFactorSetDropTolerance_C", NULL);
711:   return 0;
712: }