clc; close all;

save_figures = 0;

load('Bajko_Problem3_reference_solution_on_boundary_for_h=3_00,_N=6,_T=500.mat'); % referencni reseni

n_dt = 10;
t_vect = 0:(n_dt * dt):T;

% (x,y) = (100,0)
values_rho_R = rho_boundary_R(1:n_dt:end);
values_u_R = u_boundary_R(1:n_dt:end);
values_v_R = v_boundary_R(1:n_dt:end);
values_p_R = p_boundary_R(1:n_dt:end);

T_reference = 500;
N_steps_reference = 12450;
t_vect_reference = 0:(T_reference / N_steps_reference):T_reference;

% vykresleni numerickeho reseni bodove
fig_rho_R = figure;
plot(t_vect_reference,values_rho_reference_R,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_rho_R,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.01,0.18]);
xlabel('t'); ylabel('\rho''');

fig_u_R = figure;
plot(t_vect_reference,values_u_reference_R,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_u_R,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.04,0.08]);
xlabel('t'); ylabel('u''');

fig_v_R = figure;
plot(t_vect_reference,values_v_reference_R,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_v_R,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.12,0.12]);
xlabel('t'); ylabel('v''');

fig_p_R = figure;
plot(t_vect_reference,values_p_reference_R,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_p_R,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.04,0.08]);
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_Category3_Problem1_rho_solution_on_boundary_x=100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_rho_R,filename_string,'pdf');
    saveas(fig_rho_R,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_u_solution_on_boundary_x=100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_u_R,filename_string,'pdf');
    saveas(fig_u_R,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_v_solution_on_boundary_x=100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_v_R,filename_string,'pdf');
    saveas(fig_v_R,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_p_solution_on_boundary_x=100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_p_R,filename_string,'pdf');
    saveas(fig_p_R,filename_string,'png');
end


% (x,y) = (-100,0)
values_rho_L = rho_boundary_L(1:n_dt:end);
values_u_L = u_boundary_L(1:n_dt:end);
values_v_L = v_boundary_L(1:n_dt:end);
values_p_L = p_boundary_L(1:n_dt:end);

% vykresleni numerickeho reseni bodove
fig_rho_L = figure;
plot(t_vect_reference,values_rho_reference_L,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_rho_L,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.02,0.05]);
xlabel('t'); ylabel('\rho''');

fig_u_L = figure;
plot(t_vect_reference,values_u_reference_L,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_u_L,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.05,0.03]);
xlabel('t'); ylabel('u''');

fig_v_L = figure;
plot(t_vect_reference,values_v_reference_L,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_v_L,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.05,0.03]); % vazne zde ma byt stale nula???
xlabel('t'); ylabel('v''');

fig_p_L = figure;
plot(t_vect_reference,values_p_reference_L,'Color','red','LineWidth',2); hold on;
plot(t_vect,values_p_L,'*');
legend('reference','numerical','Location','NorthEast');
xlim([0,T]);
%ylim([-0.02,0.05]);
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_Category3_Problem1_rho_solution_on_boundary_x=-100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_rho_L,filename_string,'pdf');
    saveas(fig_rho_L,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_u_solution_on_boundary_x=-100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_u_L,filename_string,'pdf');
    saveas(fig_u_L,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_v_solution_on_boundary_x=-100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_v_L,filename_string,'pdf');
    saveas(fig_v_L,filename_string,'png');
    
    filename_string = ['CAA_Workshop1_Category3_Problem1_p_solution_on_boundary_x=-100_y=0_for_h=',mesh_size_string,',_N=',num2str(N)];
    saveas(fig_p_L,filename_string,'pdf');
    saveas(fig_p_L,filename_string,'png');
end