#include <../src/ksp/pc/impls/factor/icc/icc.h> /*I "petscpc.h" I*/ #undef __FUNCT__ #define __FUNCT__ "PCSetUp_ICC" static PetscErrorCode PCSetUp_ICC(PC pc) { PC_ICC *icc = (PC_ICC*)pc->data; IS perm,cperm; PetscErrorCode ierr; MatInfo info; const MatSolverPackage stype; MatFactorError err; PetscFunctionBegin; pc->failedreason = PC_NOERROR; ierr = MatGetOrdering(pc->pmat, ((PC_Factor*)icc)->ordering,&perm,&cperm);CHKERRQ(ierr); ierr = MatSetErrorIfFailure(pc->pmat,pc->erroriffailure);CHKERRQ(ierr); if (!pc->setupcalled) { if (!((PC_Factor*)icc)->fact) { ierr = MatGetFactor(pc->pmat,((PC_Factor*)icc)->solvertype,MAT_FACTOR_ICC,&((PC_Factor*)icc)->fact);CHKERRQ(ierr); } ierr = MatICCFactorSymbolic(((PC_Factor*)icc)->fact,pc->pmat,perm,&((PC_Factor*)icc)->info);CHKERRQ(ierr); } else if (pc->flag != SAME_NONZERO_PATTERN) { ierr = MatDestroy(&((PC_Factor*)icc)->fact);CHKERRQ(ierr); ierr = MatGetFactor(pc->pmat,((PC_Factor*)icc)->solvertype,MAT_FACTOR_ICC,&((PC_Factor*)icc)->fact);CHKERRQ(ierr); ierr = MatICCFactorSymbolic(((PC_Factor*)icc)->fact,pc->pmat,perm,&((PC_Factor*)icc)->info);CHKERRQ(ierr); } ierr = MatGetInfo(((PC_Factor*)icc)->fact,MAT_LOCAL,&info);CHKERRQ(ierr); icc->hdr.actualfill = info.fill_ratio_needed; ierr = ISDestroy(&cperm);CHKERRQ(ierr); ierr = ISDestroy(&perm);CHKERRQ(ierr); ierr = MatFactorGetError(((PC_Factor*)icc)->fact,&err);CHKERRQ(ierr); if (err) { /* FactorSymbolic() fails */ pc->failedreason = (PCFailedReason)err; PetscFunctionReturn(0); } ierr = MatCholeskyFactorNumeric(((PC_Factor*)icc)->fact,pc->pmat,&((PC_Factor*)icc)->info);CHKERRQ(ierr); ierr = MatFactorGetError(((PC_Factor*)icc)->fact,&err);CHKERRQ(ierr); if (err) { /* FactorNumeric() fails */ pc->failedreason = (PCFailedReason)err; } ierr = PCFactorGetMatSolverPackage(pc,&stype);CHKERRQ(ierr); if (!stype) { const MatSolverPackage solverpackage; ierr = MatFactorGetSolverPackage(((PC_Factor*)icc)->fact,&solverpackage);CHKERRQ(ierr); ierr = PCFactorSetMatSolverPackage(pc,solverpackage);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCReset_ICC" static PetscErrorCode PCReset_ICC(PC pc) { PC_ICC *icc = (PC_ICC*)pc->data; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatDestroy(&((PC_Factor*)icc)->fact);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCDestroy_ICC" static PetscErrorCode PCDestroy_ICC(PC pc) { PC_ICC *icc = (PC_ICC*)pc->data; PetscErrorCode ierr; PetscFunctionBegin; ierr = PCReset_ICC(pc);CHKERRQ(ierr); ierr = PetscFree(((PC_Factor*)icc)->ordering);CHKERRQ(ierr); ierr = PetscFree(((PC_Factor*)icc)->solvertype);CHKERRQ(ierr); ierr = PetscFree(pc->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApply_ICC" static PetscErrorCode PCApply_ICC(PC pc,Vec x,Vec y) { PC_ICC *icc = (PC_ICC*)pc->data; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatSolve(((PC_Factor*)icc)->fact,x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApplySymmetricLeft_ICC" static PetscErrorCode PCApplySymmetricLeft_ICC(PC pc,Vec x,Vec y) { PetscErrorCode ierr; PC_ICC *icc = (PC_ICC*)pc->data; PetscFunctionBegin; ierr = MatForwardSolve(((PC_Factor*)icc)->fact,x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApplySymmetricRight_ICC" static PetscErrorCode PCApplySymmetricRight_ICC(PC pc,Vec x,Vec y) { PetscErrorCode ierr; PC_ICC *icc = (PC_ICC*)pc->data; PetscFunctionBegin; ierr = MatBackwardSolve(((PC_Factor*)icc)->fact,x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCSetFromOptions_ICC" static PetscErrorCode PCSetFromOptions_ICC(PetscOptionItems *PetscOptionsObject,PC pc) { PC_ICC *icc = (PC_ICC*)pc->data; PetscBool flg; PetscErrorCode ierr; /* PetscReal dt[3];*/ PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"ICC Options");CHKERRQ(ierr); ierr = PCSetFromOptions_Factor(PetscOptionsObject,pc);CHKERRQ(ierr); ierr = PetscOptionsReal("-pc_factor_levels","levels of fill","PCFactorSetLevels",((PC_Factor*)icc)->info.levels,&((PC_Factor*)icc)->info.levels,&flg);CHKERRQ(ierr); /*dt[0] = ((PC_Factor*)icc)->info.dt; dt[1] = ((PC_Factor*)icc)->info.dtcol; dt[2] = ((PC_Factor*)icc)->info.dtcount; PetscInt dtmax = 3; ierr = PetscOptionsRealArray("-pc_factor_drop_tolerance","