save_figures = 0;

disp('Plotting exact solution at specified time:');

t = 10;

step = 0.05;
dx = x_l:step:x_u; n_x = length(dx);
dy = y_l:step:y_u; n_y = length(dy);
[X,Y] = meshgrid(dx,dy);

rho_exact = zeros(size(X));
u_exact = zeros(size(X));
v_exact = zeros(size(X));
p_exact = zeros(size(X));

for i = 1:n_x
    for j = 1:n_y
        x_point = X(j,i); y_point = Y(j,i);
        [rho_point,u_point,v_point,p_point] = ExactSolution(x_point,y_point,t);
        rho_exact(j,i) = rho_point;
        u_exact(j,i) = u_point;
        v_exact(j,i) = v_point;
        p_exact(j,i) = p_point;
    end
end

fig_rho_ES = figure('Name','Density exact solution');
surf(dx, dy, rho_exact, 'EdgeColor', 'none');
xlabel('x'); ylabel('y'); zlabel('rho');
colorbar('Location','EastOutside');
view(0, 90);
axis equal;
xlim(x_axis_limits); ylim(y_axis_limits);
if save_figures == 1
    filename_string = sprintf('Bajko_Problem2_rho_exact_solution_in_t=%d',t);
    saveas(fig_rho_ES,filename_string,'pdf');
    saveas(fig_rho_ES,filename_string,'png');
end

fig_u_ES = figure('Name','Velocity u exact solution');
surf(dx, dy, u_exact, 'EdgeColor', 'none');
xlabel('x'); ylabel('y'); zlabel('u');
colorbar('Location','EastOutside');
view(0, 90);
axis equal;
xlim(x_axis_limits); ylim(y_axis_limits);
if save_figures == 1
    filename_string = sprintf('Bajko_Problem2_u_exact_solution_in_t=%d',t);
    saveas(fig_u_ES,filename_string,'pdf');
    saveas(fig_u_ES,filename_string,'png');
end

fig_v_ES = figure('Name','Velocity v exact solution');
surf(dx, dy, v_exact, 'EdgeColor', 'none');
xlabel('x'); ylabel('y'); zlabel('v');
colorbar('Location','EastOutside');
view(0, 90);
axis equal;
xlim(x_axis_limits); ylim(y_axis_limits);
if save_figures == 1
    filename_string = sprintf('Bajko_Problem2_v_exact_solution_in_t=%d',t);
    saveas(fig_v_ES,filename_string,'pdf');
    saveas(fig_v_ES,filename_string,'png');
end

fig_p_ES = figure('Name','Pressure exact solution');
surf(dx, dy, p_exact, 'EdgeColor', 'none');
xlabel('x'); ylabel('y'); zlabel('p');
colorbar('Location','EastOutside');
view(0, 90);
axis equal;
xlim(x_axis_limits); ylim(y_axis_limits);
if save_figures == 1
    filename_string = sprintf('Bajko_Problem2_p_exact_solution_in_t=%d',t);
    saveas(fig_p_ES,filename_string,'pdf');
    saveas(fig_p_ES,filename_string,'png');
end