% plots convergence results for (5,2) scheme
%
% returns error matrix (rows are 1, 2, inf norm; columns are various grids)
%
% solutions at grid sizes are compared to analytic solutions from Merz
%
% Ian Mitchell for TransAC, 5/4/01

% strings to build level set filenames
%rootString = '/tmp/Aircraft3D/aircraft3D';
rootString = 'c:\cygwin\tmp\Aircraft3D\air';
tailString = 'min.0260';
gridString = { '050', '070', '100', '140', '200' };
%gridString = { '050', '070', '100', '140', '200' };

% mat file where barrier points are stored
%merzFile = '/tmp/Aircraft3D/merzPts60';
merzFile = 'c:\cygwin\tmp\Aircraft3D\merzPts60';

% set up data arrays
n = length(gridString);
grid = zeros(1,n);
err = zeros(3,n);

% this should load a vector of 3D points called "pts"
load(merzFile);

for i = 1:n

  grid(i) = str2num(gridString{i});
  gridFilename = sprintf('%s.%s.%s', rootString, gridString{i}, tailString);

  err(:,i) = errorLS(gridFilename, pts);

end

figure;
l = loglog(grid, err(1,:), '-s');
hold on
l = [ l; loglog(grid, err(3,:), '--x') ];
l = [ l; loglog(grid, 1 ./ grid, ':o') ];

if(1)
  axis([ min(grid) max(grid) 1e-4 0.03 ]);
  set(gca, 'fontsize', 24);
  ylabel([ 'Error' ]);
  xlabel('Grid Size n')
  title('(5,2) Scheme');
  [ legh obj ] = legend('1 norm', '\infty norm', '\Delta x', 3);
  set(gca, 'xtick', grid);
  set(l, 'linewidth', 4);
  set(l, 'markersize', 12);
end
