OptFEM2DP1 Toolbox  1.2b4
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
Opt/ElemStiffElasMatBaVecP1.m
Go to the documentation of this file.
00001 function [Kg]=ElemStiffElasMatBaVecP1(q,me,areas,lambda,mu)
00002 % function [Kg]=ElemStiffElasMatBaVecP1(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 order=1;
00026 ndf=(order+1)*(order+2)/2;
00027 dim=2*ndf;
00028 ndf2=dim*dim;
00029 u=q(:,me(2,:))-q(:,me(3,:));
00030 G1=[u(2,:);-u(1,:)];
00031 u=q(:,me(3,:))-q(:,me(1,:));
00032 G2=[u(2,:);-u(1,:)];
00033 u=q(:,me(1,:))-q(:,me(2,:));
00034 G3=[u(2,:);-u(1,:)];
00035 clear u
00036 coef=ones(2,1)*(0.5./sqrt(areas));
00037 G1=G1.*coef;
00038 G2=G2.*coef;
00039 G3=G3.*coef;
00040 clear coef
00041 Kg=zeros(ndf2,size(me,2));
00042 Kg(1,:)=(lambda + 2.*mu).*G1(1,:).^2 + mu.*G1(2,:).^2;
00043 Kg(2,:)=lambda.*G1(1,:).*G1(2,:) + mu.*G1(1,:).*G1(2,:);
00044 Kg(3,:)=(lambda + 2.*mu).*G1(1,:).*G2(1,:) + mu.*G1(2,:).*G2(2,:);
00045 Kg(4,:)=lambda.*G1(1,:).*G2(2,:) + mu.*G1(2,:).*G2(1,:);
00046 Kg(5,:)=(lambda + 2.*mu).*G1(1,:).*G3(1,:) + mu.*G1(2,:).*G3(2,:);
00047 Kg(6,:)=lambda.*G1(1,:).*G3(2,:) + mu.*G1(2,:).*G3(1,:);
00048 Kg(8,:)=(lambda + 2.*mu).*G1(2,:).^2 + mu.*G1(1,:).^2;
00049 Kg(9,:)=lambda.*G1(2,:).*G2(1,:) + mu.*G1(1,:).*G2(2,:);
00050 Kg(10,:)=(lambda + 2.*mu).*G1(2,:).*G2(2,:) + mu.*G1(1,:).*G2(1,:);
00051 Kg(11,:)=lambda.*G1(2,:).*G3(1,:) + mu.*G1(1,:).*G3(2,:);
00052 Kg(12,:)=(lambda + 2.*mu).*G1(2,:).*G3(2,:) + mu.*G1(1,:).*G3(1,:);
00053 Kg(15,:)=(lambda + 2.*mu).*G2(1,:).^2 + mu.*G2(2,:).^2;
00054 Kg(16,:)=lambda.*G2(1,:).*G2(2,:) + mu.*G2(1,:).*G2(2,:);
00055 Kg(17,:)=(lambda + 2.*mu).*G2(1,:).*G3(1,:) + mu.*G2(2,:).*G3(2,:);
00056 Kg(18,:)=lambda.*G2(1,:).*G3(2,:) + mu.*G2(2,:).*G3(1,:);
00057 Kg(22,:)=(lambda + 2.*mu).*G2(2,:).^2 + mu.*G2(1,:).^2;
00058 Kg(23,:)=lambda.*G2(2,:).*G3(1,:) + mu.*G2(1,:).*G3(2,:);
00059 Kg(24,:)=(lambda + 2.*mu).*G2(2,:).*G3(2,:) + mu.*G2(1,:).*G3(1,:);
00060 Kg(29,:)=(lambda + 2.*mu).*G3(1,:).^2 + mu.*G3(2,:).^2;
00061 Kg(30,:)=lambda.*G3(1,:).*G3(2,:) + mu.*G3(1,:).*G3(2,:);
00062 Kg(36,:)=(lambda + 2.*mu).*G3(2,:).^2 + mu.*G3(1,:).^2;
00063 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],:);
 All Files Functions