Actual source code: preonly.c

  1: /*$Id: preonly.c,v 1.42 2001/05/14 21:07:54 bsmith Exp $*/

  3: /*                       
  4:        This implements a stub method that applies ONLY the preconditioner.
  5:        This may be used in inner iterations, where it is desired to 
  6:        allow multiple iterations as well as the "0-iteration" case
  7: */
 8:  #include src/sles/ksp/kspimpl.h

 12: static int KSPSetUp_PREONLY(KSP ksp)
 13: {
 15:   return(0);
 16: }

 20: static int  KSPSolve_PREONLY(KSP ksp,int *its)
 21: {
 22:   int        ierr;
 23:   Vec        X,B;
 24:   PetscTruth diagonalscale;

 27:   PCDiagonalScale(ksp->B,&diagonalscale);
 28:   if (diagonalscale) SETERRQ1(1,"Krylov method %s does not support diagonal scaling",ksp->type_name);
 29:   if (!ksp->guess_zero) {
 30:     SETERRQ(1,"Running KSP of preonly doesn't make sense with nonzero initial guess\n\
 31:                you probably want a KSP type of Richardson");
 32:   }

 34:   ksp->its    = 0;
 35:   X           = ksp->vec_sol;
 36:   B           = ksp->vec_rhs;
 37:   KSP_PCApply(ksp,ksp->B,B,X);
 38:   *its        = 1;
 39:   ksp->its    = 1;
 40:   ksp->reason = KSP_CONVERGED_ITS;
 41:   return(0);
 42: }

 44: EXTERN_C_BEGIN
 47: int KSPCreate_PREONLY(KSP ksp)
 48: {
 50:   ksp->data                      = (void*)0;
 51:   ksp->ops->setup                = KSPSetUp_PREONLY;
 52:   ksp->ops->solve                = KSPSolve_PREONLY;
 53:   ksp->ops->destroy              = KSPDefaultDestroy;
 54:   ksp->ops->buildsolution        = KSPDefaultBuildSolution;
 55:   ksp->ops->buildresidual        = KSPDefaultBuildResidual;
 56:   ksp->ops->setfromoptions       = 0;
 57:   ksp->ops->view                 = 0;
 58:   return(0);
 59: }
 60: EXTERN_C_END