1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| function [S,T,RS,RT]=triangule_carre(m,n,ref_bord,ref_mat) % T= nombre des éléments du maillage, S= coordonnées des noeuds, m= nombre des éléments suivant x, n suivant y%
%initialisation
dx=50/m;
dy=50/n;
x=0:dx:50.;
y=0:dy:50.;
nbs=(m+1)*(n+1);
nbt=2*m*n;
RS=zeros(1,nbs);
RT=ref_mat*ones(1,nbt);
%definition des sommets
[X,Y]=meshgrid(x,y);
S=[reshape(X',nbs,1) reshape(Y',nbs,1)];
%definition de la numerotation des triangles
N1=[];N2=[];
mp=m+1;
for i=1:m
if(mod(i,2)==1) %i impair
N1=[N1 i i+1 mp+i i+1+mp i+mp i+1];
else %i pair
N1=[N1 i+1 i+1+mp i i+mp i i+1+mp];
end
end
N1=reshape(N1,3,2*m)';
mp=m+1;
for i=1:m
if(mod(i,2)==1) %i impair
N2=[N2 i+1 i+1+mp i i+mp i i+1+mp];
else %i pair
N2=[N2 i i+1 mp+i i+1+mp i+mp i+1];
end,
end,
N2=reshape(N2,3,2*m)';
T=[];
for j=1:n
if(mod(j,2)==1)
T=[T;N1+(j-1)*mp];
else
T=[T;N2+(j-1)*mp];
end
end
%reference des bords
RS(1:mp)=ref_bord(1);
RS(mp:mp:end)=ref_bord(2);
RS(n*mp+1:end)=ref_bord(3);
RS(1:mp:end)=ref_bord(4);
end |
Partager