62 lines
1.3 KiB
Matlab
62 lines
1.3 KiB
Matlab
function[mesh]=MeshGenerator2(LayerNum,NdNumPerLoop,InData)
|
|
% Define grid
|
|
% ...
|
|
for i=1:LayerNum*NdNumPerLoop
|
|
NodeNum(i)=InData(i,1);
|
|
NodeLoc(i,1)=InData(i,2);
|
|
NodeLoc(i,2)=InData(i,3);
|
|
NodeLoc(i,3)=InData(i,4);
|
|
Thick(i)=InData(i,5);
|
|
end
|
|
mesh=struct();
|
|
|
|
|
|
|
|
nx=ex+1; ny=ey+1;
|
|
mesh.ne=ex*ey; %number of elements
|
|
mesh.nn=nx*ny; %number of nodes
|
|
|
|
dx=a/ex; dy=b/ey;
|
|
|
|
[mesh.x,mesh.y]=meshgrid(0:dx:a,0:dy:b);
|
|
mesh.cordinates(:,1)=reshape(mesh.x',numel(mesh.x),1);%x coordinates
|
|
mesh.cordinates(:,2)=reshape(mesh.y',numel(mesh.y),1);%y coordinates
|
|
|
|
% side 1
|
|
mesh.lato1=1:nx;
|
|
% side 2
|
|
mesh.lato2=nx:nx:mesh.nn;
|
|
% side 3
|
|
mesh.lato3=mesh.nn:-1:mesh.nn-ex;
|
|
% side 4
|
|
mesh.lato4=mesh.nn-ex:-nx:1;
|
|
|
|
mesh.Nid=zeros(mesh.nn,4);% [node_id x y z]
|
|
mesh.Eid=zeros(mesh.ne,5);% [ele_id node1 node2 node3 node4]
|
|
|
|
for j=1:ny
|
|
for i=1:nx
|
|
mesh.Nid(i+nx*(j-1),:)=[i+nx*(j-1), (i-1)*dx, (j-1)*dy, 0];
|
|
end
|
|
end
|
|
|
|
%% Elements ID - 1n - right - up - left
|
|
for j=1:ey
|
|
for i=1:ex
|
|
mesh.Eid(i+ex*(j-1),:)=[i+ex*(j-1), i+nx*(j-1)...
|
|
i+nx*(j-1)+1 i+nx*(j-1)+nx+1 i+nx*(j-1)+nx];
|
|
end
|
|
end
|
|
|
|
figure
|
|
surf(mesh.x,mesh.y,zeros(size(mesh.x)));
|
|
hold on
|
|
axis equal
|
|
title('Undeformed Geometry');
|
|
|
|
|
|
for i=1:numel(mesh.x)
|
|
text(mesh.cordinates(i,1),mesh.cordinates(i,2),0,num2str(i));
|
|
end
|
|
|
|
return |