%this script is for handling the pressure information that is
%exported from tecplot.  It will output a file that can be read
%directly into tecplot to generate pressure contours on the surface
%of the ship.
clear all;clc;

% alpha=input('angle of attack (00,10,20,30):\n');
% dataFile=strcat('alpha',num2str(alpha),'.dat');
fid1=fopen('xSlices.dat');
% fid1=fopen(dataFile);
nodes=textscan(fid1,'Nodes=%f, Elements=%f','Headerlines',8)
junk=textscan(fid1,'%s',3);
connections=textscan(fid1,'FACENEIGHBORCONNECTIONS=%f')
junk=textscan(fid1,'%s',8)
data(1,:)=textscan(fid1,'%f %f %f %f %f %f',nodes{1});

frames=80;  %there are 80 frames in each simulation

for i=2:frames
	junk=textscan(fid1,'%f %f %f %f',nodes{2});
	junk=textscan(fid1,'%f %f %f',connections{1});
	junk=textscan(fid1,'%s',18);
	data(i,:)=textscan(fid1,'%f %f %f %f %f %f',nodes{1});
end
fclose(fid1);

[x y z phs f]=data{1,1:5}; %phs is hydrostatic pressure
td=30; %fully developed time (frame number)
for i=1:frames
    p(i,:)=data{i,4}; %pressure
    pd(i,:)=p(i,:)-phs'; %dynamic pressure
end
pmean=mean(p(td:frames,:),1);
pdmean=mean(pd(td:frames,:),1);

% mov(x,y,z,pd); %movie of contours of dynamic pressure.
% plotSingle(x,y,z,pdmean); %plot of pressure zeroed with respect to
                           %hydrostatic pressure.
% plotSlices(x,y,z,pd,f);cl
% plotSingleSlice(x,y,z,pdmean,f);
angle=[0 10 20 30];
% bodyCoordinates(x,y,z,pd,-.06,angle);