OptFEM2DP1 Toolbox  V1.2b3
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
ElemStiffElasMatBbVecP1.m
Go to the documentation of this file.
1 function [Kg]=ElemStiffElasMatBbVecP1(q,me,areas,lambda,mu)
2 % function [Kg]=ElemStiffElasMatBbVecP1(q,me,areas,lambda,mu)
3 % Global Computation of the element stiffness elasticity matrix.
4 % Block numbering
5 %
6 % Parameters:
7 % q: Array of vertices coordinates, `2\times\nq` array. <br/>
8 % `{\q}(\il,j)` is the
9 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
10 % `j\in\ENS{1}{\nq}`
11 % me: Connectivity array, `3\times\nme` array. <br/>
12 % `\me(\jl,k)` is the storage index of the
13 % `\jl`-th vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and
14 % `k\in{\ENS{1}{\nme}}`.
15 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
16 % lambda: the first Lame coefficient in Hooke's law
17 % mu: the second Lame coefficient in Hooke's law
18 %
19 %
20 % Return values:
21 % Kg: `36\times \nme` global element stiffness elasticity matrix
22 %
23 % Copyright:
24 % See \ref license
25 order=1;
26 ndf=(order+1)*(order+2)/2;
27 dim=2*ndf;
28 ndf2=dim*dim;
29 u=q(:,me(2,:))-q(:,me(3,:));
30 G1=[u(2,:);-u(1,:)];
31 u=q(:,me(3,:))-q(:,me(1,:));
32 G2=[u(2,:);-u(1,:)];
33 u=q(:,me(1,:))-q(:,me(2,:));
34 G3=[u(2,:);-u(1,:)];
35 clear u
36 coef=ones(2,1)*(0.5./sqrt(areas));
37 G1=G1.*coef;
38 G2=G2.*coef;
39 G3=G3.*coef;
40 clear coef
41 Kg=zeros(ndf2,size(me,2));
42 Kg(1,:)=(lambda + 2.*mu).*G1(1,:).^2 + mu.*G1(2,:).^2;
43 Kg(2,:)=(lambda + 2.*mu).*G1(1,:).*G2(1,:) + mu.*G1(2,:).*G2(2,:);
44 Kg(3,:)=(lambda + 2.*mu).*G1(1,:).*G3(1,:) + mu.*G1(2,:).*G3(2,:);
45 Kg(4,:)=lambda.*G1(1,:).*G1(2,:) + mu.*G1(1,:).*G1(2,:);
46 Kg(5,:)=lambda.*G1(1,:).*G2(2,:) + mu.*G1(2,:).*G2(1,:);
47 Kg(6,:)=lambda.*G1(1,:).*G3(2,:) + mu.*G1(2,:).*G3(1,:);
48 Kg(8,:)=(lambda + 2.*mu).*G2(1,:).^2 + mu.*G2(2,:).^2;
49 Kg(9,:)=(lambda + 2.*mu).*G2(1,:).*G3(1,:) + mu.*G2(2,:).*G3(2,:);
50 Kg(10,:)=lambda.*G1(2,:).*G2(1,:) + mu.*G1(1,:).*G2(2,:);
51 Kg(11,:)=lambda.*G2(1,:).*G2(2,:) + mu.*G2(1,:).*G2(2,:);
52 Kg(12,:)=lambda.*G2(1,:).*G3(2,:) + mu.*G2(2,:).*G3(1,:);
53 Kg(15,:)=(lambda + 2.*mu).*G3(1,:).^2 + mu.*G3(2,:).^2;
54 Kg(16,:)=lambda.*G1(2,:).*G3(1,:) + mu.*G1(1,:).*G3(2,:);
55 Kg(17,:)=lambda.*G2(2,:).*G3(1,:) + mu.*G2(1,:).*G3(2,:);
56 Kg(18,:)=lambda.*G3(1,:).*G3(2,:) + mu.*G3(1,:).*G3(2,:);
57 Kg(22,:)=(lambda + 2.*mu).*G1(2,:).^2 + mu.*G1(1,:).^2;
58 Kg(23,:)=(lambda + 2.*mu).*G1(2,:).*G2(2,:) + mu.*G1(1,:).*G2(1,:);
59 Kg(24,:)=(lambda + 2.*mu).*G1(2,:).*G3(2,:) + mu.*G1(1,:).*G3(1,:);
60 Kg(29,:)=(lambda + 2.*mu).*G2(2,:).^2 + mu.*G2(1,:).^2;
61 Kg(30,:)=(lambda + 2.*mu).*G2(2,:).*G3(2,:) + mu.*G2(1,:).*G3(1,:);
62 Kg(36,:)=(lambda + 2.*mu).*G3(2,:).^2 + mu.*G3(1,:).^2;
63 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],:);