1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| clear, close all; clc,
%Mold dimensions and mesh elements
Lx = 0.600; Nx = 60; hx = Lx / (Nx);
Ly = 0.300; Ny = 30; hy = Ly / (Ny);
%%Loading A text file containing 8 columns: number of the node, node coordinates
%%(x,y, and z respectively), pressure, flow rate, time (8th column) and fill factor in all
%%the nodes
B1 = load('case_99_8.txt'); T1 = B1(:,7);
%Rearranging the vector which contains the time at each node to a matrix
%with the mold dimensions
for j = 1:Ny+1
for i = 1:Nx+1
k = (j-1)*(Nx+1) + i;
TIME1(i,j) = T1(k);
end
end
TIME1_physical = TIME1'; TIME1_physical = TIME1_physical(end:-1:1,:);
TIME1_physical(TIME1_physical==0)=max(max(TIME1_physical));
%Meshgrid
x= 0:hx:Lx ; y= Ly:-hy:0;
[X,Y]= meshgrid(x, y);
%Plotting contours
figure(1)
colormap('jet');
[C, H]= contour(X,Y,TIME1_physical); clabel(C,H);
title('Flow Front Contours for a partial Race-tracking scenario'), xlabel('x [m]')
ylabel('y [m]'), grid
hold on
set(gca,'xcolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
set(gca,'ycolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
saveas(gcf,'1.pdf')
%Storing in Ni the numbers of the levels of all the curves:
Ni=get(H,'levellist'); %Niveau
NC=Ni(end);% Choix du niveau
%Plotting the selected contour level(Putting the selected level in Ni in the form [x x]:
figure(2)
[C1, H1]=contour(X,Y,TIME1_physical,[400 400]); %clabel(C1,H1);%%%%%%%%%%%%%%%%%%%%%%% Choix du niveau 500
title('SCENARIO 12 FLOW FRONT CURVE'), xlabel('x [m]')
ylabel('y [m]'), grid
set(gca,'xcolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
set(gca,'ycolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
saveas(gcf,'2.pdf')
% C and C1 contain erroneous values.To calculate the distance they must be eliminated.
[I,J,V] = find(C1>1);% Searching for erroneous values
if length(J)>0
deb=J(end)+1;% Beginning of calculations
else
deb=2;
end
grid
set(H1,'Color','k')
axis([0 Lx 0 Ly])
% Plotting the discretization of the chosen contour
figure(3)
plot(C1(1,deb:end),C1(2,deb:end),'.r');% Plotting the selected level points
title('Discretization of the chosen contour'), xlabel('x [m]')
ylabel('y [m]'), grid
hold on
plot(0.6,0.15,'.k','MarkerSize',23)% The vent node
grid
axis([0 Lx 0 Ly])
hold off
set(gca,'xcolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
set(gca,'ycolor','k','LineWidth',2,'FontSize',14,'FontWeight','bold')
saveas(gcf,'3.pdf')
% Preparation of the indices to calculate the distances:
i=deb:length(C1);% Indice |
Partager