close all
clear
datapath = '/mnt/data/ijs/medusa-disucssions/sparse-matrices/';

casename = 'rbf_fd_scattered';
% casename = 'rbf_fd_uniform';
% casename = 'fdm_uniform';

file = [datapath casename '_wip.h5'];

grp = '';
pos = h5read(file, '/domain/pos');
types = h5read(file, '/domain/types');
int = types > 0;
bnd = types < 0;

neigh = h5read(file, '/neighbors') + 1; % Matlab has 1-based indexing

sol = h5read(file, '/sol');
M = spconvert(h5read(file, '/M'));
rhs = h5read(file, '/rhs');

x = pos(:, 1);
y = pos(:, 2);

figure
scatter(x, y, 5, sol, 'filled');
box on
grid on
daspect([1 1 1])
colorbar
colormap jet
title('Solution of $\nabla^2 u = 1; u|_{\partial \Omega} = 0$', 'interpreter', 'latex')


figure 
spy(M)
title('System matrix')

figure
spy(M(int, int))
title('Only interior nodes')


figure
lam = eigs(M(int, int), sum(int));
scatter(real(lam), imag(lam), 5, 'ok', 'filled')
box on
grid on
title('Spectrum of $M$')
