%************************************************************************** % MontaKg % % numbering == 1: Plota a malha em preto com os nós e elementos % 0: Plota a malha em preto somente % % inci(numero, tipo, tmat, tgeo, no1, no2 ,...) % coord( x1,y1; x2,y2 ; ...) % % Author: Renato Pavanello % Copyright (c) 2023 by The DMC/FEM/UNICAMP. %************************************************************************** function [kg]=montaKg(coord,inci,Tgeo,Tmat,nnos,nel) % Assemblage of global stiffness matrix kg=zeros(2*nnos); for e = 1:nel noi=inci(e,5); noj=inci(e,6); xi=coord(noi,1); yi=coord(noi,2); xj=coord(noj,1); yj=coord(noj,2); l=sqrt((xj-xi)^2+ (yj-yi)^2); c=(xj-xi)/l; s=(yj-yi)/l; E=Tmat(inci(e,3) ,1); A=Tgeo(inci(e,4) ,1); ke= (E*A/l)*[ c^2 c*s -c^2 -c*s; c*s s^2 -c*s -s^2; -c^2 -c*s c^2 c*s; -c*s -s^2 c*s s^2]; loc=[2*noi-1 2*noi 2*noj-1 2*noj]; kg(loc,loc)=kg(loc,loc)+ke; end