Actual source code: smg.c

      1: #define PETSCKSP_DLL

      3: /*
      4:      Additive Multigrid V Cycle routine
      5: */
     6:  #include src/ksp/pc/impls/mg/mgimpl.h

     10: PetscErrorCode PCMGACycle_Private(PC_MG **mg)
     11: {
     13:   PetscInt       i,l = mg[0]->levels;
     14:   PetscScalar    zero = 0.0;

     17:   /* compute RHS on each level */
     18:   for (i=l-1; i>0; i--) {
     19:     MatRestrict(mg[i]->restrct,mg[i]->b,mg[i-1]->b);
     20:   }
     21:   /* solve seperately on each level */
     22:   for (i=0; i<l; i++) {
     23:     VecSet(mg[i]->x,zero);
     24:     if (mg[i]->eventsolve) {PetscLogEventBegin(mg[i]->eventsolve,0,0,0,0);}
     25:     KSPSolve(mg[i]->smoothd,mg[i]->b,mg[i]->x);
     26:     if (mg[i]->eventsolve) {PetscLogEventEnd(mg[i]->eventsolve,0,0,0,0);}
     27:   }
     28:   for (i=1; i<l; i++) {
     29:     MatInterpolateAdd(mg[i]->interpolate,mg[i-1]->x,mg[i]->x,mg[i]->x);
     30:   }
     31:   return(0);
     32: }