adding balbi_atm.m
[wrf-fire-matlab.git] / femwind / coarse_correction.m
blob2c20c75d3929a25a9eb79512ceb0caecc1938186
1 function x=coarse_correction(x,F,K,K_coarse,X_coarse,hzc,icl3,X,params)
2     n = size(X{1});
3     res = reshape(F-K*x,n);
4     F_c = restriction(res,hzc,icl3,X,params);
5     % F_c_f = restriction_fortran(res,hzc,icl3,X,params);
6     % err_fort=big(F_c-F_c_f)
7     F_coarse = F_c(:);
8     if params.apply_coarse_boundary_conditions
9         [K_coarse,F_coarse]=apply_boundary_conditions(K_coarse,F_coarse,X_coarse);
10     end
11     params_coarse=params;  % copy all params 
12     params_coarse.level=params.level+1;
13     params_coarse.levels=params.levels-1;
14     params_coarse.nsmooth=params.nsmooth_coarse;
15     params_coarse.maxit=params.maxit_coarse;
16     params_coarse.iterations_fig=params.iterations_fig+10;
17     params_coarse.res_slice_fig=params.res_slice_fig+10;
18     params_coarse.err_slice_fig=params.err_slice_fig+10;
19     [x_coarse,~,~,~]=multigrid_solve(K_coarse,F_coarse,X_coarse,params_coarse);
20     fprintf('coarse solve done, level %g continuting\n',params.levels)
21     % x = x + P*x_coarse
22     x_increment = prolongation(reshape(x_coarse,size(X_coarse{1})),hzc,icl3,X,params);
23     x = x + x_increment(:);
24 end