clear all
close all


directory = '../DockingMooring_06/Results_d60_c1_w15_Hs4_Tp9';

env = LoadEnvironment(directory);
MooringRiser = LoadCableResults(directory,'SURFACE_MOORING');
BUOY = LoadRigidBodyResults(directory,'Buoy');

WindAndWater = LoadWindAndWaterConditions(directory);


MooringRiserResults = ParseCableResults(MooringRiser);

WindAndWaterResults = ParseWindAndWaterResults(WindAndWater,env.WaterDepth);


figure('Position',[  227    441   1569    998],'paperorientation','landscape','papersize',[17 11]);
ah1 = subplot(3,7,[1,8,15]);

lh = plot(WindAndWaterResults.MeanCurrentX,-WindAndWaterResults.CurrentHeights,'k-');
hold all;
set(lh,'linewidth',3);
lh = plot(WindAndWaterResults.MeanWindX/10,WindAndWaterResults.WindHeights,'b-');
set(lh,'linewidth',2);



plot(WindAndWaterResults.CurrentX,-WindAndWaterResults.CurrentHeights)
plot(WindAndWaterResults.WindX/10,WindAndWaterResults.WindHeights)

lh = plot(WindAndWaterResults.MeanCurrentX,-WindAndWaterResults.CurrentHeights,'k-');
set(lh,'linewidth',3);
lh = plot(WindAndWaterResults.MeanWindX/10,WindAndWaterResults.WindHeights,'b-');
set(lh,'linewidth',2);
legend('Mean Water X-Vel','Mean Wind X-Vel (/10)');
xlabel('(m/s)');
ylabel('(m)');
grid on
title('Horiz. Water Speed')

ah2 = subplot(3,7,[2,3,9,10,16,17]);
plot(MooringRiserResults.X',-MooringRiserResults.Z');
hold all
set(gca,'ColorOrderIndex',1);

lh = plot(MooringRiserResults.MeanX',-MooringRiserResults.MeanZ','-k');
set(lh,'linewidth',3);



xlabel('m');
ylabel('m');
grid on
hold on
title('Mooring Location');

%Match Current ylim to mooring plot
set(ah1,'ylim',get(ah2,'ylim'));


ah3 = subplot(3,7,[4,5])
plot(WindAndWaterResults.t,WindAndWaterResults.SeaHeightAtOrigin);
grid on
xlabel('time (s)');
ylabel('Sea Height at Origin (m)');
title('Sea Height at Origin');

ah4 = subplot(3,7,[11 12])
plot(MooringRiserResults.ElementTensions_s/4.45,100*MooringRiserResults.epsilon);
grid on
xlabel('Tension (lbs)');
ylabel('Strain (%)');
title('Strain Versus Tension');


ah4 = subplot(3,7,[18 19])

plot((MooringRiserResults.Unstretched_Node_s(:,end)-MooringRiserResults.Unstretched_Node_s)',MooringRiserResults.NodeTensions_s'/4.45);
hold all;
set(gca,'ColorOrderIndex',1);
%plot((MooringRiserResults.Unstretched_Node_s(:,end)+HoseTetherResults.Unstretched_Node_s(:,end)-HoseTetherResults.Unstretched_Node_s)',HoseTetherResults.NodeTensions_s'/4.45);
grid on
xlabel('Distance from Anchor along unstreteched mooring (m)')
ylabel('Tension (lbs)');
title('Mooring Tension Snapshots');

ah5 = subplot(3,7,[6 7]);
plot(MooringRiserResults.t,-MooringRiserResults.Node0HorizForce/4.45);
hold all
plot(MooringRiserResults.t,-MooringRiserResults.Node0VertForce/4.45);
legend('Horiz Force','Vert Force');
xlabel('time (s)');
ylabel('(lbs)');
grid on
title('Force on Buoy');

ah6 = subplot(3,7,[13 14]);
plot(MooringRiserResults.t,MooringRiserResults.submergenceProbe/.0254+60);
legend('Freeboard');
xlabel('time (s)');
ylabel('(in)');
grid on
%title('Force on Anchor');

ah6 = subplot(3,7,[20 21]);
plot(MooringRiserResults.t,MooringRiserResults.NodeNHorizForce/4.45);
hold all
plot(MooringRiserResults.t,-MooringRiserResults.NodeNVertForce/4.45);
legend('Horiz Force','Vert Force');
xlabel('time (s)');
ylabel('(lbs)');
grid on
title('Force on Anchor');

print([directory 'ResultsSummary.pdf'],'-landscape');

save([directory 'ResultsSummary.mat'],'-mat7-binary');


