![]() |
OptFEM2DP1 Toolbox
V1.2
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
|
00001 function [Kg]=ElemStiffElasMatBaVec2DP1(q,me,areas,lambda,mu) 00002 % function [Kg]=ElemStiffElasMatBaVec2DP1(q,me,areas,lambda,mu) 00003 % Global Computation of the element stiffness elasticity matrix. 00004 % Alternate numbering 00005 % 00006 % Parameters: 00007 % q: Array of vertices coordinates, `2\times\nq` array. <br/> 00008 % `{\q}(\il,j)` is the 00009 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and 00010 % `j\in\ENS{1}{\nq}` 00011 % me: Connectivity array, `3\times\nme` array. <br/> 00012 % `\me(\jl,k)` is the storage index of the 00013 % `\jl`-th vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and 00014 % `k\in{\ENS{1}{\nme}}`. 00015 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle. 00016 % lambda: the first Lame coefficient in Hooke's law 00017 % mu: the second Lame coefficient in Hooke's law 00018 % 00019 % 00020 % Return values: 00021 % Kg: `36\times \nme` global element stiffness elasticity matrix 00022 % 00023 % Copyright: 00024 % See \ref license 00025 u=q(:,me(2,:))-q(:,me(3,:)); 00026 G1=[u(2,:);-u(1,:)]; 00027 u=q(:,me(3,:))-q(:,me(1,:)); 00028 G2=[u(2,:);-u(1,:)]; 00029 u=q(:,me(1,:))-q(:,me(2,:)); 00030 G3=[u(2,:);-u(1,:)]; 00031 clear u 00032 coef=ones(2,1)*(0.5./sqrt(areas)); 00033 G1=G1.*coef; 00034 G2=G2.*coef; 00035 G3=G3.*coef; 00036 clear coef 00037 Kg=zeros(36,size(me,2)); 00038 Kg(1,:)=(lambda + 2.*mu).*G1(1,:).^2 + mu.*G1(2,:).^2; 00039 Kg(2,:)=lambda.*G1(1,:).*G1(2,:) + mu.*G1(1,:).*G1(2,:); 00040 Kg(3,:)=(lambda + 2.*mu).*G1(1,:).*G2(1,:) + mu.*G1(2,:).*G2(2,:); 00041 Kg(4,:)=lambda.*G1(1,:).*G2(2,:) + mu.*G1(2,:).*G2(1,:); 00042 Kg(5,:)=(lambda + 2.*mu).*G1(1,:).*G3(1,:) + mu.*G1(2,:).*G3(2,:); 00043 Kg(6,:)=lambda.*G1(1,:).*G3(2,:) + mu.*G1(2,:).*G3(1,:); 00044 Kg(8,:)=(lambda + 2.*mu).*G1(2,:).^2 + mu.*G1(1,:).^2; 00045 Kg(9,:)=lambda.*G1(2,:).*G2(1,:) + mu.*G1(1,:).*G2(2,:); 00046 Kg(10,:)=(lambda + 2.*mu).*G1(2,:).*G2(2,:) + mu.*G1(1,:).*G2(1,:); 00047 Kg(11,:)=lambda.*G1(2,:).*G3(1,:) + mu.*G1(1,:).*G3(2,:); 00048 Kg(12,:)=(lambda + 2.*mu).*G1(2,:).*G3(2,:) + mu.*G1(1,:).*G3(1,:); 00049 Kg(15,:)=(lambda + 2.*mu).*G2(1,:).^2 + mu.*G2(2,:).^2; 00050 Kg(16,:)=lambda.*G2(1,:).*G2(2,:) + mu.*G2(1,:).*G2(2,:); 00051 Kg(17,:)=(lambda + 2.*mu).*G2(1,:).*G3(1,:) + mu.*G2(2,:).*G3(2,:); 00052 Kg(18,:)=lambda.*G2(1,:).*G3(2,:) + mu.*G2(2,:).*G3(1,:); 00053 Kg(22,:)=(lambda + 2.*mu).*G2(2,:).^2 + mu.*G2(1,:).^2; 00054 Kg(23,:)=lambda.*G2(2,:).*G3(1,:) + mu.*G2(1,:).*G3(2,:); 00055 Kg(24,:)=(lambda + 2.*mu).*G2(2,:).*G3(2,:) + mu.*G2(1,:).*G3(1,:); 00056 Kg(29,:)=(lambda + 2.*mu).*G3(1,:).^2 + mu.*G3(2,:).^2; 00057 Kg(30,:)=lambda.*G3(1,:).*G3(2,:) + mu.*G3(1,:).*G3(2,:); 00058 Kg(36,:)=(lambda + 2.*mu).*G3(2,:).^2 + mu.*G3(1,:).^2; 00059 Kg([7, 13, 14, 19, 20, 21, 25, 26, 27, 28, 31, 32, 33, 34, 35],:)=Kg([2, 3, 9, 4, 10, 16, 5, 11, 17, 23, 6, 12, 18, 24, 30],:);