Professional Documents
Culture Documents
Input of Program
Input of Program
m 1 of 6
% ---------------
% force vector
% ---------------
ff(13) = 400; % force applied at node 13 in x-axis,(N)
ff(17) = 200; % force applied at node 17 in x-axis,(N)
%
% -------------------------------------------------
% compute element matrices and vector, and assemble
% -------------------------------------------------
[point2,weight2]=feglqd2(nglx,ngly); % sampling points & weights
matmtx = fematiso(1,emodule,poisson); % constitutive matrix
%
for iel = 1:nel % loop for the total number of elements
for i = 1:nnel
nd(i) = nodes(iel,i); % extract nodes for (iel)-th element
xcoord(i) = gcoord(nd(i),1); % extract x value of the node
ycoord(i) = gcoord(nd(i),2); % extract y value of the node
end
%
k = zeros(edof,edof); % initialization of element matrix
%
% ----------------------
% numerical integration
% ----------------------
for intx = 1:nglx
x = point2(intx,1); % sampling point in x-sxis
wtx = weight2(intx,1); % weight in x-axis
for inty = 1:ngly
y = point2(inty,2); % sampling point in y-sxis
wty = weight2(inty,2); % weight in y-axis
[shape,dhdr,dhds]=feisoq4(x,y);
jacob2 = fejacob2(nnel,dhdr,dhds,xcoord,ycoord);
detjacob = det(jacob2); % determinant of jacobian
invjacob = inv(jacob2); % inverse of jacobian matrix
[dhdx,dhdy] = federiv2(nnel,dhdr,dhds,invjacob);
kinmtx2 = fekine2(nnel,dhdx,dhdy); % compute kinmatic matrix
10/02/17 06:51 مC:\Users\NyZak\Desk...\fempro4.m 4 of 6
%
% ------------------------
% compute element matrix
% ------------------------
k = k+kinmtx2'*matmtx*kinmtx2*thick*wtx*wty*detjacob;
end
end % end of numerical integration loop
%
index = feeldof(nd,nnel,ndof); % extract system dofs for the element
%
kk = feasmbl1(kk,k,index); % assemble element matrices
%
end % end of loop for the total number of elements
%
% -------------------------
% apply boundary condition
% -------------------------
[kk,ff]=feaplyc2(kk,ff,bcdof,bcval);
%
% -------------------------
% solve the matrix equation
% -------------------------
disp = kk\ff;
%
num = 1:1:sdof;
displace = [num' disp] % print nodal displacements
%
% ----------------------------
% element stress computation
% ----------------------------
for ielp = 1:nel % loop for the total number of elements
%
for i = 1:nnel
nd(i) =nodes(ielp,i); % extrat nodes for (iel)-th elements
xcoord(i) = gcoord(nd(i),1); % extract x value of the node
ycoord(i) = gcoord(nd(i),2); % extract y value of the node
10/02/17 06:51 مC:\Users\NyZak\Desk...\fempro4.m 5 of 6
end
%
% -----------------------
% numerical integration
% -----------------------
intp =0;
for intx = 1:nglx
x = point2(intx,1); % sampling point in x-axis
wtx = weight2(intx,1); % weight in x-axis
for inty = 1:ngly
y = point2(inty,2); % sampling point in y-sxis
wty = weight2(inty,2); % weight in y-axis
intp = intp+1;
%
[shape,dhdr,dhds]=feisoq4(x,y);
%
jacob2=fejacob2(nnel,dhdr,dhds,xcoord,ycoord);
%
detjacob = det(jacob2); % determinant of jacobian
invjacob = inv(jacob2); % inverse of jacobian matrix
%
[dhdx,dhdy]=federiv2(nnel,dhdr,dhds,invjacob);
%
kinmtx2=fekine2(nnel,dhdx,dhdy);
%
index = feeldof(nd,nnel,ndof);
%
% ------------------------------------
% extract element displacement vector
% ------------------------------------
for i = 1:edof
eldisp(i)=disp(index(i));
end
%
kinmtx2=fekine2(nnel,dhdx,dhdy); % compute kinmatic matrix
%
10/02/17 06:51 مC:\Users\NyZak\Desk...\fempro4.m 6 of 6