close all
clear all
format long
% ***** read x
load x.dat
ni=length(x);

% ***** read y
load y.dat
nj=length(y);
%
%
viscos=1/950;

% load the file
% 
% Transformation: you don't need to look at this
load vect_uuvvwwz.dat
vectc=vect_uuvvwwz;
ntstep=vectc(1);
n=length(vectc);
nn=10;
iu=2:nn:n;
iv=3:nn:n;
ieps=4:nn:n;
iuu=5:nn:n;
ivv=6:nn:n;
iww=7:nn:n;
iuv=8:nn:n;
irk=9:nn:n;
ivis=10:nn:n;
ipksgs=11:nn:n;
u=vectc(iu)/ntstep;
v=vectc(iv)/ntstep;
eps=vectc(ieps)/ntstep;
uutot=vectc(iuu)/ntstep;
vv=vectc(ivv)/ntstep;
ww=vectc(iww)/ntstep;
uv=vectc(iuv)/ntstep;
rk=vectc(irk)/ntstep;
vis=vectc(ivis)/ntstep;
pksgs=vectc(ipksgs)/ntstep;
uu=uutot-u.^2;
uv=uv-u.*v;
for j=1:nj
for i=1:ni
   y_2d(i,j)=y(j);
   x_2d(i,j)=x(i);
end
end

% End of transformation

u_2d=reshape(u,nj,ni)';
v_2d=reshape(v,nj,ni)';
eps_2d=reshape(eps,nj,ni)';% eps_u
uu_2d=reshape(uu,nj,ni)';
vv_2d=reshape(vv,nj,ni)';
ww_2d=reshape(ww,nj,ni)';
uv_2d=reshape(uv,nj,ni)';
ksgs_2d=reshape(rk,nj,ni)'; % k_u
vis_2d=reshape(vis,nj,ni)'; % laminar + turbulent viscosity (nu + nu_u)
pksgs_2d=reshape(pksgs,nj,ni)'; %produktion term in k_u eq.

% compute the velocity gradients
[dudy_2d dudx_2d]=gradient(u_2d,y_2d',x_2d);

% The arrays have have the dimension (ni,nj). The first index
% represents moving in the $x_1$ direction. For example
%
%  u_2d(:,1):  nodes at the lower wall (low y)
%  u_2d(:,nj): nodes at the upper wall (high y)
%  u_2d(1,:):  nodes at the inlet (low x)
%  u_2d(ni,:): nodes at the outlet (high x)


%*************************
% plot uu vs. y
figure(1)
i=25; % x=1.175
plot(y,uu_2d(i,:).^0.5,'r--','linewidth',2)
hold
i=60; % x=2.925
plot(y,uu_2d(i,:).^0.5,'k-.','linewidth',2)
axis([0 2 0 4.5])
title('u2')
handle=gca;
set(handle,'fontsize',[20])
print uu_vs_y.ps  -depsc


%*************************
% plot uu vs. x
figure(2)
j=15; %y=0.032
plot(x,uu_2d(:,j).^0.5,'linewidth',2)
hold
j=30; %y=0.24
plot(x,uu_2d(:,j).^0.5,'r--','linewidth',2)
j=45; %y=1.35
plot(x,uu_2d(:,j).^0.5,'k-.','linewidth',2)
axis([0 3.2 0 4.5])
title('u2')
handle=gca;
set(handle,'fontsize',[20])
print uu_vs_x.ps  -depsc

