How to mesh a model with non rectangle element?
조회 수: 3 (최근 30일)
이전 댓글 표시
hello every one, how can use this element for meshing in 3 direction x, y, z ? I wrote the code for one element but I don't know how fill the whole model with this element? thanks for your help and attention.
댓글 수: 0
답변 (1개)
KSSV
2018년 11월 6일
L = 1; % length
B = 1; % breadth
H = 1; % height
% Disctritze
NX = 5; % number of nodes along length
NY = 5; % number of nodes along breadth
NZ = 5 ; % number of nodes along height
%
x = linspace(0,L,NX) ;
y = linspace(0,B,NY) ;
z = linspace(0,H,NZ) ;
%
[X,Y,Z] = meshgrid(x,y,z) ;
%
nel = (NX-1)*(NY-1)*(NZ-1) ; % Total Number of elements
nnel = 8 ; % Number of nodes per element
%
nnode = NX*NY*NZ ; % Total Number of nodes
% To get the Nodal Connectivity Matrix
nodes = zeros(nel,nnel) ; % Initialize nodal connectivity matrix
count = 0 ;
for i = 1:NX-1
for j = 1:NY-1
for k = 1:NZ-1
count = count+1 ;
l = (k-1)*(NY)*(NX)+(j-1)*(NX)+i ;
nodes(count,:) = [l l+1 l+NX+1 l+NX............
l+(NY)*(NX) l+(NY)*(NX)+1 l+(NY)*(NX)+NX+1 l+(NY)*(NX)+NX];
end
end
end
%%To plot the grid
% Get the required for input Geometry
coordinates = [X(:) Y(:) Z(:)] ;
%
idnodesplot=[1 2 3 4 1 5 6 2 6 7 3 7 8 4 8 5 ];
N = length(idnodesplot) ;
X = zeros(N,nel) ;
Y = X ;
Z = X ;
for e=1:nel
idnodes=nodes(e,:);
X(:,e) = coordinates(idnodes(idnodesplot),1)' ;
Y(:,e) = coordinates(idnodes(idnodesplot),2)' ;
Z(:,e) = coordinates(idnodes(idnodesplot),3)' ;
end
set(gcf,'color','w')
fill3(X,Y,Z,'w','Edgecolor','r','FaceAlpha',0.) ;
set(gca,'XTick',[]) ; set(gca,'YTick',[]); set(gca,'ZTick',[]) ;
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!