1 #include "../src/snes/impls/fas/fasimpls.h" 2 3 #undef __FUNCT__ 4 #define __FUNCT__ "SNESFASGalerkinDefaultFunction" 5 /* 6 SNESFASGalerkinDefaultFunction 7 8 */ 9 PetscErrorCode SNESFASGalerkinDefaultFunction(SNES snes, Vec X, Vec F, void * ctx) { 10 /* the Galerkin FAS function evalutation is defined as 11 F^l(x^l) = I^l_0F^0(P^0_lx^l) 12 */ 13 SNES fassnes; 14 SNES_FAS * fas; 15 SNES_FAS * prevfas; 16 SNES prevsnes; 17 Vec b_temp; 18 PetscErrorCode ierr; 19 PetscFunctionBegin; 20 /* prolong to the fine level and evaluate there. */ 21 fassnes = (SNES)ctx; 22 fas = (SNES_FAS *)fassnes->data; 23 prevsnes = fas->previous; 24 prevfas = (SNES_FAS *)prevsnes->data; 25 /* interpolate down the solution */ 26 ierr = MatInterpolate(prevfas->interpolate, X, prevfas->Xg);CHKERRQ(ierr); 27 /* the RHS we care about is at the coarsest level */ 28 b_temp = prevsnes->vec_rhs; 29 prevsnes->vec_rhs = PETSC_NULL; 30 ierr = SNESComputeFunction(prevsnes, prevfas->Xg, prevfas->Fg);CHKERRQ(ierr); 31 prevsnes->vec_rhs = b_temp; 32 /* restrict up the function */ 33 ierr = MatRestrict(prevfas->restrct, prevfas->Fg, F);CHKERRQ(ierr); 34 PetscFunctionReturn(0); 35 } 36