xref: /petsc/src/ksp/pc/impls/factor/factimpl.c (revision dbbe0bcd3f3a8fbab5a45420dc06f8387e5764c6)
185317021SBarry Smith 
2c6db04a5SJed Brown #include <../src/ksp/pc/impls/factor/factor.h>     /*I "petscpc.h"  I*/
385317021SBarry Smith 
485317021SBarry Smith /* ------------------------------------------------------------------------------------------*/
585317021SBarry Smith 
63ca39a21SBarry Smith PetscErrorCode PCFactorSetUpMatSolverType_Factor(PC pc)
7f8260c8fSBarry Smith {
8f8260c8fSBarry Smith   PC_Factor      *icc = (PC_Factor*)pc->data;
9f8260c8fSBarry Smith 
10f8260c8fSBarry Smith   PetscFunctionBegin;
1128b400f6SJacob Faibussowitsch   PetscCheck(pc->pmat,PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"You can only call this routine after the matrix object has been provided to the solver, for example with KSPSetOperators() or SNESSetJacobian()");
12f8260c8fSBarry Smith   if (!pc->setupcalled && !((PC_Factor*)icc)->fact) {
139566063dSJacob Faibussowitsch     PetscCall(MatGetFactor(pc->pmat,((PC_Factor*)icc)->solvertype,((PC_Factor*)icc)->factortype,&((PC_Factor*)icc)->fact));
14f8260c8fSBarry Smith   }
15f8260c8fSBarry Smith   PetscFunctionReturn(0);
16f8260c8fSBarry Smith }
17f8260c8fSBarry Smith 
187087cfbeSBarry Smith PetscErrorCode  PCFactorSetZeroPivot_Factor(PC pc,PetscReal z)
1985317021SBarry Smith {
2085317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
2185317021SBarry Smith 
2285317021SBarry Smith   PetscFunctionBegin;
2385317021SBarry Smith   ilu->info.zeropivot = z;
2485317021SBarry Smith   PetscFunctionReturn(0);
2585317021SBarry Smith }
2685317021SBarry Smith 
277087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftType_Factor(PC pc,MatFactorShiftType shifttype)
28d90ac83dSHong Zhang {
29d90ac83dSHong Zhang   PC_Factor *dir = (PC_Factor*)pc->data;
30d90ac83dSHong Zhang 
31d90ac83dSHong Zhang   PetscFunctionBegin;
322fa5cd67SKarl Rupp   if (shifttype == (MatFactorShiftType)PETSC_DECIDE) dir->info.shifttype = (PetscReal) MAT_SHIFT_NONE;
332fa5cd67SKarl Rupp   else {
34f4db908eSBarry Smith     dir->info.shifttype = (PetscReal) shifttype;
359dbfc187SHong Zhang     if ((shifttype == MAT_SHIFT_NONZERO || shifttype ==  MAT_SHIFT_INBLOCKS) && dir->info.shiftamount == 0.0) {
369dbfc187SHong Zhang       dir->info.shiftamount = 100.0*PETSC_MACHINE_EPSILON; /* set default amount if user has not called PCFactorSetShiftAmount() yet */
376cc3b3c1SHong Zhang     }
38d90ac83dSHong Zhang   }
39d90ac83dSHong Zhang   PetscFunctionReturn(0);
40d90ac83dSHong Zhang }
41d90ac83dSHong Zhang 
427087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftAmount_Factor(PC pc,PetscReal shiftamount)
43d90ac83dSHong Zhang {
44d90ac83dSHong Zhang   PC_Factor *dir = (PC_Factor*)pc->data;
45d90ac83dSHong Zhang 
46d90ac83dSHong Zhang   PetscFunctionBegin;
472fa5cd67SKarl Rupp   if (shiftamount == (PetscReal) PETSC_DECIDE) dir->info.shiftamount = 100.0*PETSC_MACHINE_EPSILON;
482fa5cd67SKarl Rupp   else dir->info.shiftamount = shiftamount;
49d90ac83dSHong Zhang   PetscFunctionReturn(0);
50d90ac83dSHong Zhang }
51d90ac83dSHong Zhang 
527087cfbeSBarry Smith PetscErrorCode  PCFactorSetDropTolerance_Factor(PC pc,PetscReal dt,PetscReal dtcol,PetscInt dtcount)
5385317021SBarry Smith {
5485317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
5585317021SBarry Smith 
5685317021SBarry Smith   PetscFunctionBegin;
5785317021SBarry Smith   if (pc->setupcalled && (!ilu->info.usedt || ((PC_Factor*)ilu)->info.dt != dt || ((PC_Factor*)ilu)->info.dtcol != dtcol || ((PC_Factor*)ilu)->info.dtcount != dtcount)) {
58ce94432eSBarry Smith     SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change tolerance after use");
5985317021SBarry Smith   }
6085317021SBarry Smith   ilu->info.usedt   = PETSC_TRUE;
6185317021SBarry Smith   ilu->info.dt      = dt;
6285317021SBarry Smith   ilu->info.dtcol   = dtcol;
6385317021SBarry Smith   ilu->info.dtcount = dtcount;
6485317021SBarry Smith   ilu->info.fill    = PETSC_DEFAULT;
6585317021SBarry Smith   PetscFunctionReturn(0);
6685317021SBarry Smith }
6785317021SBarry Smith 
687087cfbeSBarry Smith PetscErrorCode  PCFactorSetFill_Factor(PC pc,PetscReal fill)
6985317021SBarry Smith {
7085317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
7185317021SBarry Smith 
7285317021SBarry Smith   PetscFunctionBegin;
7385317021SBarry Smith   dir->info.fill = fill;
7485317021SBarry Smith   PetscFunctionReturn(0);
7585317021SBarry Smith }
7685317021SBarry Smith 
7719fd82e9SBarry Smith PetscErrorCode  PCFactorSetMatOrderingType_Factor(PC pc,MatOrderingType ordering)
7885317021SBarry Smith {
7985317021SBarry Smith   PC_Factor      *dir = (PC_Factor*)pc->data;
80ace3abfcSBarry Smith   PetscBool      flg;
8185317021SBarry Smith 
8285317021SBarry Smith   PetscFunctionBegin;
8385317021SBarry Smith   if (!pc->setupcalled) {
849566063dSJacob Faibussowitsch     PetscCall(PetscFree(dir->ordering));
859566063dSJacob Faibussowitsch     PetscCall(PetscStrallocpy(ordering,(char**)&dir->ordering));
8685317021SBarry Smith   } else {
879566063dSJacob Faibussowitsch     PetscCall(PetscStrcmp(dir->ordering,ordering,&flg));
8828b400f6SJacob Faibussowitsch     PetscCheck(flg,PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change ordering after use");
8985317021SBarry Smith   }
9085317021SBarry Smith   PetscFunctionReturn(0);
9185317021SBarry Smith }
9285317021SBarry Smith 
932591b318SToby Isaac PetscErrorCode  PCFactorGetLevels_Factor(PC pc,PetscInt *levels)
942591b318SToby Isaac {
952591b318SToby Isaac   PC_Factor      *ilu = (PC_Factor*)pc->data;
962591b318SToby Isaac 
972591b318SToby Isaac   PetscFunctionBegin;
982591b318SToby Isaac   *levels = ilu->info.levels;
992591b318SToby Isaac   PetscFunctionReturn(0);
1002591b318SToby Isaac }
1012591b318SToby Isaac 
102c7f610a1SBarry Smith PetscErrorCode  PCFactorGetZeroPivot_Factor(PC pc,PetscReal *pivot)
103c7f610a1SBarry Smith {
104c7f610a1SBarry Smith   PC_Factor      *ilu = (PC_Factor*)pc->data;
105c7f610a1SBarry Smith 
106c7f610a1SBarry Smith   PetscFunctionBegin;
107c7f610a1SBarry Smith   *pivot = ilu->info.zeropivot;
108c7f610a1SBarry Smith   PetscFunctionReturn(0);
109c7f610a1SBarry Smith }
110c7f610a1SBarry Smith 
111c7f610a1SBarry Smith PetscErrorCode  PCFactorGetShiftAmount_Factor(PC pc,PetscReal *shift)
112c7f610a1SBarry Smith {
113c7f610a1SBarry Smith   PC_Factor      *ilu = (PC_Factor*)pc->data;
114c7f610a1SBarry Smith 
115c7f610a1SBarry Smith   PetscFunctionBegin;
116c7f610a1SBarry Smith   *shift = ilu->info.shiftamount;
117c7f610a1SBarry Smith   PetscFunctionReturn(0);
118c7f610a1SBarry Smith }
119c7f610a1SBarry Smith 
120c7f610a1SBarry Smith PetscErrorCode  PCFactorGetShiftType_Factor(PC pc,MatFactorShiftType *type)
121c7f610a1SBarry Smith {
122c7f610a1SBarry Smith   PC_Factor      *ilu = (PC_Factor*)pc->data;
123c7f610a1SBarry Smith 
124c7f610a1SBarry Smith   PetscFunctionBegin;
125b729e602SBarry Smith   *type = (MatFactorShiftType) (int) ilu->info.shifttype;
126c7f610a1SBarry Smith   PetscFunctionReturn(0);
127c7f610a1SBarry Smith }
128c7f610a1SBarry Smith 
1297087cfbeSBarry Smith PetscErrorCode  PCFactorSetLevels_Factor(PC pc,PetscInt levels)
13085317021SBarry Smith {
13185317021SBarry Smith   PC_Factor      *ilu = (PC_Factor*)pc->data;
13285317021SBarry Smith 
13385317021SBarry Smith   PetscFunctionBegin;
1342fa5cd67SKarl Rupp   if (!pc->setupcalled) ilu->info.levels = levels;
1352fa5cd67SKarl Rupp   else if (ilu->info.levels != levels) {
136*dbbe0bcdSBarry Smith     PetscUseTypeMethod(pc,reset); /* remove previous factored matrices */
1375b9c68c7SBarry Smith     pc->setupcalled  = 0; /* force a complete rebuild of preconditioner factored matrices */
1385b9c68c7SBarry Smith     ilu->info.levels = levels;
1392472a847SBarry Smith   } else PetscCheck(!ilu->info.usedt,PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change levels after use with ILUdt");
14085317021SBarry Smith   PetscFunctionReturn(0);
14185317021SBarry Smith }
14285317021SBarry Smith 
14392e9c092SBarry Smith PetscErrorCode  PCFactorSetAllowDiagonalFill_Factor(PC pc,PetscBool flg)
14485317021SBarry Smith {
14585317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
14685317021SBarry Smith 
14785317021SBarry Smith   PetscFunctionBegin;
14892e9c092SBarry Smith   dir->info.diagonal_fill = (PetscReal) flg;
14992e9c092SBarry Smith   PetscFunctionReturn(0);
15092e9c092SBarry Smith }
15192e9c092SBarry Smith 
15292e9c092SBarry Smith PetscErrorCode  PCFactorGetAllowDiagonalFill_Factor(PC pc,PetscBool *flg)
15392e9c092SBarry Smith {
15492e9c092SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
15592e9c092SBarry Smith 
15692e9c092SBarry Smith   PetscFunctionBegin;
15792e9c092SBarry Smith   *flg = dir->info.diagonal_fill ? PETSC_TRUE : PETSC_FALSE;
15885317021SBarry Smith   PetscFunctionReturn(0);
15985317021SBarry Smith }
16085317021SBarry Smith 
16185317021SBarry Smith /* ------------------------------------------------------------------------------------------*/
16285317021SBarry Smith 
1637087cfbeSBarry Smith PetscErrorCode  PCFactorSetPivotInBlocks_Factor(PC pc,PetscBool pivot)
16485317021SBarry Smith {
16585317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
16685317021SBarry Smith 
16785317021SBarry Smith   PetscFunctionBegin;
16885317021SBarry Smith   dir->info.pivotinblocks = pivot ? 1.0 : 0.0;
16985317021SBarry Smith   PetscFunctionReturn(0);
17085317021SBarry Smith }
17185317021SBarry Smith 
1727087cfbeSBarry Smith PetscErrorCode  PCFactorGetMatrix_Factor(PC pc,Mat *mat)
17385317021SBarry Smith {
17485317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
17585317021SBarry Smith 
17685317021SBarry Smith   PetscFunctionBegin;
17728b400f6SJacob Faibussowitsch   PetscCheck(ilu->fact,PetscObjectComm((PetscObject)pc),PETSC_ERR_ORDER,"Matrix not yet factored; call after KSPSetUp() or PCSetUp()");
17885317021SBarry Smith   *mat = ilu->fact;
17985317021SBarry Smith   PetscFunctionReturn(0);
18085317021SBarry Smith }
18185317021SBarry Smith 
182978beb7fSPierre Jolivet /* allow access to preallocation information */
183978beb7fSPierre Jolivet #include <petsc/private/matimpl.h>
184978beb7fSPierre Jolivet 
185ea799195SBarry Smith PetscErrorCode  PCFactorSetMatSolverType_Factor(PC pc,MatSolverType stype)
18685317021SBarry Smith {
18785317021SBarry Smith   PC_Factor      *lu = (PC_Factor*)pc->data;
18885317021SBarry Smith 
18985317021SBarry Smith   PetscFunctionBegin;
190978beb7fSPierre Jolivet   if (lu->fact && lu->fact->assembled) {
191ea799195SBarry Smith     MatSolverType ltype;
192ace3abfcSBarry Smith     PetscBool     flg;
1939566063dSJacob Faibussowitsch     PetscCall(MatFactorGetSolverType(lu->fact,&ltype));
1949566063dSJacob Faibussowitsch     PetscCall(PetscStrcmp(stype,ltype,&flg));
19528b400f6SJacob Faibussowitsch     PetscCheck(flg,PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change solver matrix package from %s to %s after PC has been setup or used",ltype,stype);
19600c67f3bSHong Zhang   }
19700c67f3bSHong Zhang 
1989566063dSJacob Faibussowitsch   PetscCall(PetscFree(lu->solvertype));
1999566063dSJacob Faibussowitsch   PetscCall(PetscStrallocpy(stype,&lu->solvertype));
20085317021SBarry Smith   PetscFunctionReturn(0);
20185317021SBarry Smith }
20285317021SBarry Smith 
203ea799195SBarry Smith PetscErrorCode  PCFactorGetMatSolverType_Factor(PC pc,MatSolverType *stype)
2047112b564SBarry Smith {
2057112b564SBarry Smith   PC_Factor *lu = (PC_Factor*)pc->data;
2067112b564SBarry Smith 
2077112b564SBarry Smith   PetscFunctionBegin;
2087112b564SBarry Smith   *stype = lu->solvertype;
2097112b564SBarry Smith   PetscFunctionReturn(0);
2107112b564SBarry Smith }
2117112b564SBarry Smith 
2127087cfbeSBarry Smith PetscErrorCode  PCFactorSetColumnPivot_Factor(PC pc,PetscReal dtcol)
21385317021SBarry Smith {
21485317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
21585317021SBarry Smith 
21685317021SBarry Smith   PetscFunctionBegin;
2172472a847SBarry Smith   PetscCheck(dtcol >= 0.0 && dtcol <= 1.0,PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_OUTOFRANGE,"Column pivot tolerance is %g must be between 0 and 1",(double)dtcol);
21885317021SBarry Smith   dir->info.dtcol = dtcol;
21985317021SBarry Smith   PetscFunctionReturn(0);
22085317021SBarry Smith }
2218ff23777SHong Zhang 
222*dbbe0bcdSBarry Smith PetscErrorCode  PCSetFromOptions_Factor(PC pc,PetscOptionItems *PetscOptionsObject)
2238ff23777SHong Zhang {
2248ff23777SHong Zhang   PC_Factor         *factor = (PC_Factor*)pc->data;
2258afaa268SBarry Smith   PetscBool         flg,set;
2268ff23777SHong Zhang   char              tname[256], solvertype[64];
227140e18c1SBarry Smith   PetscFunctionList ordlist;
228018dd85eSSatish Balay   PetscEnum         etmp;
2298e37d05fSBarry Smith   PetscBool         inplace;
2308ff23777SHong Zhang 
2318ff23777SHong Zhang   PetscFunctionBegin;
2329566063dSJacob Faibussowitsch   PetscCall(PCFactorGetUseInPlace(pc,&inplace));
2339566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-pc_factor_in_place","Form factored matrix in the same memory as the matrix","PCFactorSetUseInPlace",inplace,&flg,&set));
2341baa6e33SBarry Smith   if (set) PetscCall(PCFactorSetUseInPlace(pc,flg));
2359566063dSJacob Faibussowitsch   PetscCall(PetscOptionsReal("-pc_factor_fill","Expected non-zeros in factored matrix","PCFactorSetFill",((PC_Factor*)factor)->info.fill,&((PC_Factor*)factor)->info.fill,NULL));
2368ff23777SHong Zhang 
2379566063dSJacob Faibussowitsch   PetscCall(PetscOptionsEnum("-pc_factor_shift_type","Type of shift to add to diagonal","PCFactorSetShiftType",MatFactorShiftTypes,(PetscEnum)(int)((PC_Factor*)factor)->info.shifttype,&etmp,&flg));
2381baa6e33SBarry Smith   if (flg) PetscCall(PCFactorSetShiftType(pc,(MatFactorShiftType)etmp));
2399566063dSJacob Faibussowitsch   PetscCall(PetscOptionsReal("-pc_factor_shift_amount","Shift added to diagonal","PCFactorSetShiftAmount",((PC_Factor*)factor)->info.shiftamount,&((PC_Factor*)factor)->info.shiftamount,NULL));
240d90ac83dSHong Zhang 
2419566063dSJacob Faibussowitsch   PetscCall(PetscOptionsReal("-pc_factor_zeropivot","Pivot is considered zero if less than","PCFactorSetZeroPivot",((PC_Factor*)factor)->info.zeropivot,&((PC_Factor*)factor)->info.zeropivot,NULL));
2429566063dSJacob Faibussowitsch   PetscCall(PetscOptionsReal("-pc_factor_column_pivot","Column pivot tolerance (used only for some factorization)","PCFactorSetColumnPivot",((PC_Factor*)factor)->info.dtcol,&((PC_Factor*)factor)->info.dtcol,&flg));
2438ff23777SHong Zhang 
2449566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-pc_factor_pivot_in_blocks","Pivot inside matrix dense blocks for BAIJ and SBAIJ","PCFactorSetPivotInBlocks",((PC_Factor*)factor)->info.pivotinblocks ? PETSC_TRUE : PETSC_FALSE,&flg,&set));
2451baa6e33SBarry Smith   if (set) PetscCall(PCFactorSetPivotInBlocks(pc,flg));
2468ff23777SHong Zhang 
2479566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-pc_factor_reuse_fill","Use fill from previous factorization","PCFactorSetReuseFill",PETSC_FALSE,&flg,&set));
2481baa6e33SBarry Smith   if (set) PetscCall(PCFactorSetReuseFill(pc,flg));
2499566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-pc_factor_reuse_ordering","Reuse ordering from previous factorization","PCFactorSetReuseOrdering",PETSC_FALSE,&flg,&set));
2501baa6e33SBarry Smith   if (set) PetscCall(PCFactorSetReuseOrdering(pc,flg));
2518ff23777SHong Zhang 
2529566063dSJacob Faibussowitsch   PetscCall(PetscOptionsDeprecated("-pc_factor_mat_solver_package","-pc_factor_mat_solver_type","3.9",NULL));
2539566063dSJacob Faibussowitsch   PetscCall(PetscOptionsString("-pc_factor_mat_solver_type","Specific direct solver to use","MatGetFactor",((PC_Factor*)factor)->solvertype,solvertype,sizeof(solvertype),&flg));
2541baa6e33SBarry Smith   if (flg) PetscCall(PCFactorSetMatSolverType(pc,solvertype));
2559566063dSJacob Faibussowitsch   PetscCall(PCFactorSetDefaultOrdering_Factor(pc));
2569566063dSJacob Faibussowitsch   PetscCall(MatGetOrderingList(&ordlist));
2579566063dSJacob Faibussowitsch   PetscCall(PetscOptionsFList("-pc_factor_mat_ordering_type","Reordering to reduce nonzeros in factored matrix","PCFactorSetMatOrderingType",ordlist,((PC_Factor*)factor)->ordering,tname,sizeof(tname),&flg));
2581baa6e33SBarry Smith   if (flg) PetscCall(PCFactorSetMatOrderingType(pc,tname));
2598ff23777SHong Zhang   PetscFunctionReturn(0);
2608ff23777SHong Zhang }
261914a5d51SHong Zhang 
262914a5d51SHong Zhang PetscErrorCode PCView_Factor(PC pc,PetscViewer viewer)
263914a5d51SHong Zhang {
264914a5d51SHong Zhang   PC_Factor       *factor = (PC_Factor*)pc->data;
2654ac6704cSBarry Smith   PetscBool       isstring,iascii,canuseordering;
2664ac6704cSBarry Smith   MatInfo         info;
2679bd791bbSBarry Smith   MatOrderingType ordering;
268914a5d51SHong Zhang 
269914a5d51SHong Zhang   PetscFunctionBegin;
2709566063dSJacob Faibussowitsch   PetscCall(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERSTRING,&isstring));
2719566063dSJacob Faibussowitsch   PetscCall(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii));
272914a5d51SHong Zhang   if (iascii) {
2733d1c1ea0SBarry Smith     if (factor->inplace) {
2749566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIPrintf(viewer,"  in-place factorization\n"));
2753d1c1ea0SBarry Smith     } else {
2769566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIPrintf(viewer,"  out-of-place factorization\n"));
2773d1c1ea0SBarry Smith     }
2783d1c1ea0SBarry Smith 
2799566063dSJacob Faibussowitsch     if (factor->reusefill)     PetscCall(PetscViewerASCIIPrintf(viewer,"  Reusing fill from past factorization\n"));
2809566063dSJacob Faibussowitsch     if (factor->reuseordering) PetscCall(PetscViewerASCIIPrintf(viewer,"  Reusing reordering from past factorization\n"));
281879e8a4dSBarry Smith     if (factor->factortype == MAT_FACTOR_ILU || factor->factortype == MAT_FACTOR_ICC) {
282914a5d51SHong Zhang       if (factor->info.dt > 0) {
2839566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  drop tolerance %g\n",(double)factor->info.dt));
28463a3b9bcSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  max nonzeros per row %" PetscInt_FMT "\n",(PetscInt)factor->info.dtcount));
2859566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  column permutation tolerance %g\n",(double)factor->info.dtcol));
286914a5d51SHong Zhang       } else if (factor->info.levels == 1) {
28763a3b9bcSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  %" PetscInt_FMT " level of fill\n",(PetscInt)factor->info.levels));
288914a5d51SHong Zhang       } else {
28963a3b9bcSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  %" PetscInt_FMT " levels of fill\n",(PetscInt)factor->info.levels));
290914a5d51SHong Zhang       }
291914a5d51SHong Zhang     }
292914a5d51SHong Zhang 
2939566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPrintf(viewer,"  tolerance for zero pivot %g\n",(double)factor->info.zeropivot));
2945e9742b9SJed Brown     if (MatFactorShiftTypesDetail[(int)factor->info.shifttype]) { /* Only print when using a nontrivial shift */
2959566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIPrintf(viewer,"  using %s [%s]\n",MatFactorShiftTypesDetail[(int)factor->info.shifttype],MatFactorShiftTypes[(int)factor->info.shifttype]));
296914a5d51SHong Zhang     }
297914a5d51SHong Zhang 
2984ac6704cSBarry Smith     if (factor->fact) {
2999566063dSJacob Faibussowitsch       PetscCall(MatFactorGetCanUseOrdering(factor->fact,&canuseordering));
3004ac6704cSBarry Smith       if (!canuseordering) ordering = MATORDERINGEXTERNAL;
3014ac6704cSBarry Smith       else ordering = factor->ordering;
3029566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIPrintf(viewer,"  matrix ordering: %s\n",ordering));
303978beb7fSPierre Jolivet       if (!factor->fact->assembled) {
3049566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  matrix solver type: %s\n",factor->fact->solvertype));
3059566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  matrix not yet factored; no additional information available\n"));
306978beb7fSPierre Jolivet       } else {
3079566063dSJacob Faibussowitsch         PetscCall(MatGetInfo(factor->fact,MAT_LOCAL,&info));
3089566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"  factor fill ratio given %g, needed %g\n",(double)info.fill_ratio_given,(double)info.fill_ratio_needed));
3099566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPrintf(viewer,"    Factored matrix follows:\n"));
3109566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPushTab(viewer));
3119566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPushTab(viewer));
3129566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPushTab(viewer));
3139566063dSJacob Faibussowitsch         PetscCall(PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO));
3149566063dSJacob Faibussowitsch         PetscCall(MatView(factor->fact,viewer));
3159566063dSJacob Faibussowitsch         PetscCall(PetscViewerPopFormat(viewer));
3169566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPopTab(viewer));
3179566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPopTab(viewer));
3189566063dSJacob Faibussowitsch         PetscCall(PetscViewerASCIIPopTab(viewer));
319914a5d51SHong Zhang       }
320978beb7fSPierre Jolivet     }
321914a5d51SHong Zhang 
322914a5d51SHong Zhang   } else if (isstring) {
3236335c336SBarry Smith     MatFactorType t;
3249566063dSJacob Faibussowitsch     PetscCall(MatGetFactorType(factor->fact,&t));
3256335c336SBarry Smith     if (t == MAT_FACTOR_ILU || t == MAT_FACTOR_ICC) {
32663a3b9bcSJacob Faibussowitsch       PetscCall(PetscViewerStringSPrintf(viewer," lvls=%" PetscInt_FMT ",order=%s",(PetscInt)factor->info.levels,factor->ordering));
327914a5d51SHong Zhang     }
328914a5d51SHong Zhang   }
329914a5d51SHong Zhang   PetscFunctionReturn(0);
330914a5d51SHong Zhang }
331