clc; close all;

save_figures = 1;

x_wall = 0; y_wall = 0;


n_dt = 12;
t_vect = 0:(n_dt * dt):T;
values_rho = rho_wall(1:n_dt:end);
values_u = u_wall(1:n_dt:end);
values_v = v_wall(1:n_dt:end);
values_p = p_wall(1:n_dt:end);


t_step_exact = 0.01;
t_vect_exact = 0:t_step_exact:T;
n = length(t_vect_exact);
values_rho_exact = zeros(1,n);
values_u_exact = zeros(1,n);
values_v_exact = zeros(1,n);
values_p_exact = zeros(1,n);

tic;
for i = 1:n
    [rho_point,u_point,v_point,p_point] = ExactSolution(x_wall,y_wall,t_vect_exact(i));
    values_rho_exact(i) = rho_point; 
    values_u_exact(i) = u_point; 
    values_v_exact(i) = v_point; 
    values_p_exact(i) = p_point; 
end
toc;

% vykresleni numerickeho reseni bodove
fig_rho = figure;
plot(t_vect_exact,values_rho_exact,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_rho,'*');
legend('analytical','numerical','Location','NorthEast');
xlim([0,T]);
ylim([-0.2,0.35]);
xlabel('t'); ylabel('\rho''');

fig_u = figure;
plot(t_vect_exact,values_u_exact,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_u,'*');
legend('analytical','numerical','Location','NorthEast');
xlim([0,T]);
ylim([-0.35,0.15]);
xlabel('t'); ylabel('u''');

fig_v = figure;
plot(t_vect_exact,values_v_exact,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_v,'*');
legend('analytical','numerical','Location','NorthEast');
xlim([0,T]);
ylim([-0.35,0.15]);
xlabel('t'); ylabel('v''');

fig_p = figure;
plot(t_vect_exact,values_p_exact,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_p,'*');
legend('analytical','numerical','Location','NorthEast');
xlim([0,T]);
ylim([-0.2,0.35]);
xlabel('t'); ylabel('p''');

if save_figures == 1
    mesh_size_string = sprintf('%0.2f',mesh_size_parametr);
    mesh_size_string = strrep(mesh_size_string,'.',',');
    
    filename_string = ['CAA_Workshop1_Category4_Problem1_rho_solution_on_wall_x=0_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_rho,filename_string,'pdf');
    saveas(fig_rho,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category4_Problem1_u_solution_on_wall_x=0_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_u,filename_string,'pdf');
    saveas(fig_u,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category4_Problem1_v_solution_on_wall_x=0_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_v,filename_string,'pdf');
    saveas(fig_v,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category4_Problem1_p_solution_on_wall_x=0_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_p,filename_string,'pdf');
    saveas(fig_p,filename_string,'png');
end