%
% Demonstration of front tracking for a system;
%

% Making a color map called cm; you can change roed gronn and blaa 
% to change the colors. 
NCOLOR=512;
g=linspace(0,1,NCOLOR)';
cm=[roed(g),gronn(g),blaa(g)];
cm=flipud(cm);   % Just for aestetic purposes. 
close all; 

% Here are the parameters for the front tracking routine !!!!!!!
N=64; 
delta=0.5; % Just a convenient value, delta does not depend on N
T=1.5;
xmax=1; xmin=-1;
h=(xmax-xmin)/N;
x0=xmin+h:h:xmax-h;
y=xmin+h/2:h:xmax-h/2;

% Initial function 
p=(cos(pi*y)).^2 + 0.1;
v=cos(pi*y);

% To ensure periodic data:
xmin=xmin+h/2;
xmax=xmax-h/2;
p(N)=p(1);
v(N)=v(1);



% plot initial functions
plotFTresult([p;v],y);
pause;
% wait for CR
u0=Phys_to_Riemann(p,v);
% The front tracking routine
[u,x]=genFrontTrack(u0,x0,T,delta,'display','polygons','colors',hot,...
	'periodic',[xmin xmax]);
% Change the options to produce other figures							
pause;
%wait for CR
[p,v]=Riemann_to_Phys(u);
plotFTresult([p;v],x);
