Actual source code: smg.c
1: /*$Id: smg.c,v 1.24 2001/08/07 03:03:36 balay Exp $*/
2: /*
3: Additive Multigrid V Cycle routine
4: */
5: #include src/sles/pc/impls/mg/mgimpl.h
7: /*
8: MGACycle_Private - Given an MG structure created with MGCreate() runs
9: one cycle down through the levels and back up. Applys
10: the smoothers in an additive manner.
12: Iput Parameters:
13: . mg - structure created with MGCreate().
15: */
16: int MGACycle_Private(MG *mg)
17: {
18: int i,l = mg[0]->levels,its,ierr;
19: PetscScalar zero = 0.0;
22: /* compute RHS on each level */
23: for (i=l-1; i>0; i--) {
24: MatRestrict(mg[i]->restrct,mg[i]->b,mg[i-1]->b);
25: }
26: /* solve seperately on each level */
27: for (i=0; i<l; i++) {
28: VecSet(&zero,mg[i]->x);
29: SLESSolve(mg[i]->smoothd,mg[i]->b,mg[i]->x,&its);
30: }
31: for (i=1; i<l; i++) {
32: MatInterpolateAdd(mg[i]->interpolate,mg[i-1]->x,mg[i]->x,mg[i]->x);
33: }
34: return(0);
35: }