function phi = sweep(phi,n,h,N,ix,iy) 
%% basic RT scheme Rouy Tourin discrestization 

%% loop according to specified ordering 
 for j = ix
  for i = iy
    %% upwind 
      a = min(phi(i-1, j), phi(i+1,j));
      b = min(phi(i, j+1), phi(i, j-1));  

%% check causality 
     if (abs(a-b) < n(i,j)*h)     
       nphi = 0.5*(a+b+sqrt(2.0*n(i,j)*n(i,j)*h*h-(a-b)*(a-b)));
     else
       nphi = min(a, b) + n(i,j)*h;
     end
       phi(i,j) = min(nphi,phi(i,j))  ; %% boundary conditions  
   end
  end








