halfvmg_cycle.m

来自「五点差分型多重网格方法:各种插值算子的比较)」· M 代码 · 共 42 行

M
42
字号
%HALFVMG_CYCLE  Half V-cycle Algorithm
%
%       *** NOT IMPLEMENTED YET ***
%
%       U_OUT = HALFVMG_CYCLE(LEVEL, B) uses the half V-Cycle to 
%       recursively solve the linear system AX=B at the given level.
%
%       No global variables are accessed.

% James Bordner and Faisal Saied
% Department of Computer Science
% University of Illinois at Urbana-Champaign
% 10 April 1995

% Modified for Matlab Version 6 Compatability
% Ryan McKenzie
% University of Kentucky Center for Computational Sciences
% May 2004
%
% Minor changes made in determining if we are on the coursest level currently.

function u_out = vmg_cycle(level, b, u_in)

% Use the zero vector for u_in as the default

if nargin == 2,   
   u_in = zeros(size(b));
end

C_level = coarsest;
if level==C_level
   u_out   = coarse_grid_solve(level, b);
else 
   u       = smooth(level, b, u_in, 'pre');
   r       = residual(level, b, u);
   b_c     = restrict(level, r);
   u_c     = vmg_cycle(level+1, b_c);
   correct = interpolate(level, u_c);
   u       = u + correct;
   u_out   = smooth(level, b, u, 'post');
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?