Actual source code: preonly.c
1: #define PETSCKSP_DLL
3: #include private/kspimpl.h
7: static PetscErrorCode KSPSetUp_PREONLY(KSP ksp)
8: {
10: return(0);
11: }
15: static PetscErrorCode KSPSolve_PREONLY(KSP ksp)
16: {
18: PetscTruth diagonalscale;
21: PCDiagonalScale(ksp->pc,&diagonalscale);
22: if (diagonalscale) SETERRQ1(PETSC_ERR_SUP,"Krylov method %s does not support diagonal scaling",((PetscObject)ksp)->type_name);
23: if (!ksp->guess_zero) {
24: SETERRQ(PETSC_ERR_USER,"Running KSP of preonly doesn't make sense with nonzero initial guess\n\
25: you probably want a KSP type of Richardson");
26: }
27: ksp->its = 0;
28: PCSetInitialGuessNonzero(ksp->pc,(PetscTruth)!(int)ksp->guess_zero);
29: KSP_PCApply(ksp,ksp->vec_rhs,ksp->vec_sol);
30: ksp->its = 1;
31: ksp->reason = KSP_CONVERGED_ITS;
32: return(0);
33: }
35: /*MC
36: KSPPREONLY - This implements a stub method that applies ONLY the preconditioner.
37: This may be used in inner iterations, where it is desired to
38: allow multiple iterations as well as the "0-iteration" case. It is
39: commonly used with the direct solver preconditioners like PCLU and PCCHOLESKY
41: Options Database Keys:
42: . see KSPSolve()
44: Level: beginner
46: .seealso: KSPCreate(), KSPSetType(), KSPType (for list of available types), KSP
48: M*/
53: PetscErrorCode KSPCreate_PREONLY(KSP ksp)
54: {
56: ksp->data = (void*)0;
57: ksp->ops->setup = KSPSetUp_PREONLY;
58: ksp->ops->solve = KSPSolve_PREONLY;
59: ksp->ops->destroy = KSPDefaultDestroy;
60: ksp->ops->buildsolution = KSPDefaultBuildSolution;
61: ksp->ops->buildresidual = KSPDefaultBuildResidual;
62: ksp->ops->setfromoptions = 0;
63: ksp->ops->view = 0;
64: return(0);
65: }