
clear all; clf

% parameter files
filename='rayleightaylor';
%%sed -e 's/Description/salut/g' rayleightaylor.gfs > blou

dostart=0;

paramvec=linspace(1,20,7);

% loop over parameters
for ind=1:length(paramvec)
    t=paramvec(ind);

    if dostart
    % edit the parameter files
    st=['!sed -e ''s/TMAX/' num2str(t) '/g'' ' filename '.gfs > ' filename num2str(ind) '.gfs'];
    disp(st)
    eval(st)

    % start the computations
    stt=['!gerris2D ' filename num2str(ind) '.gfs'];

    else
    % now do the postprocessing



end




break

% interpolation

n=30;
x=linspace(0,2*pi,n);
y=linspace(0,pi,n/2);

[X,Y]=meshgrid(x,y);


% initial condition for particles
np=15000;
xp=rand(np,1)*2*pi;
yp=rand(np,1)*pi;

selb=xp<pi;

hold on

dt=0.1;

meth='linear';

nt=10000;
tvec=0:dt:nt*dt;
% my time loop
for ind=1:nt
t=tvec(ind);
u=sin(X-t).*cos(Y);
v=-cos(X-t).*sin(Y);
quiver(X,Y,u,v,1,'k');
hold on
    
up=interp2(X,Y,u,xp,yp,meth);
vp=interp2(X,Y,v,xp,yp,meth);



%quiver(xp,yp,up,vp,1,'r')

xp=mod(xp+dt*up,2*pi);
yp=yp+dt*vp;

plot(xp(selb),yp(selb),'b.','markersize',5);
plot(xp(~selb),yp(~selb),'r.','markersize',5);
hold off
drawnow
end



