function [x,u,t] = pclaw_load(path,frame)
%PCLAW_LOAD Load pclaw data file.
% [X,U,T] = PCLAW_LOAD(PATH,FRAME) loads a data file generated by
% the particle method PARTICLECLAW for scalar conservation and
% balance laws in one space dimension.
% PATH is a string providing where to find the file, FRAME is an
% integer stating the number of the data file. If PATH is
% omitted, the current path is chosen.
% Two files are required: pclaw.q???? and pclaw.t????.
% The function yields the positions and function values of points
% representing the solution, and the time in the computation.
%
% Version 1.0
% Copyright (c) 2008 Benjamin Seibold and Yossi Farjoun
% http://math.mit.edu/~seibold/research/particleclaw
% http://arxiv.org/abs/0809.0726
%===============================================================================
if nargin==1, frame = path; path = '.'; end
filename = sprintf('%s/pclaw.t%04d',path,frame);
try
fid = fopen(filename);
t = fgetl(fid); t = str2num(t(1:20));
fclose(fid);
catch
x = nan; u = nan; t = nan;
return
end
filename = sprintf('%s/pclaw.q%04d',path,frame);
try
fid = fopen(filename);
u = fscanf(fid,'%e %e',[2 inf]);
x = u(1,:)'; u = u(2,:)';
fclose(fid);
catch
x = nan; u = nan; t = nan;
return
end
%===============================================================================
% Copyright (c) 2008 Benjamin Seibold and Yossi Farjoun
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction for non-commercial purposes, including
% without limitation the rights to use, copy, modify, merge, publish, and/or
% distribute copies of the Software, and to permit persons to whom the
% Software is furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software, and credit has to be
% given to the authors in publications that are in any form based on this
% Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
% THE SOFTWARE.
%===============================================================================