Actual source code: ilu.c
1: #define PETSCKSP_DLL
3: /*
4: Defines a ILU factorization preconditioner for any Mat implementation
5: */
6: #include private/pcimpl.h
7: #include src/ksp/pc/impls/factor/ilu/ilu.h
8: #include include/private/matimpl.h
10: /* ------------------------------------------------------------------------------------------*/
14: PetscErrorCode PCFactorSetReuseFill_ILU(PC pc,PetscTruth flag)
15: {
16: PC_ILU *lu;
17:
19: lu = (PC_ILU*)pc->data;
20: lu->reusefill = flag;
21: return(0);
22: }
28: PetscErrorCode PCFactorSetZeroPivot_ILU(PC pc,PetscReal z)
29: {
30: PC_ILU *ilu;
33: ilu = (PC_ILU*)pc->data;
34: ilu->info.zeropivot = z;
35: return(0);
36: }
42: PetscErrorCode PCFactorSetShiftNonzero_ILU(PC pc,PetscReal shift)
43: {
44: PC_ILU *dir;
47: dir = (PC_ILU*)pc->data;
48: if (shift == (PetscReal) PETSC_DECIDE) {
49: dir->info.shiftnz = 1.e-12;
50: } else {
51: dir->info.shiftnz = shift;
52: }
53: return(0);
54: }
60: PetscErrorCode PCFactorSetShiftPd_ILU(PC pc,PetscTruth shift)
61: {
62: PC_ILU *dir;
63:
65: dir = (PC_ILU*)pc->data;
66: if (shift) {
67: dir->info.shift_fraction = 0.0;
68: dir->info.shiftpd = 1.0;
69: } else {
70: dir->info.shiftpd = 0.0;
71: }
72: return(0);
73: }
79: PetscErrorCode PCFactorReorderForNonzeroDiagonal_ILU(PC pc,PetscReal z)
80: {
81: PC_ILU *ilu = (PC_ILU*)pc->data;
84: ilu->nonzerosalongdiagonal = PETSC_TRUE;
85: if (z == PETSC_DECIDE) {
86: ilu->nonzerosalongdiagonaltol = 1.e-10;
87: } else {
88: ilu->nonzerosalongdiagonaltol = z;
89: }
90: return(0);
91: }
96: PetscErrorCode PCDestroy_ILU_Internal(PC pc)
97: {
98: PC_ILU *ilu = (PC_ILU*)pc->data;
102: if (!ilu->inplace && ilu->fact) {MatDestroy(ilu->fact);}
103: if (ilu->row && ilu->col && ilu->row != ilu->col) {ISDestroy(ilu->row);}
104: if (ilu->col) {ISDestroy(ilu->col);}
105: return(0);
106: }
111: PetscErrorCode PCFactorSetUseDropTolerance_ILU(PC pc,PetscReal dt,PetscReal dtcol,PetscInt dtcount)
112: {
113: PC_ILU *ilu;
117: ilu = (PC_ILU*)pc->data;
118: if (pc->setupcalled && (!ilu->usedt || ilu->info.dt != dt || ilu->info.dtcol != dtcol || ilu->info.dtcount != dtcount)) {
119: pc->setupcalled = 0;
120: PCDestroy_ILU_Internal(pc);
121: }
122: ilu->usedt = PETSC_TRUE;
123: ilu->info.dt = dt;
124: ilu->info.dtcol = dtcol;
125: ilu->info.dtcount = dtcount;
126: ilu->info.fill = PETSC_DEFAULT;
127: return(0);
128: }
134: PetscErrorCode PCFactorSetFill_ILU(PC pc,PetscReal fill)
135: {
136: PC_ILU *dir;
139: dir = (PC_ILU*)pc->data;
140: dir->info.fill = fill;
141: return(0);
142: }
148: PetscErrorCode PCFactorSetMatOrderingType_ILU(PC pc,MatOrderingType ordering)
149: {
150: PC_ILU *dir = (PC_ILU*)pc->data;
152: PetscTruth flg;
153:
155: if (!pc->setupcalled) {
156: PetscStrfree(dir->ordering);
157: PetscStrallocpy(ordering,&dir->ordering);
158: } else {
159: PetscStrcmp(dir->ordering,ordering,&flg);
160: if (!flg) {
161: pc->setupcalled = 0;
162: PetscStrfree(dir->ordering);
163: PetscStrallocpy(ordering,&dir->ordering);
164: /* free the data structures, then create them again */
165: PCDestroy_ILU_Internal(pc);
166: }
167: }
168: return(0);
169: }
175: PetscErrorCode PCFactorSetReuseOrdering_ILU(PC pc,PetscTruth flag)
176: {
177: PC_ILU *ilu;
180: ilu = (PC_ILU*)pc->data;
181: ilu->reuseordering = flag;
182: return(0);
183: }
189: PetscErrorCode PCFactorSetLevels_ILU(PC pc,PetscInt levels)
190: {
191: PC_ILU *ilu;
195: ilu = (PC_ILU*)pc->data;
197: if (!pc->setupcalled) {
198: ilu->info.levels = levels;
199: } else if (ilu->usedt || ilu->info.levels != levels) {
200: ilu->info.levels = levels;
201: pc->setupcalled = 0;
202: ilu->usedt = PETSC_FALSE;
203: PCDestroy_ILU_Internal(pc);
204: }
205: return(0);
206: }
212: PetscErrorCode PCFactorSetUseInPlace_ILU(PC pc)
213: {
214: PC_ILU *dir;
217: dir = (PC_ILU*)pc->data;
218: dir->inplace = PETSC_TRUE;
219: return(0);
220: }
226: PetscErrorCode PCFactorSetAllowDiagonalFill_ILU(PC pc)
227: {
228: PC_ILU *dir;
231: dir = (PC_ILU*)pc->data;
232: dir->info.diagonal_fill = 1;
233: return(0);
234: }
239: /*@
240: PCFactorSetUseDropTolerance - The preconditioner will use an ILU
241: based on a drop tolerance.
243: Collective on PC
245: Input Parameters:
246: + pc - the preconditioner context
247: . dt - the drop tolerance, try from 1.e-10 to .1
248: . dtcol - tolerance for column pivot, good values [0.1 to 0.01]
249: - maxrowcount - the max number of nonzeros allowed in a row, best value
250: depends on the number of nonzeros in row of original matrix
252: Options Database Key:
253: . -pc_factor_use_drop_tolerance <dt,dtcol,maxrowcount> - Sets drop tolerance
255: Level: intermediate
257: Notes:
258: This uses the iludt() code of Saad's SPARSKIT package
260: There are NO default values for the 3 parameters, you must set them with reasonable values for your
261: matrix. We don't know how to compute reasonable values.
263: .keywords: PC, levels, reordering, factorization, incomplete, ILU
264: @*/
265: PetscErrorCode PCFactorSetUseDropTolerance(PC pc,PetscReal dt,PetscReal dtcol,PetscInt maxrowcount)
266: {
267: PetscErrorCode ierr,(*f)(PC,PetscReal,PetscReal,PetscInt);
271: PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetUseDropTolerance_C",(void (**)(void))&f);
272: if (f) {
273: (*f)(pc,dt,dtcol,maxrowcount);
274: }
275: return(0);
276: }
280: /*@
281: PCFactorSetLevels - Sets the number of levels of fill to use.
283: Collective on PC
285: Input Parameters:
286: + pc - the preconditioner context
287: - levels - number of levels of fill
289: Options Database Key:
290: . -pc_factor_levels <levels> - Sets fill level
292: Level: intermediate
294: .keywords: PC, levels, fill, factorization, incomplete, ILU
295: @*/
296: PetscErrorCode PCFactorSetLevels(PC pc,PetscInt levels)
297: {
298: PetscErrorCode ierr,(*f)(PC,PetscInt);
302: if (levels < 0) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"negative levels");
303: PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetLevels_C",(void (**)(void))&f);
304: if (f) {
305: (*f)(pc,levels);
306: }
307: return(0);
308: }
312: /*@
313: PCFactorSetAllowDiagonalFill - Causes all diagonal matrix entries to be
314: treated as level 0 fill even if there is no non-zero location.
316: Collective on PC
318: Input Parameters:
319: + pc - the preconditioner context
321: Options Database Key:
322: . -pc_factor_diagonal_fill
324: Notes:
325: Does not apply with 0 fill.
327: Level: intermediate
329: .keywords: PC, levels, fill, factorization, incomplete, ILU
330: @*/
331: PetscErrorCode PCFactorSetAllowDiagonalFill(PC pc)
332: {
333: PetscErrorCode ierr,(*f)(PC);
337: PetscObjectQueryFunction((PetscObject)pc,"PCFactorSetAllowDiagonalFill_C",(void (**)(void))&f);
338: if (f) {
339: (*f)(pc);
340: }
341: return(0);
342: }
344: /* ------------------------------------------------------------------------------------------*/
349: PetscErrorCode PCFactorSetPivotInBlocks_ILU(PC pc,PetscTruth pivot)
350: {
351: PC_ILU *dir = (PC_ILU*)pc->data;
354: dir->info.pivotinblocks = pivot ? 1.0 : 0.0;
355: return(0);
356: }
361: static PetscErrorCode PCSetFromOptions_ILU(PC pc)
362: {
364: PetscInt dtmax = 3,itmp;
365: PetscTruth flg,set;
366: PetscReal dt[3];
367: char tname[256];
368: PC_ILU *ilu = (PC_ILU*)pc->data;
369: PetscFList ordlist;
370: PetscReal tol;
373: MatOrderingRegisterAll(PETSC_NULL);
374: PetscOptionsHead("ILU Options");
375: PetscOptionsInt("-pc_factor_levels","levels of fill","PCFactorSetLevels",(PetscInt)ilu->info.levels,&itmp,&flg);
376: if (flg) ilu->info.levels = itmp;
377: PetscOptionsName("-pc_factor_in_place","do factorization in place","PCFactorSetUseInPlace",&flg);
378: if (flg) ilu->inplace = PETSC_TRUE;
379: PetscOptionsName("-pc_factor_diagonal_fill","Allow fill into empty diagonal entry","PCFactorSetAllowDiagonalFill",&flg);
380: ilu->info.diagonal_fill = (double) flg;
381: PetscOptionsName("-pc_factor_reuse_fill","Reuse fill ratio from previous factorization","PCFactorSetReuseFill",&flg);
382: if (flg) ilu->reusefill = PETSC_TRUE;
383: PetscOptionsName("-pc_factor_reuse_ordering","Reuse previous reordering","PCFactorSetReuseOrdering",&flg);
384: if (flg) ilu->reuseordering = PETSC_TRUE;
385: PetscOptionsName("-pc_factor_shift_nonzero","Shift added to diagonal","PCFactorSetShiftNonzero",&flg);
386: if (flg) {
387: PCFactorSetShiftNonzero(pc,(PetscReal)PETSC_DECIDE);
388: }
389: PetscOptionsReal("-pc_factor_shift_nonzero","Shift added to diagonal","PCFactorSetShiftNonzero",ilu->info.shiftnz,&ilu->info.shiftnz,0);
390:
391: PetscOptionsName("-pc_factor_shift_positive_definite","Manteuffel shift applied to diagonal","PCFactorSetShiftPd",&flg);
392: if (flg) {
393: PetscOptionsInt("-pc_factor_shift_positive_definite","Manteuffel shift applied to diagonal","PCFactorSetShiftPd",(PetscInt)ilu->info.shiftpd,&itmp,&flg);
394: if (flg && !itmp) {
395: PCFactorSetShiftPd(pc,PETSC_FALSE);
396: } else {
397: PCFactorSetShiftPd(pc,PETSC_TRUE);
398: }
399: }
400: PetscOptionsReal("-pc_factor_zeropivot","Pivot is considered zero if less than","PCFactorSetZeroPivot",ilu->info.zeropivot,&ilu->info.zeropivot,0);
402: dt[0] = ilu->info.dt;
403: dt[1] = ilu->info.dtcol;
404: dt[2] = ilu->info.dtcount;
405: PetscOptionsRealArray("-pc_factor_use_drop_tolerance","<dt,dtcol,maxrowcount>","PCFactorSetUseDropTolerance",dt,&dtmax,&flg);
406: if (flg) {
407: PCFactorSetUseDropTolerance(pc,dt[0],dt[1],(PetscInt)dt[2]);
408: }
409: PetscOptionsReal("-pc_factor_fill","Expected fill in factorization","PCFactorSetFill",ilu->info.fill,&ilu->info.fill,&flg);
410: PetscOptionsName("-pc_factor_nonzeros_along_diagonal","Reorder to remove zeros from diagonal","PCFactorReorderForNonzeroDiagonal",&flg);
411: if (flg) {
412: tol = PETSC_DECIDE;
413: PetscOptionsReal("-pc_factor_nonzeros_along_diagonal","Reorder to remove zeros from diagonal","PCFactorReorderForNonzeroDiagonal",ilu->nonzerosalongdiagonaltol,&tol,0);
414: PCFactorReorderForNonzeroDiagonal(pc,tol);
415: }
417: MatGetOrderingList(&ordlist);
418: PetscOptionsList("-pc_factor_mat_ordering_type","Reorder to reduce nonzeros in ILU","PCFactorSetMatOrderingType",ordlist,ilu->ordering,tname,256,&flg);
419: if (flg) {
420: PCFactorSetMatOrderingType(pc,tname);
421: }
422: flg = ilu->info.pivotinblocks ? PETSC_TRUE : PETSC_FALSE;
423: PetscOptionsTruth("-pc_factor_pivot_in_blocks","Pivot inside matrix blocks for BAIJ and SBAIJ","PCFactorSetPivotInBlocks",flg,&flg,&set);
424: if (set) {
425: PCFactorSetPivotInBlocks(pc,flg);
426: }
427: PetscOptionsTail();
428: return(0);
429: }
433: static PetscErrorCode PCView_ILU(PC pc,PetscViewer viewer)
434: {
435: PC_ILU *ilu = (PC_ILU*)pc->data;
437: PetscTruth isstring,iascii;
440: PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);
441: PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);
442: if (iascii) {
443: if (ilu->usedt) {
444: PetscViewerASCIIPrintf(viewer," ILU: drop tolerance %G\n",ilu->info.dt);
445: PetscViewerASCIIPrintf(viewer," ILU: max nonzeros per row %D\n",(PetscInt)ilu->info.dtcount);
446: PetscViewerASCIIPrintf(viewer," ILU: column permutation tolerance %G\n",ilu->info.dtcol);
447: } else if (ilu->info.levels == 1) {
448: PetscViewerASCIIPrintf(viewer," ILU: %D level of fill\n",(PetscInt)ilu->info.levels);
449: } else {
450: PetscViewerASCIIPrintf(viewer," ILU: %D levels of fill\n",(PetscInt)ilu->info.levels);
451: }
452: PetscViewerASCIIPrintf(viewer," ILU: factor fill ratio allocated %G\n",ilu->info.fill);
453: PetscViewerASCIIPrintf(viewer," ILU: tolerance for zero pivot %G\n",ilu->info.zeropivot);
454: if (ilu->info.shiftpd) {PetscViewerASCIIPrintf(viewer," ILU: using Manteuffel shift\n");}
455: if (ilu->inplace) {PetscViewerASCIIPrintf(viewer," in-place factorization\n");}
456: else {PetscViewerASCIIPrintf(viewer," out-of-place factorization\n");}
457: PetscViewerASCIIPrintf(viewer," matrix ordering: %s\n",ilu->ordering);
458: if (ilu->reusefill) {PetscViewerASCIIPrintf(viewer," Reusing fill from past factorization\n");}
459: if (ilu->reuseordering) {PetscViewerASCIIPrintf(viewer," Reusing reordering from past factorization\n");}
460: if (ilu->fact) {
461: PetscViewerASCIIPrintf(viewer," ILU: factor fill ratio needed %G\n",ilu->actualfill);
462: PetscViewerASCIIPrintf(viewer," Factored matrix follows\n");
463: PetscViewerASCIIPushTab(viewer);
464: PetscViewerASCIIPushTab(viewer);
465: PetscViewerASCIIPushTab(viewer);
466: PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
467: MatView(ilu->fact,viewer);
468: PetscViewerPopFormat(viewer);
469: PetscViewerASCIIPopTab(viewer);
470: PetscViewerASCIIPopTab(viewer);
471: PetscViewerASCIIPopTab(viewer);
472: }
473: } else if (isstring) {
474: PetscViewerStringSPrintf(viewer," lvls=%D,order=%s",(PetscInt)ilu->info.levels,ilu->ordering);
475: } else {
476: SETERRQ1(PETSC_ERR_SUP,"Viewer type %s not supported for PCILU",((PetscObject)viewer)->type_name);
477: }
478: return(0);
479: }
483: static PetscErrorCode PCSetUp_ILU(PC pc)
484: {
486: PC_ILU *ilu = (PC_ILU*)pc->data;
487: MatInfo info;
490: if (ilu->inplace) {
491: if (!pc->setupcalled) {
493: /* In-place factorization only makes sense with the natural ordering,
494: so we only need to get the ordering once, even if nonzero structure changes */
495: MatGetOrdering(pc->pmat,ilu->ordering,&ilu->row,&ilu->col);
496: if (ilu->row) {PetscLogObjectParent(pc,ilu->row);}
497: if (ilu->col) {PetscLogObjectParent(pc,ilu->col);}
498: }
500: /* In place ILU only makes sense with fill factor of 1.0 because
501: cannot have levels of fill */
502: ilu->info.fill = 1.0;
503: ilu->info.diagonal_fill = 0;
504: MatILUFactor(pc->pmat,ilu->row,ilu->col,&ilu->info);
505: ilu->fact = pc->pmat;
506: } else if (ilu->usedt) {
507: if (!pc->setupcalled) {
508: MatGetOrdering(pc->pmat,ilu->ordering,&ilu->row,&ilu->col);
509: if (ilu->row) {PetscLogObjectParent(pc,ilu->row);}
510: if (ilu->col) {PetscLogObjectParent(pc,ilu->col);}
511: MatILUDTFactor(pc->pmat,ilu->row,ilu->col,&ilu->info,&ilu->fact);
512: PetscLogObjectParent(pc,ilu->fact);
513: } else if (pc->flag != SAME_NONZERO_PATTERN) {
514: MatDestroy(ilu->fact);
515: if (!ilu->reuseordering) {
516: if (ilu->row) {ISDestroy(ilu->row);}
517: if (ilu->col) {ISDestroy(ilu->col);}
518: MatGetOrdering(pc->pmat,ilu->ordering,&ilu->row,&ilu->col);
519: if (ilu->row) {PetscLogObjectParent(pc,ilu->row);}
520: if (ilu->col) {PetscLogObjectParent(pc,ilu->col);}
521: }
522: MatILUDTFactor(pc->pmat,ilu->row,ilu->col,&ilu->info,&ilu->fact);
523: PetscLogObjectParent(pc,ilu->fact);
524: } else if (!ilu->reusefill) {
525: MatDestroy(ilu->fact);
526: MatILUDTFactor(pc->pmat,ilu->row,ilu->col,&ilu->info,&ilu->fact);
527: PetscLogObjectParent(pc,ilu->fact);
528: } else {
529: MatLUFactorNumeric(pc->pmat,&ilu->info,&ilu->fact);
530: }
531: } else {
532: if (!pc->setupcalled) {
533: /* first time in so compute reordering and symbolic factorization */
534: MatGetOrdering(pc->pmat,ilu->ordering,&ilu->row,&ilu->col);
535: if (ilu->row) {PetscLogObjectParent(pc,ilu->row);}
536: if (ilu->col) {PetscLogObjectParent(pc,ilu->col);}
537: /* Remove zeros along diagonal? */
538: if (ilu->nonzerosalongdiagonal) {
539: MatReorderForNonzeroDiagonal(pc->pmat,ilu->nonzerosalongdiagonaltol,ilu->row,ilu->col);
540: }
541: MatILUFactorSymbolic(pc->pmat,ilu->row,ilu->col,&ilu->info,&ilu->fact);
542: MatGetInfo(ilu->fact,MAT_LOCAL,&info);
543: ilu->actualfill = info.fill_ratio_needed;
544: PetscLogObjectParent(pc,ilu->fact);
545: } else if (pc->flag != SAME_NONZERO_PATTERN) {
546: if (!ilu->reuseordering) {
547: /* compute a new ordering for the ILU */
548: ISDestroy(ilu->row);
549: ISDestroy(ilu->col);
550: MatGetOrdering(pc->pmat,ilu->ordering,&ilu->row,&ilu->col);
551: if (ilu->row) {PetscLogObjectParent(pc,ilu->row);}
552: if (ilu->col) {PetscLogObjectParent(pc,ilu->col);}
553: /* Remove zeros along diagonal? */
554: if (ilu->nonzerosalongdiagonal) {
555: MatReorderForNonzeroDiagonal(pc->pmat,ilu->nonzerosalongdiagonaltol,ilu->row,ilu->col);
556: }
557: }
558: MatDestroy(ilu->fact);
559: MatILUFactorSymbolic(pc->pmat,ilu->row,ilu->col,&ilu->info,&ilu->fact);
560: MatGetInfo(ilu->fact,MAT_LOCAL,&info);
561: ilu->actualfill = info.fill_ratio_needed;
562: PetscLogObjectParent(pc,ilu->fact);
563: }
564: MatLUFactorNumeric(pc->pmat,&ilu->info,&ilu->fact);
565: }
566: return(0);
567: }
571: static PetscErrorCode PCDestroy_ILU(PC pc)
572: {
573: PC_ILU *ilu = (PC_ILU*)pc->data;
577: PCDestroy_ILU_Internal(pc);
578: PetscStrfree(ilu->ordering);
579: PetscFree(ilu);
580: return(0);
581: }
585: static PetscErrorCode PCApply_ILU(PC pc,Vec x,Vec y)
586: {
587: PC_ILU *ilu = (PC_ILU*)pc->data;
591: MatSolve(ilu->fact,x,y);
592: return(0);
593: }
597: static PetscErrorCode PCApplyTranspose_ILU(PC pc,Vec x,Vec y)
598: {
599: PC_ILU *ilu = (PC_ILU*)pc->data;
603: MatSolveTranspose(ilu->fact,x,y);
604: return(0);
605: }
609: static PetscErrorCode PCGetFactoredMatrix_ILU(PC pc,Mat *mat)
610: {
611: PC_ILU *ilu = (PC_ILU*)pc->data;
614: if (!ilu->fact) SETERRQ(PETSC_ERR_ORDER,"Matrix not yet factored; call after KSPSetUp() or PCSetUp()");
615: *mat = ilu->fact;
616: return(0);
617: }
619: /*MC
620: PCILU - Incomplete factorization preconditioners.
622: Options Database Keys:
623: + -pc_factor_levels <k> - number of levels of fill for ILU(k)
624: . -pc_factor_in_place - only for ILU(0) with natural ordering, reuses the space of the matrix for
625: its factorization (overwrites original matrix)
626: . -pc_factor_diagonal_fill - fill in a zero diagonal even if levels of fill indicate it wouldn't be fill
627: . -pc_factor_reuse_ordering - reuse ordering of factorized matrix from previous factorization
628: . -pc_factor_use_drop_tolerance <dt,dtcol,maxrowcount> - use Saad's drop tolerance ILUdt
629: . -pc_factor_fill <nfill> - expected amount of fill in factored matrix compared to original matrix, nfill > 1
630: . -pc_factor_nonzeros_along_diagonal - reorder the matrix before factorization to remove zeros from the diagonal,
631: this decreases the chance of getting a zero pivot
632: . -pc_factor_mat_ordering_type <natural,nd,1wd,rcm,qmd> - set the row/column ordering of the factored matrix
633: . -pc_factor_pivot_in_blocks - for block ILU(k) factorization, i.e. with BAIJ matrices with block size larger
634: than 1 the diagonal blocks are factored with partial pivoting (this increases the
635: stability of the ILU factorization
636: . -pc_factor_shift_nonzero <shift> - Sets shift amount or PETSC_DECIDE for the default
637: - -pc_factor_shift_positive_definite [PETSC_TRUE/PETSC_FALSE] - Activate/Deactivate PCFactorSetShiftPd(); the value
638: is optional with PETSC_TRUE being the default
640: Level: beginner
642: Concepts: incomplete factorization
644: Notes: Only implemented for some matrix formats. Not implemented in parallel
646: For BAIJ matrices this implements a point block ILU
648: .seealso: PCCreate(), PCSetType(), PCType (for list of available types), PC, PCSOR, MatOrderingType,
649: PCFactorSetZeroPivot(), PCFactorSetShiftNonzero(), PCFactorSetShiftPd(), PCFactorSetUseDropTolerance(),
650: PCFactorSetFill(), PCFactorSetMatOrderingType(), PCFactorSetReuseOrdering(),
651: PCFactorSetLevels(), PCFactorSetUseInPlace(), PCFactorSetAllowDiagonalFill(), PCFactorSetPivotInBlocks(),
652: PCFactorSetShiftNonzero(),PCFactorSetShiftPd()
654: M*/
659: PetscErrorCode PCCreate_ILU(PC pc)
660: {
662: PC_ILU *ilu;
665: PetscNew(PC_ILU,&ilu);
666: PetscLogObjectMemory(pc,sizeof(PC_ILU));
668: ilu->fact = 0;
669: MatFactorInfoInitialize(&ilu->info);
670: ilu->info.levels = 0;
671: ilu->info.fill = 1.0;
672: ilu->col = 0;
673: ilu->row = 0;
674: ilu->inplace = PETSC_FALSE;
675: PetscStrallocpy(MATORDERING_NATURAL,&ilu->ordering);
676: ilu->reuseordering = PETSC_FALSE;
677: ilu->usedt = PETSC_FALSE;
678: ilu->info.dt = PETSC_DEFAULT;
679: ilu->info.dtcount = PETSC_DEFAULT;
680: ilu->info.dtcol = PETSC_DEFAULT;
681: ilu->info.shiftnz = 0.0;
682: ilu->info.shiftpd = 0.0; /* false */
683: ilu->info.shift_fraction = 0.0;
684: ilu->info.zeropivot = 1.e-12;
685: ilu->info.pivotinblocks = 1.0;
686: ilu->reusefill = PETSC_FALSE;
687: ilu->info.diagonal_fill = 0;
688: pc->data = (void*)ilu;
690: pc->ops->destroy = PCDestroy_ILU;
691: pc->ops->apply = PCApply_ILU;
692: pc->ops->applytranspose = PCApplyTranspose_ILU;
693: pc->ops->setup = PCSetUp_ILU;
694: pc->ops->setfromoptions = PCSetFromOptions_ILU;
695: pc->ops->getfactoredmatrix = PCGetFactoredMatrix_ILU;
696: pc->ops->view = PCView_ILU;
697: pc->ops->applyrichardson = 0;
699: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetZeroPivot_C","PCFactorSetZeroPivot_ILU",
700: PCFactorSetZeroPivot_ILU);
701: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetShiftNonzero_C","PCFactorSetShiftNonzero_ILU",
702: PCFactorSetShiftNonzero_ILU);
703: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetShiftPd_C","PCFactorSetShiftPd_ILU",
704: PCFactorSetShiftPd_ILU);
706: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetUseDropTolerance_C","PCFactorSetUseDropTolerance_ILU",
707: PCFactorSetUseDropTolerance_ILU);
708: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetFill_C","PCFactorSetFill_ILU",
709: PCFactorSetFill_ILU);
710: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetMatOrderingType_C","PCFactorSetMatOrderingType_ILU",
711: PCFactorSetMatOrderingType_ILU);
712: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetReuseOrdering_C","PCFactorSetReuseOrdering_ILU",
713: PCFactorSetReuseOrdering_ILU);
714: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetReuseFill_C","PCFactorSetReuseFill_ILU",
715: PCFactorSetReuseFill_ILU);
716: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetLevels_C","PCFactorSetLevels_ILU",
717: PCFactorSetLevels_ILU);
718: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetUseInPlace_C","PCFactorSetUseInPlace_ILU",
719: PCFactorSetUseInPlace_ILU);
720: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetAllowDiagonalFill_C","PCFactorSetAllowDiagonalFill_ILU",
721: PCFactorSetAllowDiagonalFill_ILU);
722: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorSetPivotInBlocks_C","PCFactorSetPivotInBlocks_ILU",
723: PCFactorSetPivotInBlocks_ILU);
724: PetscObjectComposeFunctionDynamic((PetscObject)pc,"PCFactorReorderForNonzeroDiagonal_C","PCFactorReorderForNonzeroDiagonal_ILU",
725: PCFactorReorderForNonzeroDiagonal_ILU);
726: return(0);
727: }