xref: /petsc/src/ksp/pc/impls/factor/factimpl.c (revision 00c67f3b09c0bcda06af5ed306d845d9138e5003)
185317021SBarry Smith 
2c6db04a5SJed Brown #include <../src/ksp/pc/impls/factor/factor.h>     /*I "petscpc.h"  I*/
385317021SBarry Smith 
485317021SBarry Smith /* ------------------------------------------------------------------------------------------*/
585317021SBarry Smith 
6f8260c8fSBarry Smith 
7f8260c8fSBarry Smith #undef __FUNCT__
8f8260c8fSBarry Smith #define __FUNCT__ "PCFactorSetUpMatSolverPackage_Factor"
9f8260c8fSBarry Smith PetscErrorCode PCFactorSetUpMatSolverPackage_Factor(PC pc)
10f8260c8fSBarry Smith {
11f8260c8fSBarry Smith   PC_Factor      *icc = (PC_Factor*)pc->data;
12f8260c8fSBarry Smith   PetscErrorCode ierr;
13f8260c8fSBarry Smith 
14f8260c8fSBarry Smith   PetscFunctionBegin;
15ad5697c6SBarry Smith   if (!pc->pmat) SETERRQ(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()");
16f8260c8fSBarry Smith   if (!pc->setupcalled && !((PC_Factor*)icc)->fact) {
17f8260c8fSBarry Smith     ierr = MatGetFactor(pc->pmat,((PC_Factor*)icc)->solvertype,((PC_Factor*)icc)->factortype,&((PC_Factor*)icc)->fact);CHKERRQ(ierr);
18f8260c8fSBarry Smith   }
19f8260c8fSBarry Smith   PetscFunctionReturn(0);
20f8260c8fSBarry Smith }
21f8260c8fSBarry Smith 
2285317021SBarry Smith #undef __FUNCT__
2385317021SBarry Smith #define __FUNCT__ "PCFactorSetZeroPivot_Factor"
247087cfbeSBarry Smith PetscErrorCode  PCFactorSetZeroPivot_Factor(PC pc,PetscReal z)
2585317021SBarry Smith {
2685317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
2785317021SBarry Smith 
2885317021SBarry Smith   PetscFunctionBegin;
2985317021SBarry Smith   ilu->info.zeropivot = z;
3085317021SBarry Smith   PetscFunctionReturn(0);
3185317021SBarry Smith }
3285317021SBarry Smith 
3385317021SBarry Smith #undef __FUNCT__
34d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftType_Factor"
357087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftType_Factor(PC pc,MatFactorShiftType shifttype)
36d90ac83dSHong Zhang {
37d90ac83dSHong Zhang   PC_Factor *dir = (PC_Factor*)pc->data;
38d90ac83dSHong Zhang 
39d90ac83dSHong Zhang   PetscFunctionBegin;
402fa5cd67SKarl Rupp   if (shifttype == (MatFactorShiftType)PETSC_DECIDE) dir->info.shifttype = (PetscReal) MAT_SHIFT_NONE;
412fa5cd67SKarl Rupp   else {
42f4db908eSBarry Smith     dir->info.shifttype = (PetscReal) shifttype;
439dbfc187SHong Zhang     if ((shifttype == MAT_SHIFT_NONZERO || shifttype ==  MAT_SHIFT_INBLOCKS) && dir->info.shiftamount == 0.0) {
449dbfc187SHong Zhang       dir->info.shiftamount = 100.0*PETSC_MACHINE_EPSILON; /* set default amount if user has not called PCFactorSetShiftAmount() yet */
456cc3b3c1SHong Zhang     }
46d90ac83dSHong Zhang   }
47d90ac83dSHong Zhang   PetscFunctionReturn(0);
48d90ac83dSHong Zhang }
49d90ac83dSHong Zhang 
50d90ac83dSHong Zhang #undef __FUNCT__
51d90ac83dSHong Zhang #define __FUNCT__ "PCFactorSetShiftAmount_Factor"
527087cfbeSBarry Smith PetscErrorCode  PCFactorSetShiftAmount_Factor(PC pc,PetscReal shiftamount)
53d90ac83dSHong Zhang {
54d90ac83dSHong Zhang   PC_Factor *dir = (PC_Factor*)pc->data;
55d90ac83dSHong Zhang 
56d90ac83dSHong Zhang   PetscFunctionBegin;
572fa5cd67SKarl Rupp   if (shiftamount == (PetscReal) PETSC_DECIDE) dir->info.shiftamount = 100.0*PETSC_MACHINE_EPSILON;
582fa5cd67SKarl Rupp   else dir->info.shiftamount = shiftamount;
59d90ac83dSHong Zhang   PetscFunctionReturn(0);
60d90ac83dSHong Zhang }
61d90ac83dSHong Zhang 
62d90ac83dSHong Zhang #undef __FUNCT__
63b7c853c4SBarry Smith #define __FUNCT__ "PCFactorSetDropTolerance_Factor"
647087cfbeSBarry Smith PetscErrorCode  PCFactorSetDropTolerance_Factor(PC pc,PetscReal dt,PetscReal dtcol,PetscInt dtcount)
6585317021SBarry Smith {
6685317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
6785317021SBarry Smith 
6885317021SBarry Smith   PetscFunctionBegin;
6985317021SBarry 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)) {
70ce94432eSBarry Smith     SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change tolerance after use");
7185317021SBarry Smith   }
7285317021SBarry Smith   ilu->info.usedt   = PETSC_TRUE;
7385317021SBarry Smith   ilu->info.dt      = dt;
7485317021SBarry Smith   ilu->info.dtcol   = dtcol;
7585317021SBarry Smith   ilu->info.dtcount = dtcount;
7685317021SBarry Smith   ilu->info.fill    = PETSC_DEFAULT;
7785317021SBarry Smith   PetscFunctionReturn(0);
7885317021SBarry Smith }
7985317021SBarry Smith 
8085317021SBarry Smith #undef __FUNCT__
8185317021SBarry Smith #define __FUNCT__ "PCFactorSetFill_Factor"
827087cfbeSBarry Smith PetscErrorCode  PCFactorSetFill_Factor(PC pc,PetscReal fill)
8385317021SBarry Smith {
8485317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
8585317021SBarry Smith 
8685317021SBarry Smith   PetscFunctionBegin;
8785317021SBarry Smith   dir->info.fill = fill;
8885317021SBarry Smith   PetscFunctionReturn(0);
8985317021SBarry Smith }
9085317021SBarry Smith 
9185317021SBarry Smith #undef __FUNCT__
9285317021SBarry Smith #define __FUNCT__ "PCFactorSetMatOrderingType_Factor"
9319fd82e9SBarry Smith PetscErrorCode  PCFactorSetMatOrderingType_Factor(PC pc,MatOrderingType ordering)
9485317021SBarry Smith {
9585317021SBarry Smith   PC_Factor      *dir = (PC_Factor*)pc->data;
9685317021SBarry Smith   PetscErrorCode ierr;
97ace3abfcSBarry Smith   PetscBool      flg;
9885317021SBarry Smith 
9985317021SBarry Smith   PetscFunctionBegin;
10085317021SBarry Smith   if (!pc->setupcalled) {
101503cfb0cSBarry Smith     ierr = PetscFree(dir->ordering);CHKERRQ(ierr);
10219fd82e9SBarry Smith     ierr = PetscStrallocpy(ordering,(char**)&dir->ordering);CHKERRQ(ierr);
10385317021SBarry Smith   } else {
10485317021SBarry Smith     ierr = PetscStrcmp(dir->ordering,ordering,&flg);CHKERRQ(ierr);
105ce94432eSBarry Smith     if (!flg) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change ordering after use");
10685317021SBarry Smith   }
10785317021SBarry Smith   PetscFunctionReturn(0);
10885317021SBarry Smith }
10985317021SBarry Smith 
11085317021SBarry Smith #undef __FUNCT__
1112591b318SToby Isaac #define __FUNCT__ "PCFactorGetLevels_Factor"
1122591b318SToby Isaac PetscErrorCode  PCFactorGetLevels_Factor(PC pc,PetscInt *levels)
1132591b318SToby Isaac {
1142591b318SToby Isaac   PC_Factor      *ilu = (PC_Factor*)pc->data;
1152591b318SToby Isaac 
1162591b318SToby Isaac   PetscFunctionBegin;
1172591b318SToby Isaac   *levels = ilu->info.levels;
1182591b318SToby Isaac   PetscFunctionReturn(0);
1192591b318SToby Isaac }
1202591b318SToby Isaac 
1212591b318SToby Isaac #undef __FUNCT__
12285317021SBarry Smith #define __FUNCT__ "PCFactorSetLevels_Factor"
1237087cfbeSBarry Smith PetscErrorCode  PCFactorSetLevels_Factor(PC pc,PetscInt levels)
12485317021SBarry Smith {
12585317021SBarry Smith   PC_Factor      *ilu = (PC_Factor*)pc->data;
1265b9c68c7SBarry Smith   PetscErrorCode ierr;
12785317021SBarry Smith 
12885317021SBarry Smith   PetscFunctionBegin;
1292fa5cd67SKarl Rupp   if (!pc->setupcalled) ilu->info.levels = levels;
1302fa5cd67SKarl Rupp   else if (ilu->info.levels != levels) {
1315b9c68c7SBarry Smith     ierr             = (*pc->ops->reset)(pc);CHKERRQ(ierr); /* remove previous factored matrices */
1325b9c68c7SBarry Smith     pc->setupcalled  = 0; /* force a complete rebuild of preconditioner factored matrices */
1335b9c68c7SBarry Smith     ilu->info.levels = levels;
134ce94432eSBarry Smith   } else if (ilu->info.usedt) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change levels after use with ILUdt");
13585317021SBarry Smith   PetscFunctionReturn(0);
13685317021SBarry Smith }
13785317021SBarry Smith 
13885317021SBarry Smith #undef __FUNCT__
13985317021SBarry Smith #define __FUNCT__ "PCFactorSetAllowDiagonalFill_Factor"
14092e9c092SBarry Smith PetscErrorCode  PCFactorSetAllowDiagonalFill_Factor(PC pc,PetscBool flg)
14185317021SBarry Smith {
14285317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
14385317021SBarry Smith 
14485317021SBarry Smith   PetscFunctionBegin;
14592e9c092SBarry Smith   dir->info.diagonal_fill = (PetscReal) flg;
14692e9c092SBarry Smith   PetscFunctionReturn(0);
14792e9c092SBarry Smith }
14892e9c092SBarry Smith 
14992e9c092SBarry Smith #undef __FUNCT__
15092e9c092SBarry Smith #define __FUNCT__ "PCFactorGetAllowDiagonalFill_Factor"
15192e9c092SBarry Smith PetscErrorCode  PCFactorGetAllowDiagonalFill_Factor(PC pc,PetscBool *flg)
15292e9c092SBarry Smith {
15392e9c092SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
15492e9c092SBarry Smith 
15592e9c092SBarry Smith   PetscFunctionBegin;
15692e9c092SBarry Smith   *flg = dir->info.diagonal_fill ? PETSC_TRUE : PETSC_FALSE;
15785317021SBarry Smith   PetscFunctionReturn(0);
15885317021SBarry Smith }
15985317021SBarry Smith 
16085317021SBarry Smith /* ------------------------------------------------------------------------------------------*/
16185317021SBarry Smith 
16285317021SBarry Smith #undef __FUNCT__
16385317021SBarry Smith #define __FUNCT__ "PCFactorSetPivotInBlocks_Factor"
1647087cfbeSBarry Smith PetscErrorCode  PCFactorSetPivotInBlocks_Factor(PC pc,PetscBool pivot)
16585317021SBarry Smith {
16685317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
16785317021SBarry Smith 
16885317021SBarry Smith   PetscFunctionBegin;
16985317021SBarry Smith   dir->info.pivotinblocks = pivot ? 1.0 : 0.0;
17085317021SBarry Smith   PetscFunctionReturn(0);
17185317021SBarry Smith }
17285317021SBarry Smith 
17385317021SBarry Smith #undef __FUNCT__
17485317021SBarry Smith #define __FUNCT__ "PCFactorGetMatrix_Factor"
1757087cfbeSBarry Smith PetscErrorCode  PCFactorGetMatrix_Factor(PC pc,Mat *mat)
17685317021SBarry Smith {
17785317021SBarry Smith   PC_Factor *ilu = (PC_Factor*)pc->data;
17885317021SBarry Smith 
17985317021SBarry Smith   PetscFunctionBegin;
180ce94432eSBarry Smith   if (!ilu->fact) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ORDER,"Matrix not yet factored; call after KSPSetUp() or PCSetUp()");
18185317021SBarry Smith   *mat = ilu->fact;
18285317021SBarry Smith   PetscFunctionReturn(0);
18385317021SBarry Smith }
18485317021SBarry Smith 
18585317021SBarry Smith #undef __FUNCT__
18685317021SBarry Smith #define __FUNCT__ "PCFactorSetMatSolverPackage_Factor"
1877087cfbeSBarry Smith PetscErrorCode  PCFactorSetMatSolverPackage_Factor(PC pc,const MatSolverPackage stype)
18885317021SBarry Smith {
18985317021SBarry Smith   PetscErrorCode ierr;
19085317021SBarry Smith   PC_Factor      *lu = (PC_Factor*)pc->data;
19185317021SBarry Smith 
19285317021SBarry Smith   PetscFunctionBegin;
1937112b564SBarry Smith   if (lu->fact) {
19485317021SBarry Smith     const MatSolverPackage ltype;
195ace3abfcSBarry Smith     PetscBool              flg;
19685317021SBarry Smith     ierr = MatFactorGetSolverPackage(lu->fact,&ltype);CHKERRQ(ierr);
19785317021SBarry Smith     ierr = PetscStrcmp(stype,ltype,&flg);CHKERRQ(ierr);
198ce94432eSBarry Smith     if (!flg) SETERRQ(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_WRONGSTATE,"Cannot change solver matrix package after PC has been setup or used");
199*00c67f3bSHong Zhang   }
200*00c67f3bSHong Zhang 
201503cfb0cSBarry Smith   ierr = PetscFree(lu->solvertype);CHKERRQ(ierr);
20285317021SBarry Smith   ierr = PetscStrallocpy(stype,&lu->solvertype);CHKERRQ(ierr);
20385317021SBarry Smith   PetscFunctionReturn(0);
20485317021SBarry Smith }
20585317021SBarry Smith 
20685317021SBarry Smith #undef __FUNCT__
2077112b564SBarry Smith #define __FUNCT__ "PCFactorGetMatSolverPackage_Factor"
2087087cfbeSBarry Smith PetscErrorCode  PCFactorGetMatSolverPackage_Factor(PC pc,const MatSolverPackage *stype)
2097112b564SBarry Smith {
2107112b564SBarry Smith   PC_Factor *lu = (PC_Factor*)pc->data;
2117112b564SBarry Smith 
2127112b564SBarry Smith   PetscFunctionBegin;
2137112b564SBarry Smith   *stype = lu->solvertype;
2147112b564SBarry Smith   PetscFunctionReturn(0);
2157112b564SBarry Smith }
2167112b564SBarry Smith 
2177112b564SBarry Smith #undef __FUNCT__
2188ff23777SHong Zhang #define __FUNCT__ "PCFactorSetColumnPivot_Factor"
2197087cfbeSBarry Smith PetscErrorCode  PCFactorSetColumnPivot_Factor(PC pc,PetscReal dtcol)
22085317021SBarry Smith {
22185317021SBarry Smith   PC_Factor *dir = (PC_Factor*)pc->data;
22285317021SBarry Smith 
22385317021SBarry Smith   PetscFunctionBegin;
22457622a8eSBarry Smith   if (dtcol < 0.0 || dtcol > 1.0) SETERRQ1(PetscObjectComm((PetscObject)pc),PETSC_ERR_ARG_OUTOFRANGE,"Column pivot tolerance is %g must be between 0 and 1",(double)dtcol);
22585317021SBarry Smith   dir->info.dtcol = dtcol;
22685317021SBarry Smith   PetscFunctionReturn(0);
22785317021SBarry Smith }
2288ff23777SHong Zhang 
2298ff23777SHong Zhang #undef __FUNCT__
2308ff23777SHong Zhang #define __FUNCT__ "PCSetFromOptions_Factor"
2314416b707SBarry Smith PetscErrorCode  PCSetFromOptions_Factor(PetscOptionItems *PetscOptionsObject,PC pc)
2328ff23777SHong Zhang {
2338ff23777SHong Zhang   PC_Factor         *factor = (PC_Factor*)pc->data;
2348ff23777SHong Zhang   PetscErrorCode    ierr;
2358afaa268SBarry Smith   PetscBool         flg,set;
2368ff23777SHong Zhang   char              tname[256], solvertype[64];
237140e18c1SBarry Smith   PetscFunctionList ordlist;
238018dd85eSSatish Balay   PetscEnum         etmp;
2398e37d05fSBarry Smith   PetscBool         inplace;
2408ff23777SHong Zhang 
2418ff23777SHong Zhang   PetscFunctionBegin;
2428e37d05fSBarry Smith   ierr = PCFactorGetUseInPlace(pc,&inplace);CHKERRQ(ierr);
24392e9c092SBarry Smith   ierr = PetscOptionsBool("-pc_factor_in_place","Form factored matrix in the same memory as the matrix","PCFactorSetUseInPlace",inplace,&flg,&set);CHKERRQ(ierr);
2448e37d05fSBarry Smith   if (set) {
2458e37d05fSBarry Smith     ierr = PCFactorSetUseInPlace(pc,flg);CHKERRQ(ierr);
2468ff23777SHong Zhang   }
2478afaa268SBarry Smith   ierr = PetscOptionsReal("-pc_factor_fill","Expected non-zeros in factored matrix","PCFactorSetFill",((PC_Factor*)factor)->info.fill,&((PC_Factor*)factor)->info.fill,NULL);CHKERRQ(ierr);
2488ff23777SHong Zhang 
2498afaa268SBarry Smith   ierr = PetscOptionsEnum("-pc_factor_shift_type","Type of shift to add to diagonal","PCFactorSetShiftType",MatFactorShiftTypes,(PetscEnum)(int)((PC_Factor*)factor)->info.shifttype,&etmp,&flg);CHKERRQ(ierr);
250018dd85eSSatish Balay   if (flg) {
2516cc3b3c1SHong Zhang     ierr = PCFactorSetShiftType(pc,(MatFactorShiftType)etmp);CHKERRQ(ierr);
252018dd85eSSatish Balay   }
253d90ac83dSHong Zhang   ierr = PetscOptionsReal("-pc_factor_shift_amount","Shift added to diagonal","PCFactorSetShiftAmount",((PC_Factor*)factor)->info.shiftamount,&((PC_Factor*)factor)->info.shiftamount,0);CHKERRQ(ierr);
254d90ac83dSHong Zhang 
2558ff23777SHong Zhang   ierr = PetscOptionsReal("-pc_factor_zeropivot","Pivot is considered zero if less than","PCFactorSetZeroPivot",((PC_Factor*)factor)->info.zeropivot,&((PC_Factor*)factor)->info.zeropivot,0);CHKERRQ(ierr);
2568ff23777SHong Zhang   ierr = 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);CHKERRQ(ierr);
2578ff23777SHong Zhang 
2588afaa268SBarry Smith   ierr = 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);CHKERRQ(ierr);
2598ff23777SHong Zhang   if (set) {
2608ff23777SHong Zhang     ierr = PCFactorSetPivotInBlocks(pc,flg);CHKERRQ(ierr);
2618ff23777SHong Zhang   }
2628ff23777SHong Zhang 
2638afaa268SBarry Smith   ierr = PetscOptionsBool("-pc_factor_reuse_fill","Use fill from previous factorization","PCFactorSetReuseFill",PETSC_FALSE,&flg,&set);CHKERRQ(ierr);
2648afaa268SBarry Smith   if (set) {
2658afaa268SBarry Smith     ierr = PCFactorSetReuseFill(pc,flg);CHKERRQ(ierr);
2668ff23777SHong Zhang   }
2678afaa268SBarry Smith   ierr = PetscOptionsBool("-pc_factor_reuse_ordering","Reuse ordering from previous factorization","PCFactorSetReuseOrdering",PETSC_FALSE,&flg,&set);CHKERRQ(ierr);
2688afaa268SBarry Smith   if (set) {
2698afaa268SBarry Smith     ierr = PCFactorSetReuseOrdering(pc,flg);CHKERRQ(ierr);
2708ff23777SHong Zhang   }
2718ff23777SHong Zhang 
2728ff23777SHong Zhang   ierr = MatGetOrderingList(&ordlist);CHKERRQ(ierr);
273a264d7a6SBarry Smith   ierr = PetscOptionsFList("-pc_factor_mat_ordering_type","Reordering to reduce nonzeros in factored matrix","PCFactorSetMatOrderingType",ordlist,((PC_Factor*)factor)->ordering,tname,256,&flg);CHKERRQ(ierr);
2748ff23777SHong Zhang   if (flg) {
2758ff23777SHong Zhang     ierr = PCFactorSetMatOrderingType(pc,tname);CHKERRQ(ierr);
2768ff23777SHong Zhang   }
2778ff23777SHong Zhang 
2788ff23777SHong Zhang   /* maybe should have MatGetSolverTypes(Mat,&list) like the ordering list */
2798ff23777SHong Zhang   ierr = PetscOptionsString("-pc_factor_mat_solver_package","Specific direct solver to use","MatGetFactor",((PC_Factor*)factor)->solvertype,solvertype,64,&flg);CHKERRQ(ierr);
2808ff23777SHong Zhang   if (flg) {
2818ff23777SHong Zhang     ierr = PCFactorSetMatSolverPackage(pc,solvertype);CHKERRQ(ierr);
2828ff23777SHong Zhang   }
2838ff23777SHong Zhang   PetscFunctionReturn(0);
2848ff23777SHong Zhang }
285914a5d51SHong Zhang 
286914a5d51SHong Zhang #undef __FUNCT__
287914a5d51SHong Zhang #define __FUNCT__ "PCView_Factor"
288914a5d51SHong Zhang PetscErrorCode PCView_Factor(PC pc,PetscViewer viewer)
289914a5d51SHong Zhang {
290914a5d51SHong Zhang   PC_Factor      *factor = (PC_Factor*)pc->data;
291914a5d51SHong Zhang   PetscErrorCode ierr;
292ace3abfcSBarry Smith   PetscBool      isstring,iascii;
293914a5d51SHong Zhang 
294914a5d51SHong Zhang   PetscFunctionBegin;
295251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERSTRING,&isstring);CHKERRQ(ierr);
296251f4c67SDmitry Karpeev   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);
297914a5d51SHong Zhang   if (iascii) {
298879e8a4dSBarry Smith     if (factor->factortype == MAT_FACTOR_ILU || factor->factortype == MAT_FACTOR_ICC) {
299914a5d51SHong Zhang       if (factor->info.dt > 0) {
30057622a8eSBarry Smith         ierr = PetscViewerASCIIPrintf(viewer,"  drop tolerance %g\n",(double)factor->info.dt);CHKERRQ(ierr);
301914a5d51SHong Zhang         ierr = PetscViewerASCIIPrintf(viewer,"  max nonzeros per row %D\n",factor->info.dtcount);CHKERRQ(ierr);
30257622a8eSBarry Smith         ierr = PetscViewerASCIIPrintf(viewer,"  column permutation tolerance %g\n",(double)factor->info.dtcol);CHKERRQ(ierr);
303914a5d51SHong Zhang       } else if (factor->info.levels == 1) {
304914a5d51SHong Zhang         ierr = PetscViewerASCIIPrintf(viewer,"  %D level of fill\n",(PetscInt)factor->info.levels);CHKERRQ(ierr);
305914a5d51SHong Zhang       } else {
306914a5d51SHong Zhang         ierr = PetscViewerASCIIPrintf(viewer,"  %D levels of fill\n",(PetscInt)factor->info.levels);CHKERRQ(ierr);
307914a5d51SHong Zhang       }
308914a5d51SHong Zhang     }
309914a5d51SHong Zhang 
31057622a8eSBarry Smith     ierr = PetscViewerASCIIPrintf(viewer,"  tolerance for zero pivot %g\n",(double)factor->info.zeropivot);CHKERRQ(ierr);
3115e9742b9SJed Brown     if (MatFactorShiftTypesDetail[(int)factor->info.shifttype]) { /* Only print when using a nontrivial shift */
3125e9742b9SJed Brown       ierr = PetscViewerASCIIPrintf(viewer,"  using %s [%s]\n",MatFactorShiftTypesDetail[(int)factor->info.shifttype],MatFactorShiftTypes[(int)factor->info.shifttype]);CHKERRQ(ierr);
313914a5d51SHong Zhang     }
314914a5d51SHong Zhang 
315914a5d51SHong Zhang     ierr = PetscViewerASCIIPrintf(viewer,"  matrix ordering: %s\n",factor->ordering);CHKERRQ(ierr);
316914a5d51SHong Zhang 
317914a5d51SHong Zhang     if (factor->fact) {
3186335c336SBarry Smith       MatInfo info;
3196335c336SBarry Smith       ierr = MatGetInfo(factor->fact,MAT_LOCAL,&info);CHKERRQ(ierr);
32057622a8eSBarry Smith       ierr = PetscViewerASCIIPrintf(viewer,"  factor fill ratio given %g, needed %g\n",(double)info.fill_ratio_given,(double)info.fill_ratio_needed);CHKERRQ(ierr);
321914a5d51SHong Zhang       ierr = PetscViewerASCIIPrintf(viewer,"    Factored matrix follows:\n");CHKERRQ(ierr);
322914a5d51SHong Zhang       ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
323914a5d51SHong Zhang       ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
324914a5d51SHong Zhang       ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
325914a5d51SHong Zhang       ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr);
326914a5d51SHong Zhang       ierr = MatView(factor->fact,viewer);CHKERRQ(ierr);
327914a5d51SHong Zhang       ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr);
328914a5d51SHong Zhang       ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
329914a5d51SHong Zhang       ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
330914a5d51SHong Zhang       ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
331914a5d51SHong Zhang     }
332914a5d51SHong Zhang 
333914a5d51SHong Zhang   } else if (isstring) {
3346335c336SBarry Smith     MatFactorType t;
3356335c336SBarry Smith     ierr = MatGetFactorType(factor->fact,&t);CHKERRQ(ierr);
3366335c336SBarry Smith     if (t == MAT_FACTOR_ILU || t == MAT_FACTOR_ICC) {
337914a5d51SHong Zhang       ierr = PetscViewerStringSPrintf(viewer," lvls=%D,order=%s",(PetscInt)factor->info.levels,factor->ordering);CHKERRQ(ierr);CHKERRQ(ierr);
338914a5d51SHong Zhang     }
339914a5d51SHong Zhang   }
340914a5d51SHong Zhang   PetscFunctionReturn(0);
341914a5d51SHong Zhang }
342