📄 demo3_run.m
字号:
%==============================================
% MAIN SCRIPT OF MULTIGRID---Q1 FEM
%==============================================
% zhiyong2008 finish
% 用外推多重网格方法解-△u+u=f,(0,1)x(0,1).黎曼0边界条件
% zhiyongliu1983@163.com
%================================================================
function demo3_run
demo_globals
include_globals
include_flags
disp('*****Starting my Multigrid:Zhiyong 2008 work*****');
for nx1 = [ 8 ];
ny1 =nx1; %
coarse_level = 3; % Set current maximum number of levels
nu1 = 3; nu2 = 3; % Set number of pre- and post-smoothings
wt = 0.95; % Set smoother weighting
rhs_flag = 1; % Select right-hand side
%------------------------------------------------------------------
%smooth_flag = WEIGHTED_JACOBI;% Select smoother
smooth_flag = GAUSS_SEIDEL;
% smooth_flag = RB_GAUSS_SEIDEL;
%----------------------------------------------------------------
restrict_flag = INJECTION; % Select restriction operator
% restrict_flag = FULL_WEIGHTING;
% restrict_flag = HALF_WEIGHTING;
% restrict_flag = ZHIJIE; %This is INJECTION designed in my work.
% restrict_flag = IVER_FULL_LOCAL_EQUATION;
%restrict_flag = IVER_SEMI_LOCAL_EQUATION;
%restrict_flag = RES_LOCAL;
%restrict_flag = RES_LOCAL_SECOND;
%----------------------------------------------------------------
interp_flag = LINEAR; % Select interpolation operator
% interp_flag = FULL_LOCAL_EQUATION;
%interp_flag = SEMI_LOCAL_EQUATION;
%interp_flag = EIGHT_POINTS;
%interp_flag = ONE_DIM_LOCAL_EQUATION;
%interp_flag = EAST_SOUTH_AVERAGE;
%interp_flag = WEST_SOUTH_AVERAGE;
%interp_flag = TEST_FIVEPOINT ;
%---------------------------------------------------------------
solver_flag = VMG_SOLVE; % Select solver
precon_flag = NONE; % Select preconditioner
cycle_flag = V_CYCLE; % Select cycle flag
coarsening_flag = 0; % Select coarsening
coarse_solver_flag = DIRECT_SOLVE; % Select coarse-grid solve
cycle_flag = V_CYCLE; % Select MG cycle
% Method parameter defaults
rtol = 1e-16; % Set stopping tolerance on weighted residual
prtol = 1e-16; % Set stopping tol. on weighted pseudo-resid.
max_it = 12; % Set maximum number of iterations
max_time = 0; % Set maximum number of seconds
max_mflop = 0; % Set maximum number of mflops
num_runs = 1; % Set number of experiments to run
% Linear System defaults
generate_matrix = 1; % Must generate the matrix initially
generate_rhs = 1; % Must generate the right-hand side initially
matrix_type = []; % Matrix properties initially unknown
if (generate_matrix)
[x,y,A1,N1,b] = get_matrix_fem(nx1,ny1);
generate_matrix = 0;
multigrid_setup;
end
x0 = zeros(N1,1);
fprintf('------------------------------------------------------------------------------------\n');
fprintf('level=%d×%d,,',nx1,ny1);
utrue= cos(pi*x).*cos(pi*y);
demo3_vmg(A1,b,x0,utrue',rtol,prtol,max_it,max_time,max_mflop);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -