How to mesh a model with non rectangle element?
Afficher commentaires plus anciens
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.
Réponses (1)
KSSV
le 6 Nov 2018
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 commentaire
Khatereh Danaei
le 6 Nov 2018
Modifié(e) : Khatereh Danaei
le 6 Nov 2018
Catégories
En savoir plus sur Chemistry dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!