% % @file test_mg2d.m % % @brief % % @copyright % Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) % SPC (Swiss Plasma Center) % % SPClibs is free software: you can redistribute it and/or modify it under % the terms of the GNU Lesser General Public License as published by the Free % Software Foundation, either version 3 of the License, or (at your option) % any later version. % % SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY % WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. % % You should have received a copy of the GNU Lesser General Public License % along with this program. If not, see . % % @author % (in alphabetical order) % @author Trach-Minh Tran % file='test_mg2d.h5'; % nx=h5readatt(file,'/','NX'); ny=h5readatt(file,'/','NY'); kx=h5readatt(file,'/','KX'); ky=h5readatt(file,'/','KY'); nidbas1=h5readatt(file,'/','NIDBAS1'); nidbas2=h5readatt(file,'/','NIDBAS2'); relax=h5readatt(file,'/','RELAX'); nlevels=h5readatt(file,'/','LEVELS'); nu1=h5readatt(file,'/','NU1'); nu2=h5readatt(file,'/','NU2'); mu=h5readatt(file,'/','MU'); title_str=sprintf(['N=(%d,%d), NIDBAS=(%d,%d), relax=%s, nu1=%d, ' ... 'nu2=%d, mu=%d, LEVELS=%d, KX=%d, KY=%d'], ... nx,ny,nidbas1,nidbas2,relax,nu1,nu2,mu,nlevels,kx,ky); % % Prolongation matrices at the coarsest grid % levels=nlevels; mglevel=sprintf('/mglevels/level.%.2d', levels); dset=strcat(mglevel,'/matpx'); matpx=csr_mat(file,dset); dset=strcat(mglevel,'/matpy'); matpy=csr_mat(file,dset); % % FE matrix at the finest grid % levels=1; mglevel=sprintf('/mglevels/level.%.2d', levels); dset=strcat(mglevel,'/mata'); [mata,diag]=csr_mat(file,dset); f=h5read(file,strcat(mglevel,'/f')); v=h5read(file,strcat(mglevel,'/v')); f1d=h5read(file,strcat(mglevel,'/f1d')); v1d=h5read(file,strcat(mglevel,'/v1d')); % $$$ figure % $$$ spy(mata) % % Solutions at the finest grid % x=h5read(file,'/solutions/xg'); y=h5read(file,'/solutions/yg'); sol_anal=h5read(file,'/solutions/anal'); sol_calc=h5read(file,'/solutions/calc'); % $$$ figure % $$$ subplot(211) % $$$ surf(x,y,sol_anal') % $$$ xlabel('X'); ylabel('Y'); % $$$ title('Analytical solution on the finest grid') % $$$ subplot(212) % $$$ surf(x,y,sol_calc') % $$$ xlabel('X'); ylabel('Y'); % $$$ title('Calculated solution on the finest grid') % % Iterations % dset='/Iterations/'; disc_err=h5read(file, strcat(dset,'disc_errors')); resid=h5read(file, strcat(dset,'residues')); its=0:1:size(resid,1)-1; figure subplot(211) semilogy(its,resid,'o-') grid on xlabel('Iterations'); ylabel('Norm of residue'); title(title_str); subplot(212) semilogy(its,disc_err,'h-') grid on xlabel('Iterations'); ylabel('Norm of error');