clc

clear all
%Parameter input
Mxpoiv=625;%
Mxpoip=169;%
Mxele=288;%
Mxfree=1;%
Mxneq=2*Mxpoiv+Mxpoip;%% Number of equation in system
Npoiv=625;% %Number nodes of velocity components
Npoip=169;% %Number nodes of pressure
Nelem=288;% Number of elements
Reynolds number (density*velocity*lenght/viscosity)
den=1;%
vis=0.01;%
%Artificial parameter
betha=8;%
%Matrix dimensions
Uvel=zeros(Mxpoiv,1);%
Vvel=zeros(Mxpoiv,1);%
Pres=zeros(Mxpoiv,1);%
SysM=zeros(Mxneq,Mxneq);% %size of Mass matrix
SysK=zeros(Mxneq,Mxneq);% size of stiffness matrix System
SysR=zeros(Mxneq,1);%
SysN=zeros(Mxneq,1);% size of force matrix system
Sol=zeros(Mxneq,1);% size of result solution
Dsol=zeros(Mxneq,1);% size of result solution
nodes=zeros(Mxele,6);%
nodesf=zeros(Mxfree,4);%
Ibcu=zeros(Mxpoiv,1);% number of boundary for U
Ibcv=zeros(Mxpoiv,1);% number of boundary for V
Ibcp=zeros(Mxpoiv,1);% number of boundary for P
deltt=0.1;% time step size for transient analysis
stime=0.0;% initial time
ftime=0.0005;% termination time
ntime=fix((ftime-stime)/deltt);% number of time increment
%Read input file (element connectivity)
fid = fopen(’Mesh288elements.txt’, ’r’);%
data1 = textscan (fid, ’
nodes=[data1{1} data1{2} data1{3} data1{4} data1{5} data1{6} ];%
Read input file ( Node co-ordinates)
fid = fopen(’Meshnodes625.txt’, ’r’);%
data2 = textscan(fid, ’
X1=data2{1} ;%

’.Y1=data2{2} .2 Loop for number of equations Neq=2*Npoiv+Npoip.nodes.r’.den. ’r’).% Plot mesh figure(1) clf plot(X1.vis.1.Y1).% end for i=1:Npoip loop for pressure .j)=0.4 Initial guess value input for i=1:Npoiv %loop for velocity components Sol(i)=0.% %B.% %B.% end %Loop for initilize stiffness matrix for i=1:Neq for j=1:Neq SysK(i.10) hold on tri=nodes.SysM).% Ibcp=data1{3} .j)=0.txt’. ’ Ibcu=data1{1} .% Uvel=data1{4} .% Sol(i+Npoiv)=0.% end end %Loop for initilize mass matrix for i=1:Neq for j=1:Neq SysM(i.0356.’MarkerSize’.gcoord.Nelem.1.% %Loop for initilize force vector for i=1:Neq SysR(i)=0.% triplot(tri.% end end %B.1.X1.% gcoord=[X1 Y1].Y1.% Ibcv=data1{2} .% data1 = textscan(fid.% %Boundary condition fid = fopen(’625BC.% Vvel=data1{5} .00032272.% Pres=data1{6} .3 Mass matrix construction [SysM]=TRInew1(Npoiv.

% semilogy(time.SysK.den.1).Neq.% %Backward different scheme SysN=deltt*SysR+SysM*Sol.% Psol(i.% for it=1:ntime iteration in each time plane for iter=1:100 number of iterations %Newton-Raphson Non-linear matrix construction [SysK.Ibcu.Npoip.it+1)=Sol(2*Npoiv+i).1.vis.% break.% %Solve equations Sol=inv(SysK)*SysN %iteration checking for i=1:Npoip Psol(i.it)=Sol(2*Npoiv+i).it))/deltt.% check=zeros(ntime.nodes.SysN.Neq.% end Check(it.Sol(i+Npoiv+Npoiv)=0.% if(abs(check(it))¡1e-6) fprintf(’Pressure converged in iterations’).1.% check(it)=abs(1/betha*sum(it)).Npoip.% .Uvel.1). SysN]=ApplyBC55(Npoiv.Nfree.% end %B. gcoord.SysR.Ibcv.% end %B.1)=check(it).Nelem.SysR]=TRI(Npoiv. SysK.998.it+1)-Psol(i.5 Numerical programming codes ”AC Backward Newton-Raphson Method” SysK=SysM+deltt*SysK.% %apply boundary condition call ”ApplyBC55” [SysK.Pres).% end Ntime=it.6 Output %plot the history of convergence figure(2) time=0:deltt:Ntime*deltt.’-’).Ibcp.% end Iteration=iter end Ntime=it end %Convergence Checking for it=1:ntime for i=1:Npoip sum(it)=sum(it)+(Psol(i.% sum=zeros(ntime.Sol).1)).Vvel.(Check(:.

% %Set up matrix [A] for i=1:6 for j=1:6 A(i.SysM) A=zeros(6. ymax .%G=zeros(3. v.delta ]. u.% u=Uvelocity’.6).% hold on xmin = min ( x ).3). ’r’ ).%M22=zeros(6.% end . [ ymin .%Mele=zeros(15.gcoord.xmin. y(k).05 * max ( xmax .% ymin = min ( y ).den.nodes.ymax + delta.% plot ( x(k).%B=zeros(6.6). ymin . scale.% delta = 0. y.% ymax = max ( y ). y ).%C=zeros(6.1 Mass matrix Coefficient Function ”TRInew1” function [SysM]=TRInew1(Npoiv.% scale=2.xmin .% Vvelocity(i)=Sol(Npoiv+i).xmax + delta.% figure(3) quiver ( x.% axis equal hold on k = convhull ( x.%M33=zeros(3.% hold off %B.delta. ’b’ ).delta ].% plot ( [ xmin .% M11=zeros(6.15). ’w’ ).Nelem.3).% y=Y1.3).ymax + delta.xmax + delta.% Rele=zeros(15.% end for i=1:Npoip Pressure(i)=Sol(i+2*Npoiv).% v=Vvelocity’.xlabel(’Time’) ylabel(’Pressure convergence’) title(’Convergence history’) %Print output for i=1:Npoiv Uvelocity(i)=Sol(i).1).vis.6).% end Velocity=[Uvelocity’ Vvelocity’] Pressure=Pressure’ %plot velocity vector x=X1.delta.j)=0.3).% xmax = max ( x ).ymin ).ymin .2 Sub programming ”Functions” %B. xmin .delta.delta.2.

% C(5.% NN=nodes(iel.% for i=1:6 for j=1:6 D(j.% B(6.3)=c2.% D(2.% y2=gcoord(JJ.%A(5.% G(1.2)=Fac.% C(1.% Fac2=2*Fac.j).%A(1.1).% A(3.% Area=0.%B(5.% b2=(y3-y1)/Area2.1)=c3.% c2=(x1-x3)/Area2.2)=2*b2.% JJ=nodes(iel.% D(1.1)=1.% KK=nodes(iel.1)=2*b1.%A(3.5*((x2*y3)+(x1*y2)+(x3*y1)-(x2*y1)-(x1*y3)-(x3*y2)).j)=0.1)=b2.2)=1.%A(1.6)=-1.3)=1.%B(6.% G(3.6)=2.% D(3.% b3=(y1-y2)/Area2.% LL=nodes(iel.6)=3.% D(1.% D(3.%B(2.%A(2.% C(5.% D(5.4)=-1.% MM=nodes(iel.4)=1.1)=b3.%A(2.% G(3.% end end B(1.2)=12.2).2)=Fac2.% G(2.5)=-1.6)=1.% A(6.4)=3.1).% Area2=2*Area.5)=-1.% B(5.%A(4.% Anew=vis/den.3)=Fac.5)=3.3).% C(3.% b1=(y2-y3)/Area2.% D(4.% D(3.% C(2.% x3=gcoord(KK.5).% C(4.1)=c2.% %Set up mass matrix D(1.% Fac=Area/12.% D(2.% G(1.% D(1.3)=b1.% betha=8.1).2)=2*c2.5)=1.5)=3.% C(4.6)=4.3)=c1.% D(2.% %Compute matrix [B] [C] and [G] for i=1:6 for j=1:3 B(i.2).%A(3.5)=4.%% kinematic viscosity for iel=1:Nelem %loop for the total number of elements II=nodes(iel.%A(2.1)=2*c1.% y3=gcoord(KK.6)=3.2)=2.% D(4.3)=Fac2.% D(4.6)=1.3)=2.6).% D(1.2).1)=Fac.2)=c1.4)=3.% c1=(x3-x2)/Area2.% y1=gcoord(II.2)=c3.end A(1.% G(2.% x2=gcoord(JJ.% D(2.% D(6.5)=2.3)=b2.% D(1.2)=b3.1).% x1=gcoord(II.% G(1.% D(2.1)=Fac2.% B(4.1)=12.2)=b1.% D(5.% C(i.% B(4.4).% .4)=2.1)=Fac.3)=Fac.% c3=(x2-x1)/Area2.6)=-1.2).3)=12.6)=1.4)=4.5)=1.% D(3.3)=2*c3.2)=Fac.% G(3.3)=2*b3.j)=0.i)=D(i.% C(6.4)=-1.% G(2.% B(3.% C(6.3)=2.

2.% %Then the matrix (15x15) on LHS is for i=1:15 for j=1:15 Mele(i.j)=0.nodes.end end M11=2*Area/360*den*A*D*A’.% k=i+6.j+6)=M22(i.% end end for i=1:3 for j=1:3 Mele(i+12.Npoiv) %Contribution of coeficients assocoated with u.% SysM(KK.l).% M33=G/betha.% M22=2*Area/360*den*A*D*A’.% JJ=nodes(iel.% SysM(KK.LL)+Mele(k.% SysM(II.% LL=Npoiv+JJ.LL)=SysM(II.% end end %Contribution of coeficients assocoated with P pressure for i=1:3 for j=1:3 .v velocities for i=1:6 for j=1:6 II=nodes(iel.SysM.JJ)+Mele(k.j).j).JJ)=SysM(KK.j).% l=j+6.j).JJ)+Mele(i.j).% KK=Npoiv+II.SysM.% Mele(i+6.% SysM(II.nodes.Npoiv).2 Assembly to Global mass matrix function ”ASSEMBLEnew1” function [SysM]=ASSEMBLEnew1(iel.Mele.LL)+Mele(i.Mele.j).JJ)=SysM(II.i).j)=M11(i.% end end %Assembly Global mass matrix [SysM]=ASSEMBLEnew1(iel.j+12)=M33(i.% end %B.l).LL)=SysM(KK.% end end %Final local mass matrix for i=1:6 for j=1:6 Mele(i.

%B=zeros(6.%Aly=zeros(6.6).% Uele=zeros(6.% k=i+12.6).%Vele=zeros(6.%FY=zeros(6.5)=4.% ABGYVG=zeros(6.% NN=nodes(iel.1).4)=-1.%C=zeros(6.% y3=gcoord(KK.i).% A=zeros(6.% Qx=zeros(3.3 Local stiffness coefficient matrix function ”TRI” function [SysK.1).% A(6.6.1).% %Set up matrix [A] for i=1:6 for j=1:6 A(i.LL)=SysM(KK.% b2=(y3-y1)/Area2.3).6).SysR]=TRI(Npoiv.% A(2.den.5)=-1.LL)=SysM(II.% Area=0.% Area2=2*Area.6).3).6).6)=-1.6)=4.15).1)=1.6).6).3).% KK=nodes(iel.%AGBYVG=zeros(6.2).%Syx=zeros(6.% A(4.6).6).2).Sol).%Syy=zeros(6.%G=zeros(3.% Sxx=zeros(6.% A(1.5).6).5*((x2*y3)+(x1*y2)+(x3*y1)-(x2*y1)-(x1*y3)-(x3*y2)).%Pele=zeros(3.%Gyy=zeros(6.j)=0.1).%AGBXUG=zeros(6.%ABGYUG=zeros(6.3).5)=-1.% SysM(KK.1).SysK.3)=1.% SysM(II.%Alx=zeros(6.% A(5.% A(3.% b1=(y2-y3)/Area2.6).% Akele=zeros(15.% Gxx=zeros(6.%ABGXVG=zeros(6.SysR.% x3=gcoord(KK.% y2=gcoord(JJ.1).l).2)=1.6).6).l).1).% ABGXUG=zeros(6.% y1=gcoord(II.% LL=2*Npoiv+JJ.4)=4.%FX=zeros(6.%Qy=zeros(3.6). gcoord.LL)+Mele(k.% end end A(1.2).6)=-1.Npoip.% x2=gcoord(JJ.j).1).3).% A(3.3).vis.6).1).% FI=zeros(3.2).% LL=nodes(iel.%Rele=zeros(15.% .Neq.3).% x1=gcoord(II.LL)+Mele(i.% JJ=nodes(iel.% end end %B.% A(2.4).1).% KK=2*Npoiv+II.II=nodes(iel.%Qyt=zeros(6.%Sxy=zeros(6.6).6).%F=zeros(6.% MM=nodes(iel.4)=-1.1).2.% A(3.% l=j+12.% JJ=nodes(iel.%Qxt=zeros(6.6).% A(1.Nelem.% Anew=vis/den.% for iel=1:Nelem %loop for the total number of elements II=nodes(iel.% A(2.

% B(6.% Fac2=2*Fac.j)=0.% end end B(1.% G(2.3)=F12.2.% B(4.1)=F4.% C(4.2)=F6.2)=F4.1)=F12.% G(1.% F(3.6.2)=F12.2)=c1.% F(4.1)=Fac.1)=F12.% F(1.% B(5.% F(1.2)=F4.2)=b1.% F(1.1)=F12.% F(1.% F(1.5.5.3.5.1)=F12.% G(1.% F(2.3)=Fac.% F(6.2).5.6.3)=F4.6.% F(1.% F(4.1.% F(2.1)=F12.b3=(y1-y2)/Area2.% F(5.1)=2*c1.1)=F24.3)=Fac2.j)=0.2)=F4.j.% F4=Factor*4.% F(4.2)=2*c2.2)=F12.% F(4.% c2=(x1-x3)/Area2.% F(4.2)=Fac2.% G(3.% F(3.2)=Fac.% end end F(1.% F(5.% %Set up matrix [F] Factor=2*Area/5040.3.% F(5.% c3=(x2-x1)/Area2.1)=F4.4.2)=F24.% F(3.3)=c1.1.2)=F12.2)=F4.1)=b2.3)=b2.1)=2*b1.4.2)=F6.% Compute matrix [B] [C] and [G] for i=1:6 for j=1:3 B(i.4.6.1)=F4.4.1)=F4.1)=c3.% G(2.% F(2.5.3.1)=F24.6.2)=Fac.% %Set up [G] matrix Fac=Area/12.3)=2*c3.% F(3.2.2)=F12.% F(1.2)=F24.1)=F4.6.% C(6.1)=Fac2.2.% F(2.% F(2.% F(1.% F(1.% F(4.3)=2*b3.% F(5.% F(2.2)=F24.% F(2.2)=F6.1)=F6.% F(1.% F(1.% G(3.6.1)=F4.% G(1.1)=Fac.6.3.% C(5.3.% F(2.% C(6.6.2.4.% F24=Factor*24.5.% B(2.4.1).2)=c3.% C(4.% F(3.i.% .1)=c2.% F(3.2)=F12.1)=F6.4.5.2)=F4.j.3)=c2.3)=F4.% F12=Factor*12.% F(1.2)=F24.% F(6.% c1=(x3-x2)/Area2.1)=F6.1)=F24.% B(5.2)=F120.2)=F6.% G(3.1.% end end F(1.6.6.6.2.% C(5.1)=F120.4.2)=F12.2)=b3.% C(2.1)=F12.% B(3.3)=F24.% for i=1:6 for j=1:6 F(j.5.5.% F(1.4.% F(3.% F(3.% F(2.3)=b1.% F(2.1)=F(i.% C(3.% for i=1:6 for j=1:6 F(j.% F6=Factor*6.3)=Fac.3.% B(6.1)=F6.% F120=Factor*120.% C(i.2)=F4.% G(2.1)=b3.% F(1.2)=2*b2.3.i.2)=F(i.% C(1.5.1)=F24.% B(4.

3)=F24.% K22=0.j)*A(IB.% Sxy(IA.% Vele(1)=Sol(II+Npoiv).3)=F4.% F(2.F(1.3)=F12.% F(5.k).5.% Uele(5)=Sol(MM).3)=F12.% F(4.l)*C(l.5.% F(6.k).3)=F4.6.% .% Pele(1)=Sol(II+Npoiv+Npoiv).% F(2.6.% F(3.5.i)*C(i.3)=F120.j)*A(IB.% Vele(5)=Sol(MM+Npoiv).% F(1.% for i=1:6 for j=1:3 for k=1:3 for l=1:6 K11=K11+A(IA.% end end end end Sxx(IA.% K21=K21+A(IA.% Vele(4)=Sol(LL+Npoiv).IB)=Anew*K12.3)=F4.% F(4.i)*B(i.l)*C(l.4.% F(2.2.% end end %Extract element nodal u v and p Uele(1)=Sol(II).4.% Uele(4)=Sol(LL).% K21=0.3)=F12.3)=F6.5.j.% F(2.i)*C(i.% K12=K12+A(IA.l)*B(l.% Pele(3)=Sol(KK+Npoiv+Npoiv).3)=F6.% F(5.4.% Uele(6)=Sol(NN).i)*B(i.k).% Pele(2)=Sol(JJ+Npoiv+Npoiv).k)*G(j.% K12=0.i.% Vele(6)=Sol(NN+Npoiv).6.3)=F6.% Uele(3)=Sol(KK).k)*G(j.% K22=K22+A(IA.5.3)=F24.% F(3.3)=F12.j)*A(IB.6.3.3)=F6.3)=F4.% F(3.% Vele(2)=Sol(JJ+Npoiv).6.3)=F(i.% F(4.l)*B(l.IB)=2*Anew*K11+Anew*K22.j)*A(IB.k)*G(j.k)*G(j.6.% Uele(2)=Sol(JJ).% F(3.3)=F24.% F(2.3.% Vele(3)=Sol(KK+Npoiv).% %Compute [sxx] [sxy] [syx] [syy] matrices for IA=1:6 for IB=1:6 K11=0.3).3)=F12.k).% for i=1:6 for j=1:6 F(j.

j)*A(IB.l)*C(l.k)*2*Uele(l)*Vele(i).k)*2*Uele(l)*Uele(i).i)*B(i.% Ks222vv=0.% .k)*A(IB.k)*G(j.i)*C(i.k)*G(j.j)*G(j.i)*B(i.k)*Uele(l)*Vele(i).l)*C(l.k)*Uele(l)*Vele(i).k)*2*Vele(l)*Uele(i).i)*C(i.l)*B(l.% Ks12vv=0.% Ks12uv=Ks12uv+A(IA.j)*A(IB.IB)=Ks22vv.% KS22vv(IA.k)*G(j.l)*B(i.k)*Vele(l)*Uele(i).l)*C(l.k)*Vele(l)*Vele(i).% Ks21uv=0.i)*B(i.k)*Uele(l)*Uele(i).% Ks222uv=0.Syx(IA.k)*2*Vele(l)*Vele(i).k)*Vele(l)*Uele(i).j)*A(IB.k)*Vele(l)*Vele(i).j)*A(IB.k)*G(j.k)*G(j.% Ks22vv=Ks22vv+A(IA.i)*C(i.% Ks22vv=0.% Ks12uu=0.% end end end end KS11uu(IA.% Ks21vv=0.l)*B(i.% end end Compute stabilize term matrices for IA=1:6 for IB=1:6 Ks11uu=0.l)*B(l.% Ks112uu=0.k)*G(j.j)*G(j.l)*B(l.i)*C(l.l)*C(l.k)*Uele(l)*Uele(i).l)*C(l.k)*A(IB.j)*A(IB.% for i=1:6 for j=1:3 for k=1:3 for l=1:6 Ks11uu=Ks11uu+A(IA.% Ks21vv=Ks21vv+A(IA.k)*G(j.j)*A(IB.k)*Uele(l)*Uele(i).i)*C(i.% Ks21uv=Ks21uv+A(IA.% Ks21uu=Ks21uu+A(IA.IB)=Ks112uu.k)*G(j.l)*C(l.% Ks112uu=Ks112uu+A(IA.% Ks12vu=0.j)*G(j.% Ks12vu=Ks12vu+A(IA.IB)=Anew*K11+2*Anew*K22.j)*A(IB.IB)=Ks11uu.% KS112uu(IA.k)*Uele(l)*Uele(i).i)*B(i.j)*A(IB.k)*G(j.% Ks222vv=Ks222vv+A(IA.IB)=Anew*K21.l)*C(l.% Syy(IA.l)*B(l.% Ks222vu=0.i)*B(i.l)*C(i.i)*C(i.i)*C(i.% Ks21vu=0.i)*B(l.% Ks12uu=Ks12uu+A(IA.k)*G(j.% Ks222uv=Ks222uv+A(IA.i)*C(l.% Ks12vv=Ks12vv+A(IA.j)*A(IB.j)*A(IB.% Ks21uu=0.k)*G(j.% Ks12uv=0.j)*A(IB.% Ks222vu=Ks222vu+A(IA.% Ks21vu=Ks21vu+A(IA.k)*A(IB.

% KS12vv(IA.j)+ KS12uv(i.j)=deltt/2*(KS11uu(i.% KS21uv(IA.IB)=Ks12uu.j) +KS21vu(i.KS222vv(IA.% Kse3(i.j)*G(j.j)+KS222vv(i.j)=deltt/2*(KS12vv(i.IA).% end end %Then the corresponding two matrices on the upper right for IA=1:3 for IB=1:6 Qxt(IB.IB)=Ks222vu.% Qyt(IB.% KS222uv(IA.j)+KS222uv(i.% Kse2(i.% end end for i=1:6 for j=1:6 Kse1(i.j)).j)+KS21vv(i.j)).IB).j)+KS22vv(i.% KS12vu(IA.IB)=Ks12vv.% KS21vu(IA.j)+KS21uu(i.IB)=Ks21uv.IA)= -Qx(IA.IB)=Ks21vv.% Kse4(i.IB)=Cx/den.j)+ KS12uv(i.j)+KS112uu(i.j)*G(j.IB)=Ks21vu.% KS12uu(IA.% end end Qx(IA.% Qy(IA.j)=deltt/2*(KS11uu(i.j)+KS21vu(i.j)+KS21uv(i.i)*C(i.IB)=Ks21uu.IB)=Ks222uv.% Cy=Cy+A(IB.% for i=1:6 for j=1:3 Cx=Cx+A(IB.IA)= -Qy(IA.j)+KS22vv(i.% end end %Compute all matrices associated with the inertia term for IA=1:6 .IB)=Ks12vu.j)+KS21vu(i.j)).% KS21uu(IA.IA).% end end Compute [Q1] and [Q2] for IA=1:3 for IB=1:6 Cx=0.% KS12uv(IA.j)+KS222vu(i.IB).% Cy=0.j)+KS12vu(i.IB)=Ks222vv.% KS222vu(IA.% KS21vv(IA.j)).j)+KS12uv(i.j)=deltt/2*(KS12uu(i.IB)=Cy/den.i)*B(i.IB)=Ks12uv.

% end end %Then the matrix (15x15) on LHS is for i=1:15 for j=1:15 Akele(i.j.IB)=Cabgxvg.j)+Kse3(i.i)*A(IB.j)*A(IB.j)+Sxy(i.% AGBXUG(IA.% end end %Take in system equation for i=1:6 for j=1:6 Gxx(i.j)=ABGYUG(i.m)*Uele(k).% Cagbxug=Cagbxug+A(IA.l)*B(l.j)+Kse4(i.l)*C(l.m)*F(i.% Cagbyvg=0.% ABGYUG(IA.j)+Syx(i.j)*A(k.% for i=1:6 for j=1:6 for k=1:6 for l=1:6 for m=1:3 Cabgxug=Cabgxug+A(IA.l)*B(l.% AGBYVG(IA.j.% Cabgxvg=0.l)*C(l.for IB=1:6 Cabgxug=0.% Cabgyvg=Cabgyvg+A(IA.% ABGYVG(IA.j)+AGBXUG(i.j)+Kse1(i.m)*F(i.j)+Syy(i.% ABGXVG(IA.j.j)+Kse2(i.i)*A(IB.j).j.l)*C(l.% end end .% Cagbyvg=Cagbyvg+A(IA.m)*Uele(k).j).% Cabgxvg=Cabgxvg+A(IA.j)*A(k.% end end end end end ABGXUG(IA.% Cagbxug=0.m)*F(i.j)+AGBYVG(i.m)*F(i.j)+AGBXUG(i.j).l)*B(l.j)+Sxx(i.IB)=Cagbyvg.m)*F(i.i)*A(k.% Aly(i.j)+AGBYVG(i.m)*Uele(k).% Cabgyug=0.% Cabgyvg=0.m)*F(i.j)=ABGYVG(i.% Gyy(i.j.j)=ABGXUG(i.IB)=Cabgyug.m)*Vele(k).j.j)*A(k.m)*Vele(k).j)*A(k.IB)=Cagbxug.% Cabgyug=Cabgyug+A(IA.j).i)*A(IB.j)=0.m)*Vele(k).% Alx(i.j)=ABGXVG(i.i)*A(k.IB)=Cabgyvg.j)*A(IB.IB)=Cabgxug.i)*A(IB.

% Akele(i+6.% Term2=Term2+ABGYUG(i.j+6)=Qy(i.j).% Term9=Term9+KS22vv(i.% Term3=0.j)=Qx(i.% for j=1:6 Term1=Term1+ABGXUG(i.j)*Vele(j).j).j).% Term5=Term5+Sxy(i.% Term7=Term7+KS12uv(i.% Term5=0.j)*Uele(j).j+6)=Aly(i.j).j).% Term6=Term6+KS11uu(i.% end FX(i)=Term1+Term2+Term3+Term4+Term5+ deltt/2*(Term6+Term7+Term8+Term9).j+6)=Gyy(i.j)*Uele(j).for i=1:6 for j=1:6 Akele(i.j)*Vele(j).% end for j=1:3 Term3=Term3+Qxt(i.% Term9=0.j)*Pele(j).% Term7=0.j+12)=Qyt(i.j)*Uele(j).j)*Uele(j).% end end for i=1:3 for j=1:6 Akele(i+12.j)*Uele(j).% Term4=Term4+Sxx(i.% Term4=0.% end for j=1:3 Akele(i.% Akele(i+12.j)=Alx(i.% Term8=0.% end for i=1:6 .% Akele(i.j).% Akele(i+6.j+12)=Qxt(i.% Term8=Term8+KS21vu(i.j).j)*Uele(j).j).% Term6=0.% Akele(i+6.j)=Gxx(i.% Term2=0.% end end %Begin computing the residuals on RHS of element equation for i=1:6 Term1=0.

% for j=1:6 Term1=Term1+ABGXVG(i.j)*Uele(j).Neq.% end %B.nodes.% Term6=0.% Term9=0.j)*Uele(j).% end for j=1:3 Term3=Term3+Qyt(i.% Term5=0.SysK.Term1=0.% Term2=Term2+ABGYVG(i.% Term4=0.% for j=1:6 Term1=Term1+Qx(i.% end [SysK SysR]=ASSEMBLE(iel.% end for i=1:3 Rele(i+12)=-FI(i).SysR.% Term2=0.% Term2=0.% Term5=Term5+Syy(i. Npoiv.% Term3=0.% end %Thus the residual vector on RHS of element equation is for i=1:6 Rele(i)=-FX(i).j)*Vele(j).% Term6=Term6+KS11uu(i.4 Assembly to Global stiffness matrix function ”ASSEMBLE” .% Term2=Term2+Qy(i.% Term7=Term7+KS12uv(i.% Rele(i+6)=-FY(i).% Term9=Term9+KS22vv(i.j)*Vele(j).j)*Vele(j).j)*Vele(j).% end FI(i)=Term1+Term2.% Term4=Term4+Syx(i.Nelem).Akele.Rele.% Term7=0.j)*Pele(j).j)*Vele(j).j)*Uele(j).% end for i=1:3 Term1=0.% Term8=Term8+KS21vu(i.% end FY(i)=Term1+Term2+Term3+Term4+Term5+ deltt/2*(Term6+Term7+Term8+Term9).j)*Vele(j).% Term8=0.j)*Vele(j).2.

% k=i+6.j).JJ)=SysK(II.l).KK)=SysK(LL. SysK.% JJ=nodes(iel.% k=i+12.i).i).% SysK(LL.j).Npoiv.% SysK(II.% SysK(II.i). and V velocity for i=1:6 II=nodes(iel.% l=j+12.function [SysK SysR]=ASSEMBLE(iel.% KK=Npoiv+II.% LL=2*Npoiv+JJ.LL)+Akele(k.% SysK(LL.nodes.LL)+Akele(i.Nelem) %Contribution of coeficients assocoated with U.% SysK(KK.LL)=SysK(KK.% KK=Npoiv+II.LL)+Akele(i.SysR.LL)+Akele(k.% SysK(II.j).k).l).% k=i+6.Akele.LL)=SysK(KK.Neq.LL)=SysK(II.% .JJ)+Akele(i.% SysR(II)=SysR(II)+Rele(i).% l=j+6.% KK=2*Npoiv+II.JJ)+Akele(k.i). and V velocity for i=1:6 for j=1:6 II=nodes(iel.% SysR(KK)=SysR(KK)+Rele(k).i).% JJ=nodes(iel.Rele.KK)+Akele(l.% SysK(KK.l).LL)=SysK(II.% LL=Npoiv+JJ.j).JJ)=SysK(KK.% SysK(KK.II)=SysK(LL.% KK=Npoiv+II.% end end %Assembly load vector system %Contribution of value with U.% k=i+6.II)+Akele(l.% end end %Contribution of coeficients assocoated with P pressure for i=1:6 for j=1:3 II=nodes(iel.% end %Contribution of value with P pressure for i=1:3 II=nodes(iel.l).

IEQ)=1.% .IC)=0.% IEQ2=Neq.% IEQ2=Npoiv.% end %Apply boundary conditions function ”ApplyBC55” function [SysM.% %Apply boundary condition for nodal U-velocity IEQ1=1.Pres). SysN.% end SysM(IEQ.IEQ)=0.% SysN(IEQ)=Uvel(IEQU).IC)=0.% end end %Apply boundary condition for nodal P-pressure IEQ1=2*Npoiv+1.% SysM(IR.% SysM(IR. SysN]=ApplyBC55(Npoiv.% for IEQ=IEQ1:IEQ2 IEQV=IEQ-Npoiv.% IEQ2=2*Npoiv.% if(Ibcv(IEQV) =0) for IR=1:Neq if(IR==IEQ) SysN(IR)=SysN(IR)-SysM(IR.IEQ)*Vvel(IEQV).% end end %Apply boundary condition for nodal V-velocity IEQ1=Npoiv+1.SysM.Neq.Vvel.% end end for IC=1:Neq SysM(IEQ.Npoip.IEQ)*Uvel(IEQU).% end end for IC=1:Neq SysM(IEQ.% end SysM(IEQ.IEQ)=1.IEQ)=0.% if(Ibcu(IEQU) =0) for IR=1:Neq if(IR==IEQ) SysN(IR)=SysN(IR)-SysM(IR.% SysN(IEQ)=Vvel(IEQV).SysR(KK)=SysR(KK)+Rele(k).% for IEQ=IEQ1:IEQ2 IEQU=IEQ.Uvel.Ibcu.

% end SysM(IEQ.IC)=0.% SysM(IR.% if(Ibcp(IEQP) =0) for IR=1:Neq if(IR==IEQ) SysN(IR)=SysN(IR)-SysM(IR.% end end for IC=1:Neq SysM(IEQ.IEQ)=1.% SysN(IEQ)=Pres(IEQP).IEQ)*Pres(IEQP).IEQ)=0.% end end .for IEQ=IEQ1:IEQ2 IEQP=IEQ-2*Npoiv.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times