% Plots for Lid-driven cavity flow

clf;
colormap(mk_colmap);

subplot(221)
surf(XP,YP,P(NodeP(2:app.Ny+1,2:app.Nx+1)),'LineStyle','none') 
TT(1)=xlabel('x(m)');TT(2)=ylabel('y(m)');TT(3)=zlabel('T(^oC)');
TT(4)=title(sprintf('Pressure app.Nx=%g, app.Ny=%g',app.Nx,app.Ny));
formatplot([],gca,TT);view(2),colorbar,shading interp,

subplot(222)
tmp1 = 0.5*(u(Nodeu(2:app.Ny+1,1:app.Nx))+u(Nodeu(2:app.Ny+1,2:app.Nx+1)));
tmp2 = 0.5*(v(Nodev(2:app.Ny+1,2:app.Nx+1))+v(Nodev(1:app.Ny,2:app.Nx+1)));
quiver(XP(:),YP(:),(tmp1(:)),(tmp2(:)),'g') 
hold on
streamslice(XP,YP,tmp1,tmp2)
hold off
ylim([0 1]),xlim([0 1])
TT(1)=xlabel('x(m)');TT(2)=ylabel('y(m)');TT(3)=zlabel('T(^oC)');
TT(4)=title(sprintf('Velocity, time =%03.03g',T));
formatplot([],gca,TT);view(2)

subplot(223)
nid = length(ucentid);
if mod(app.Nx,2)
    tmp = (u([ucentid(1);ucentid(2:nid-1)+app.Ny;ucentid(nid)])+...
        u(ucentid))/2;
else
    tmp = u(ucentid);
end
plot(tmp,[1;YU(ucentid(2:end-1)-Nbcs);0],'x-');
ylim([0 1])
ylabel('y')
xlabel('U velocity')
title('Vertical centerline u velocity')

subplot(224)
nid=length(vcentid);
if mod(app.Nx,2)
    tmp = v(vcentid);
else
    tmp =[0; 0.5*(v(5+(app.Ny-1)*(app.Nx/2-1):4+(app.Ny-1)*(app.Nx)/2)+...
            v(5+(app.Ny-1)*(app.Nx/2):4+(app.Ny-1)*(app.Nx/2+1)));0];
end
plot(tmp,[1;YV(vcentid(2:end-1)-Nbcs);0],'o-');
ylabel('y')
xlabel('V velocity')
ylim([0 1])
title('Vertical centerline v velocity')

drawnow;
