% Written by: Tapovan Lolla 
% Modified to run with FV Framework v2-100 
% Written for 2.29 Spring 2013 

% Lid driven flow convergence test. 
clear all 
clc 
clf
close all 

% Timestep. 
dt = 1/100; 
T = 6000*dt; 
plt = 500; 

% Set viscosity 
nu = 0.001; %(for RE=1000) 
U = cell(6,2); 
for i = 1:length(U) 
    N = 2.5*2^i; 
    app.Nx = N; 
    app.Ny = N; 
    app.nu = nu; 
    app.PlotIntrvl = plt; 
    app.T = T; 
    app.dt = dt; 
    [P, u, v, rho] = TestCase(10,app); %extract center u and v velocities 
    if ~mod(N,2) 
        U{i,1} = u(5+N*(N/2-1):4+N*(N/2)); 
    else U{i,1} = 0.5*(u(5+N*(N-1)/2:4+N*(N-1)/2+N)+... 
            u(5+N*(N+1)/2:4+N*(N+1)/2+N)); 
    end
    dy = 1/N; 
    U{i,2} = fliplr(linspace(dy/2,1-dy/2,N)); 
end
%% Plot figure 
figure 
str={'--','xg','or','<m','pk','db'};
hold on
for i = 1:length(U)
   hold on
   plot(U{i,1},U{i,2},str{i})
end
ylabel('y')
xlabel('U - velocity')
title('Vertical center line U-velocity')
legend('8x8','16x16','32x32','64x64','128x128','256x256')
grid on
box on
