📄 multigrid_setup.m
字号:
%MULTIGRID_SETUP Generate the linear systems for the coarse multigrid levels
%
% MULTIGRID_SETUP generates the coarse-grid linear systems for the
% currently defined problem.
%
% Accesses global variables in "include_flags"
% Accesses global variables in "include_globals"
function multigrid_setup
include_flags
include_globals
[X1,Y1] = meshgrid([0:nx1]/nx1,[0:ny1]/ny1);
ARRAY1 = zeros(nx1+1, ny1+1);
if coarse_level >= 2
nx2 = nx1/2 ;
ny2 = ny1/2 ;
[x2,y2,A2,N2,bb] = get_matrix_fem(nx2,ny2);
[X2,Y2] = meshgrid([0:nx2]/nx2,[0:ny2]/ny2);
if interp_flag == EXPLICIT_BILINEAR
ARRAY1 = sp_prolong(nx1,ny1,nx2,ny2);
else
ARRAY2 = zeros(nx2+1, ny2+1);
end
end
if coarse_level >= 3
nx3 = nx2/2;
ny3 = ny2/2;
[x3,y3,A3,N3,bb] = get_matrix_fem(nx3,ny3);
[X3,Y3] = meshgrid([0:nx3]/nx3,[0:ny3]/ny3);
if interp_flag == EXPLICIT_BILINEAR
ARRAY2 = sp_prolong(nx2,nx2,nx3,nx3);
else
ARRAY3 = zeros(nx3+1, ny3+1);
end
end
if coarse_level >= 4
nx4 = nx3/2 ;
ny4 = ny3/2 ;
[x4,y4,A4,N4,bb] = get_matrix_fem(nx4,ny4-1);
[X4,Y4] = meshgrid([0:nx4]/nx4,[0:ny4]/ny4);
if interp_flag == EXPLICIT_BILINEAR
ARRAY3 = sp_prolong(nx3,nx3,nx4,nx4);
else
ARRAY4 = zeros(nx4+1,ny4+1);
end
end
if coarse_level >= 5
nx5 = (nx4+1)/2 - 1;
ny5 = (ny4+1)/2 - 1;
[x5,y5,A5,N5,bb] = get_matrix_fem(nx5-1,nx5-1);
[X5,Y5] = meshgrid([0:nx5]/nx5,[0:ny5]/ny5);
if interp_flag == EXPLICIT_BILINEAR
ARRAY4 = sp_prolong(nx4,nx4,nx5,nx5);
else
ARRAY5 = zeros(nx5+1,ny5+1);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -