Actual source code: preonly.c

  1: #define PETSCKSP_DLL

 3:  #include 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",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:   KSP_PCApply(ksp,ksp->vec_rhs,ksp->vec_sol);
 29:   ksp->its    = 1;
 30:   ksp->reason = KSP_CONVERGED_ITS;
 31:   return(0);
 32: }

 34: /*MC
 35:      KSPPREONLY - This implements a stub method that applies ONLY the preconditioner.
 36:                   This may be used in inner iterations, where it is desired to 
 37:                   allow multiple iterations as well as the "0-iteration" case. It is 
 38:                   commonly used with the direct solver preconditioners like PCLU and PCCHOLESKY

 40:    Options Database Keys:
 41: .   see KSPSolve()

 43:    Level: beginner

 45: .seealso:  KSPCreate(), KSPSetType(), KSPType (for list of available types), KSP

 47: M*/

 52: PetscErrorCode  KSPCreate_PREONLY(KSP ksp)
 53: {
 55:   ksp->data                      = (void*)0;
 56:   ksp->ops->setup                = KSPSetUp_PREONLY;
 57:   ksp->ops->solve                = KSPSolve_PREONLY;
 58:   ksp->ops->destroy              = KSPDefaultDestroy;
 59:   ksp->ops->buildsolution        = KSPDefaultBuildSolution;
 60:   ksp->ops->buildresidual        = KSPDefaultBuildResidual;
 61:   ksp->ops->setfromoptions       = 0;
 62:   ksp->ops->view                 = 0;
 63:   return(0);
 64: }