OptFEM2DP1 Toolbox  1.2b4
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
Opt/StiffElasAssembling2DP1OptV1.m
Go to the documentation of this file.
00001 function K=StiffElasAssembling2DP1OptV1(nq,nme,q,me,areas,lambda,mu,Num)
00002 % function K=StiffElasAssembling2DP1OptV1(nq,nme,q,me,areas,lambda,mu,Num)
00003 %   Assembly of the Stiffness Elasticity Matrix by `P_1`-Lagrange finite elements
00004 %   using "OptV1" version (see report).
00005 %
00006 %   The Stiffness Elasticity Matrix is given by 
00007 %   ``\StiffElas_{m,l}=\int_{\DOMH} \Odv^t(\BasisFuncTwoD_m) \Ocv(\BasisFuncTwoD_l)dT, \ \forall (m,l)\in\ENS{1}{2\,\nq}^2,``
00008 %   where `\BasisFuncTwoD_m` are `P_1`-Lagrange vector basis functions.
00009 %   Here `\Ocv=(\Occ_{xx},\Occ_{yy},\Occ_{xy})^t` and `\Odv=(\Odc_{xx},\Odc_{yy},2\Odc_{xy})^t`
00010 %   are the elastic stress and strain tensors respectively. 
00011 %
00012 % Parameters:
00013 %  nq: total number of nodes in the mesh, also denoted by `\nq`.
00014 %  nme: total number of triangles, also denoted by `\nme`.
00015 %  q: Array of vertices coordinates, `2\times\nq` array. <br/>
00016 %  `{\q}(\il,j)` is the
00017 %  `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
00018 %  `j\in\ENS{1}{\nq}`
00019 %  me: Connectivity array, `3\times\nme` array. <br/>
00020 %  `\me(\jl,k)` is the storage index of the
00021 %  `\jl`-th  vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and
00022 %       `k\in{\ENS{1}{\nme}}`.
00023 %  areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
00024 %  lambda: the first Lame coefficient in Hooke's law
00025 %  mu: the second Lame coefficient in Hooke's law
00026 %  Num: 
00027 %    - 0 global alternate numbering with local alternate numbering (classical method), 
00028 %    - 1 global block numbering with local alternate numbering,
00029 %    - 2 global alternate numbering with local block numbering,
00030 %    - 3 global block numbering with local block numbering.
00031 %
00032 % Return values:
00033 %  K: `2\nq\times 2\nq` stiffness elasticity sparse matrix
00034 %
00035 % Example:
00036 %  @verbatim 
00037 %    Th=SquareMesh(10);
00038 %    lambda=1; mu=1;
00039 %    Num = 0; 
00040 %    KK=StiffElasAssembling2DP1OptV1(Th.nq,Th.nme,Th.q,Th.me,Th.areas,lambda,mu,Num);@endverbatim
00041 %  
00042 % See also:
00043 %   #BuildIkFunc, #BuildElemStiffElasMatFunc
00044 % Copyright:
00045 %   See \ref license
00046 ElemStiffElasMat=BuildElemStiffElasMatFunc(Num);
00047 C=[lambda+2*mu,lambda,0;lambda,lambda+2*mu,0;0,0,mu];
00048 GetI=BuildIkFunc(Num,nq);
00049 Ig=zeros(36*nme,1);Jg=zeros(36*nme,1);Kg=zeros(36*nme,1);
00050 kk=1:36;
00051 for k=1:nme
00052   Me=ElemStiffElasMat(q(:,me(:,k)),areas(k),C);
00053   I=GetI(me,k);
00054   jA=ones(6,1)*I;
00055   iA=jA';
00056 
00057   Ig(kk)=iA(:);
00058   Jg(kk)=jA(:);
00059   Kg(kk)=Me(:);
00060   kk=kk+36;
00061 end
00062 K=sparse(Ig,Jg,Kg,2*nq,2*nq);
 All Files Functions