Mesh Simulation
clc
clear
M=8;
N=8;
L=8;
LX=1;
LY=1;
LZ=1;
dx=LX/M;
dy=LY/N;
dz=LZ/L;
a(1)=0;
for p=1:12;
for i=1:M;
for j=1:N;
for k=1:L;
x(i,j,k,p)=i*dx;
y0(i,j,k,p)=j*dy;
a(p+1)=a(p)+1;
y(i,j,k,p)=a(p+1)*((x(i,j,k,p))^2)+y0(i,j,k,p);
z(i,j,k,p)=k*dz;
end
end
end
end
for p=1:12;
figure(p)
for i=1:M;
for j=1:N;
for k=1:L;
plot3(x(i,j,k,p),y(i,j,k,p),z(i,j,k,p),'*r')
hold on
grid on
xlabel('x')
ylabel('y')
zlabel('z')
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (i<M)
xx=[ x(i+1,j,k,p) x(i,j,k,p) ];
yy=[ y(i+1,j,k,p) y(i,j,k,p) ];
zz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xx,yy,zz);
elseif (i==M)
xx=[ x(i,j,k,p) x(i,j,k,p) ];
yy=[ y(i,j,k,p) y(i,j,k,p) ];
zz=[ z(i,j,k,p) z(i,j,k,p)];
f=line(xx,yy,zz);
end
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (j<N)
xxx=[ x(i,j+1,k,p) x(i,j,k,p) ];
yyy=[ y(i,j+1,k,p) y(i,j,k,p) ];
zzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxx,yyy,zzz);
elseif (j==N)
xxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxx,yyy,zzz);
end
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (k<L)
xxxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzzz=[ z(i,j,k+1,p) z(i,j,k,p) ];
f=line(xxxx,yyyy,zzzz);
elseif (k==L)
xxxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxxx,yyyy,zzzz);
end
end
end
end
end
pause(10)
close all
clear
M=8;
N=8;
L=8;
LX=1;
LY=1;
LZ=1;
dx=LX/M;
dy=LY/N;
dz=LZ/L;
a(1)=0;
for p=1:12;
for i=1:M;
for j=1:N;
for k=1:L;
x(i,j,k,p)=i*dx;
y0(i,j,k,p)=j*dy;
a(p+1)=a(p)+1;
y(i,j,k,p)=a(p+1)*((x(i,j,k,p))^2)+y0(i,j,k,p);
z(i,j,k,p)=k*dz;
end
end
end
end
for p=1:12;
figure(p)
for i=1:M;
for j=1:N;
for k=1:L;
plot3(x(i,j,k,p),y(i,j,k,p),z(i,j,k,p),'*r')
hold on
grid on
xlabel('x')
ylabel('y')
zlabel('z')
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (i<M)
xx=[ x(i+1,j,k,p) x(i,j,k,p) ];
yy=[ y(i+1,j,k,p) y(i,j,k,p) ];
zz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xx,yy,zz);
elseif (i==M)
xx=[ x(i,j,k,p) x(i,j,k,p) ];
yy=[ y(i,j,k,p) y(i,j,k,p) ];
zz=[ z(i,j,k,p) z(i,j,k,p)];
f=line(xx,yy,zz);
end
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (j<N)
xxx=[ x(i,j+1,k,p) x(i,j,k,p) ];
yyy=[ y(i,j+1,k,p) y(i,j,k,p) ];
zzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxx,yyy,zzz);
elseif (j==N)
xxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxx,yyy,zzz);
end
end
end
end
end
for p=1:12;
for k=1:L;
for i=1:M;
for j=1:N;
if (k<L)
xxxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzzz=[ z(i,j,k+1,p) z(i,j,k,p) ];
f=line(xxxx,yyyy,zzzz);
elseif (k==L)
xxxx=[ x(i,j,k,p) x(i,j,k,p) ];
yyyy=[ y(i,j,k,p) y(i,j,k,p) ];
zzzz=[ z(i,j,k,p) z(i,j,k,p) ];
f=line(xxxx,yyyy,zzzz);
end
end
end
end
end
pause(10)
close all
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com