%
% @file test_stencil.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 .
%
% @authors
% (in alphabetical order)
% @author Trach-Minh Tran
%
if ~exist('file'), file='test_stencil.h5'; end
x = h5read(file, '/xgrid');
y = h5read(file, '/ygrid');
b1 = h5read(file, '/barr1');
b2 = h5read(file, '/barr2');
b3 = h5read(file, '/barr3');
n1=size(x,1);
n2=size(y,1);
n=n1*n2
mat = stencil_mat(file, '/MAT');
% $$$ figure
% $$$ spy(mat)
fprintf('||B1|| = %e\n', norm(reshape(b1,n,1)));
fprintf('||B2|| = %e\n', norm(reshape(b2,n,1)));
fprintf('||B3|| = %e\n', norm(reshape(b3,n,1)));
% $$$ figure
% $$$ subplot(321)
% $$$ surf(x,y,v'); title('Exact solution')
% $$$ xlabel('X'); ylabel('Y')
% $$$ subplot(322)
% $$$ surf(x,y,f'); title('RHS')
% $$$ xlabel('X'); ylabel('Y')
% $$$ subplot(323)
% $$$ surf(x,y,u'); title('Num. solution')
% $$$ subplot(324)
% $$$ surf(x,y,udirect'); title('Direct. solution')
% $$$ xlabel('X'); ylabel('Y')
% $$$ subplot(325)
% $$$ surf(x,y,resids'); title('Residuals')
% $$$ xlabel('X'); ylabel('Y')
% $$$ subplot(326)
% $$$ surf(x,y,errs'); title('Errors')
% $$$ xlabel('X'); ylabel('Y')