1 / 4

Object write down a discrte equation in the form

4. 3. Object write down a discrte equation in the form. 5. 1. 2. %Simple Point code clear all %store coefficents a=zeros(5,1); Vol_i=0; %CV area % Global coordinates x(1)=0; y(1)=0; x(2)=1; y(2)=0; x(3)=1; y(3)=1; x(4)=0; y(4)=1; x(5)=0.5; y(5)=0.5; %known values

alair
Download Presentation

Object write down a discrte equation in the form

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 4 3 Object write down a discrte equation in the form 5 1 2

  2. %Simple Point code clear all %store coefficents a=zeros(5,1); Vol_i=0; %CV area % Global coordinates x(1)=0; y(1)=0; x(2)=1; y(2)=0; x(3)=1; y(3)=1; x(4)=0; y(4)=1; x(5)=0.5; y(5)=0.5; %known values for tri=1:4 %loop on triangles %Local to global nodes L1=5; L2=tri; if tri<4 L3=tri+1; else L3=1; end xL(1)=x(L1); yL(1)=y(L1); xL(2)=x(L2); yL(2)=y(L2); xL(3)=x(L3); yL(3)=y(L3); %2Xelemnt area v=xL(2)*yL(3)-xL(3)*yL(2)... -xL(1)*yL(3)+xL(1)*yL(2)+yL(1)*xL(3)-yL(1)*xL(2); Vol_i=Vol_i+v/6; %contribution to CV volume Nx(1)=(yL(2)-yL(3))/v; %Nx=shape function Nx(2)=(yL(3)-yL(1))/v; Nx(3)=(yL(1)-yL(2))/v; Ny(1)=-(xL(2)-xL(3))/v; %Ny=shape function Ny(2)=-(xL(3)-xL(1))/v; Ny(3)=-(xL(1)-xL(2))/v; %Face 1 %directed lengths delx= [(xL(1)+xL(2)+xL(3))/3]-[(xL(1)+xL(2))/2]; dely= [(yL(1)+yL(2)+yL(3))/3]-[(yL(1)+yL(2))/2]; %point coeficient a(L1) = a(L1) - Nx(1) * dely + Ny(1) * delx; %note - sign %Neigbouring coeff a(L2)=a(L2)+ Nx(2) * dely - Ny(2) * delx; a(L3)=a(L3)+ Nx(3) * dely - Ny(3) * delx; %Face 2 delx= [(xL(1)+xL(3))/2]-[(xL(1)+xL(2)+xL(3))/3]; dely= [(yL(1)+yL(3))/2]-[(yL(1)+yL(2)+yL(3))/3]; %point coeficient a(L1) = a(L1) - Nx(1) * dely + Ny(1) * delx; %note - sign %Neigbouring coeff a(L2)=a(L2)+ Nx(2) * dely - Ny(2) * delx; a(L3)=a(L3)+ Nx(3) * dely - Ny(3) * delx; end

  3. Assembly using MATLAB unstructured data struture p= points 3 8 2 8 5 5 9 10 4 7 6 10 4 9 12 7 6 1 11 11 3 1 2 t= triangles Nodes N= size(p,2) Number of columns in p Elements Ntri=size(t,2) Number of columns in t tri=t’ transpose of t

  4. In element 1<=1 itri <= Ntri xL(1) = p(1,k1); %x-values of ele. vert. xL(2) = p(1,k2); xL(3) = p(1,k3); yL(1) = p(2,k1); %y-values of ele. vert. yL(2) = p(2,k2); yL(3) = p(2,k3); k1=t(3,itri) 3 Nx(1)= (yL(2)-yL(3))/(2*v); %Nx=shape function Nx(2)= (yL(3)-yL(1))/(2*v); Nx(3)= (yL(1)-yL(2))/(2*v); Ny(1)=-(xL(2)-xL(3))/(2*v); %Ny=shape function Ny(2)=-(xL(3)-xL(1))/(2*v); Ny(3)=-(xL(1)-xL(2))/(2*v); 2 1 k1=t(2,itri) k1=t(1,itri) element area Coefficient for Flow IN across face %Face 1 separates node K1 from node K2 delx(1)= (xL(1)+xL(2)+xL(3))/3-(xL(1)+xL(2))/2; dely(1)= (yL(1)+yL(2)+yL(3))/3-(yL(1)+yL(2))/2; %Face 2 separates node K2 from node K3 delx(2)= (xL(1)+xL(2)+xL(3))/3-(xL(2)+xL(3))/2; dely(2)= (yL(1)+yL(2)+yL(3))/3-(yL(2)+yL(3))/2; %Face 3 separates node K3 from node K1 delx(3)= (xL(1)+xL(2)+xL(3))/3-(xL(1)+xL(3))/2; dely(3)= (yL(1)+yL(2)+yL(3))/3-(yL(1)+yL(3))/2; %FL(i,j) is coef. asso. with kj for flow across face i FL(1,:)=Nx(:)*dely(1)-Ny(:)*delx(1); FL(2,:)=Nx(:)*dely(2)-Ny(:)*delx(2); FL(3,:)=Nx(:)*dely(3)-Ny(:)*delx(3); Contributions To ap(k1)=ap(k1)-FL(1,1)+FL(3,1); ap(k2)=ap(k2)-FL(2,2)+FL(1,2); ap(k3)=ap(k3)-FL(3,3)+FL(2,3); a(k1,k2)=a(k1,k2)+FL(1,2)-FL(3,2); a(k1,k3)=a(k1,k3)+FL(1,3)-FL(3,3); a(k2,k1)=a(k2,k1)+FL(2,1)-FL(1,1); a(k2,k3)=a(k2,k3)+FL(2,3)-FL(1,3); a(k3,k1)=a(k3,k1)+FL(3,1)-FL(2,1); a(k3,k2)=a(k3,k2)+FL(3,2)-FL(2,2);

More Related