OptFEM2D Toolbox for Matlab  V1.2b1
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
StiffElasAssemblingP1base.m
Go to the documentation of this file.
1 function K=StiffElasAssemblingP1base(nq,nme,q,me,areas,lambda,mu,Num)
2 % function K=StiffElasAssemblingP1base(nq,nme,q,me,areas,lambda,mu,Num)
3 % Assembly of the Stiffness Elasticity Matrix by `P_1`-Lagrange finite elements
4 % using basic version (see report).
5 %
6 % The Stiffness Elasticity Matrix is given by
7 % ``\StiffElas_{m,l}=\int_{\DOMH} \Odv^t(\BasisFuncTwoD_m) \Ocv(\BasisFuncTwoD_l)dT, \ \forall (m,l)\in\ENS{1}{2\,\nq}^2,``
8 % where `\BasisFuncTwoD_m` are vectors field `P_1`-Lagrange basis functions.
9 % Here `\Ocv=(\Occ_{xx},\Occ_{yy},\Occ_{xy})^t` and `\Odv=(\Odc_{xx},\Odc_{yy},2\Odc_{xy})^t`
10 % are the elastic stress and strain tensors respectively.
11 %
12 % Parameters:
13 % nq: total number of nodes in the mesh, also denoted by `\nq`.
14 % nme: total number of triangles, also denoted by `\nme`.
15 % q: Array of vertices coordinates, `2\times\nq` array. <br/>
16 % `{\q}(\il,j)` is the
17 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
18 % `j\in\ENS{1}{\nq}`
19 % me: Connectivity array, `3\times\nme` array. <br/>
20 % `\me(\jl,k)` is the storage index of the
21 % `\jl`-th vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and
22 % `k\in{\ENS{1}{\nme}}`.
23 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
24 % lambda: the first Lame coefficient in Hooke's law
25 % mu: the second Lame coefficient in Hooke's law
26 % Num:
27 % - 0 global alternate numbering with local alternate numbering (classical method),
28 % - 1 global block numbering with local alternate numbering,
29 % - 2 global alternate numbering with local block numbering,
30 % - 3 global block numbering with local block numbering.
31 %
32 % Return values:
33 % K: `2\nq\times 2\nq` stiffness elasticity sparse matrix
34 %
35 % Example:
36 % @verbatim
37 % Th=SquareMesh(10);
38 % KK=StiffElasAssemblingP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas,lambda,mu,Num);@endverbatim
39 %
40 % See also:
41 % #SquareMesh
42 %
43 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
44 %
45 % This file is part of OptFEM2DP1.
46 % OptFEM2DP1 is free software: you can redistribute it and/or modify
47 % it under the terms of the GNU General Public License as published by
48 % the Free Software Foundation, either version 3 of the License, or
49 % (at your option) any later version.
50 %
51 % OptFEM2DP1 is distributed in the hope that it will be useful,
52 % but WITHOUT ANY WARRANTY; without even the implied warranty of
53 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 % GNU General Public License for more details.
55 %
56 % You should have received a copy of the GNU General Public License
57 % along with this program. If not, see <http://www.gnu.org/licenses/>.
58 K=sparse(2*nq,2*nq);
59 GetI=BuildIkFunc(Num,nq);
60 ElemStiffElasMat=BuildElemStiffElasMatFunc(Num);
61 for k=1:nme
62  MatElem=ElemStiffElasMat(q(:,me(1,k)),q(:,me(2,k)),q(:,me(3,k)),areas(k),lambda,mu);
63  I=GetI(me,k);
64  for il=1:6
65  for jl=1:6
66  K(I(il),I(jl))=K(I(il),I(jl))+MatElem(il,jl);
67  end
68  end
69 end
70