PetscErrorCode KSPSetUp_CG(KSP ksp) { KSP_CG *cgP = (KSP_CG*)ksp->data; PetscErrorCode ierr; PetscInt maxit = ksp->max_it,nwork = 3; PetscFunctionBegin; /* get work vectors needed by CG */ if (cgP->singlereduction) nwork += 2; ierr = KSPDefaultGetWork(ksp,nwork); CHKERRQ(ierr); /* If user requested computations of eigenvalues then allocate work work space needed */ if (ksp->calc_sings) { /* get space to store tridiagonal matrix for Lanczos */ ierr = PetscMalloc4(maxit+1,PetscScalar,&cgP->e,maxit+1,PetscScalar,&cgP->d,maxit+1,PetscReal,&cgP->ee,maxit+1,PetscReal,&cgP->dd); CHKERRQ(ierr); ierr = PetscLogObjectMemory(ksp,2*(maxit+1)*(sizeof(PetscScalar)+sizeof(PetscReal))); CHKERRQ(ierr); ksp->ops->computeextremesingularvalues = KSPComputeExtremeSingularValues_CG; ksp->ops->computeeigenvalues = KSPComputeEigenvalues_CG; } PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_CG(KSP ksp) { KSP_CG *cgP = (KSP_CG*)ksp->data; PetscErrorCode ierr; PetscInt maxit = ksp->max_it,nwork = 3; PetscFunctionBegin; /* This implementation of CG only handles left preconditioning so generate an error otherwise. */ if (ksp->pc_side == PC_RIGHT) { SETERRQ(PETSC_ERR_SUP,"No right preconditioning for KSPCG"); } else if (ksp->pc_side == PC_SYMMETRIC) { SETERRQ(PETSC_ERR_SUP,"No symmetric preconditioning for KSPCG"); } /* get work vectors needed by CG */ if (cgP->singlereduction) nwork += 2; ierr = KSPDefaultGetWork(ksp,nwork);CHKERRQ(ierr); /* If user requested computations of eigenvalues then allocate work work space needed */ if (ksp->calc_sings) { /* get space to store tridiagonal matrix for Lanczos */ ierr = PetscMalloc4(maxit+1,PetscScalar,&cgP->e,maxit+1,PetscScalar,&cgP->d,maxit+1,PetscReal,&cgP->ee,maxit+1,PetscReal,&cgP->dd);CHKERRQ(ierr); ierr = PetscLogObjectMemory(ksp,2*(maxit+1)*(sizeof(PetscScalar)+sizeof(PetscReal)));CHKERRQ(ierr); ksp->ops->computeextremesingularvalues = KSPComputeExtremeSingularValues_CG; ksp->ops->computeeigenvalues = KSPComputeEigenvalues_CG; } PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_GROPPCG(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; ierr = KSPDefaultGetWork(ksp,6);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode KSPSetUp_CGS(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; ierr = KSPDefaultGetWork(ksp,7);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode KSPSetUp_TCQMR(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; if (ksp->pc_side == PC_SYMMETRIC) SETERRQ(((PetscObject)ksp)->comm,PETSC_ERR_SUP,"no symmetric preconditioning for KSPTCQMR"); ierr = KSPDefaultGetWork(ksp,TCQMR_VECS);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_PIPECG(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; /* get work vectors needed by PIPECG */ ierr = KSPDefaultGetWork(ksp,9);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_Chebychev(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; if (ksp->pc_side == PC_SYMMETRIC) SETERRQ(PETSC_ERR_SUP,"no symmetric preconditioning for KSPCHEBYCHEV"); if (ksp->pc_side == PC_RIGHT) SETERRQ(PETSC_ERR_SUP,"no right preconditioning for KSPCHEBYCHEV"); ierr = KSPDefaultGetWork(ksp,3);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode KSPSetUp_CR(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; if (ksp->pc_side == PC_RIGHT) {SETERRQ(PETSC_ERR_SUP,"no right preconditioning for KSPCR");} else if (ksp->pc_side == PC_SYMMETRIC) {SETERRQ(PETSC_ERR_SUP,"no symmetric preconditioning for KSPCR");} ierr = KSPDefaultGetWork(ksp,6);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode KSPSetUp_IBCGS(KSP ksp) { PetscErrorCode ierr; PetscBool diagonalscale; PetscFunctionBegin; ierr = PCGetDiagonalScale(ksp->pc,&diagonalscale);CHKERRQ(ierr); if (diagonalscale) SETERRQ1(((PetscObject)ksp)->comm,PETSC_ERR_SUP,"Krylov method %s does not support diagonal scaling",((PetscObject)ksp)->type_name); ierr = KSPDefaultGetWork(ksp,9);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_NASH(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; /***************************************************************************/ /* Set work vectors needed by conjugate gradient method and allocate */ /***************************************************************************/ ierr = KSPDefaultGetWork(ksp, 3);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_BiCG(KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; /* check user parameters and functions */ if (ksp->pc_side == PC_RIGHT) { SETERRQ(PETSC_ERR_SUP,"no right preconditioning for KSPBiCG"); } else if (ksp->pc_side == PC_SYMMETRIC) { SETERRQ(PETSC_ERR_SUP,"no symmetric preconditioning for KSPBiCG"); } /* get work vectors from user code */ ierr = KSPDefaultGetWork(ksp,6);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetUp_BCGSL(KSP ksp) { KSP_BCGSL *bcgsl = (KSP_BCGSL *)ksp->data; PetscInt ell = bcgsl->ell,ldMZ = ell+1; PetscErrorCode ierr; PetscFunctionBegin; if (ksp->pc_side == PC_SYMMETRIC) { SETERRQ(PETSC_ERR_SUP, "no symmetric preconditioning for KSPBCGSL"); } else if (ksp->pc_side == PC_RIGHT) { SETERRQ(PETSC_ERR_SUP, "no right preconditioning for KSPBCGSL"); } ierr = KSPDefaultGetWork(ksp, 6+2*ell); CHKERRQ(ierr); ierr = PetscMalloc5(ldMZ,PetscScalar,&AY0c,ldMZ,PetscScalar,&AYlc,ldMZ,PetscScalar,&AYtc,ldMZ*ldMZ,PetscScalar,&MZa,ldMZ*ldMZ,PetscScalar,&MZb); CHKERRQ(ierr); PetscFunctionReturn(0); }