Filter löschen
Filter löschen

How to mesh a model with non rectangle element?

3 Ansichten (letzte 30 Tage)
Khatereh Danaei
Khatereh Danaei am 6 Nov. 2018
Bearbeitet: Khatereh Danaei am 6 Nov. 2018
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.

Antworten (1)

KSSV
KSSV am 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 Kommentar
Khatereh Danaei
Khatereh Danaei am 6 Nov. 2018
Bearbeitet: Khatereh Danaei am 6 Nov. 2018
Hi dear, thanks for your help and attention. This cod is for rectangle element. I want fill the model with nonrectangle element. I wrote cod for one nonrectangle element that you can see at the follow also I attach shape of element and formulation for calculable magnetic in the 8 node of the element. I really appreciate you.
clc
clear all;
close all;
T=2000;
%% location of 8 node of element.
Xl=[0 1 0 1 -0.2 1.2 -0.2 1.2];Xl=(Xl.*2)+2;
Yl=[0 0 1 1 0 0 1 1];Yl=(Yl.*2)+2;
Zl=[0 0 0 0 1 1 1 1];Zl=(Zl.*2)+2;
plot3(Xl,Yl,Zl,'O')
% grid on
%%location of center of element.
etac=(((Xl(1)+Xl(2))./2)+((Xl(3)+Xl(4))./2)+((Xl(5)+Xl(6))./2)+((Xl(7)+Xl(8))./2)./4);
betac=(((Yl(1)+Yl(2))./2)+((Yl(3)+Yl(4))./2)+((Yl(5)+Yl(6))./2)+((Yl(7)+Yl(8))./2)./4);
zetac=(((Zl(1)+Zl(2))./2)+((Zl(3)+Zl(4))./2)+((Zl(5)+Zl(6))./2)+((Zl(7)+Zl(8))./2)./4);
%%length of element
for l=1:length(Xl)
if etac>Xl(l)
etaq(l)=etac-Xl(l);
elseif etac<Xl(l)
etaq(l)=Xl(l)-etac;
end
end
for l=1:length(Yl)
if betac>Yl(l)
betaq(l)=betac-Yl(l);
elseif betac<Yl(l)
betaq(l)=Yl(l)-betac;
end
end
for l=1:length(Zl)
if zetac>Zl(l)
zetaq(l)=zetac-Zl(l);
elseif betac<Zl(l)
zetaq(l)=Zl(l)-zetac;
end
end
%plot(X,Z,'o',E,B,'+')
%% according the table in the article
etal=[-1 1 -1 1 -1 1 -1 1];
betal=[-1 -1 1 1 -1 -1 1 1];
zetal=[-1 -1 -1 -1 1 1 1 1];
syms eta beta zeta Fpqr Aij
for l=1:8
Nl(l)=(1/8).*(1+(etal(l).*eta)).*(1+(betal(l).*beta)).*(1+(zetal(l).*zeta));
end
X=0;
for l=1:8
Xf=Nl(l).*Xl(l);
X=X+Xf;
end
Y=0;
for l=1:8
Yf=Nl(l).*Yl(l);
Y=Y+Yf;
end
Z=0;
for l=1:8
Zf=Nl(l).*Zl(l);
Z=Z+Zf;
end
ss=[diff(X,eta) diff(Y,eta) diff(Z,eta);diff(X,beta) diff(Y,beta) diff(Z,beta);diff(X,zeta) diff(Y,zeta) diff(Z,zeta)];
S=det(ss);
Fpqr=((Z/(((X.^2)+(Y.^2)+(Z.^2)).^(3./2))).*S);
Aij=T./(4.*pi).*Fpqr;
Aij1=subs (Aij,beta,betaq);
Aij2=subs (Aij1,eta,etaq);
for l=1:length(Xl)
Aij3(l)=double(subs (Aij2(l),zeta,zetaq(l)))
end

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by