![]() |
OptFEM2DP1 Toolbox
V1.2
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
|
00001 function M=MassAssembling2DP1OptV1(nq,nme,me,areas) 00002 % function M=MassAssembling2DP1OptV1(nq,nme,me,areas) 00003 % Assembly of the Mass Matrix using `P_1`-Lagrange finite elements 00004 % - OptV1 version (see report). 00005 % 00006 % The Mass Matrix `\Masse` is given by 00007 % ``\Masse_{i,j}=\int_\DOMH \FoncBase_i(\q) \FoncBase_j(\q) d\q,\ \forall (i,j)\in{\ENS{1}{\nq}}^2`` 00008 % where `\FoncBase_i` are `P_1`-Lagrange basis functions 00009 % Parameters: 00010 % nq: total number of nodes of the mesh, also denoted by `\nq`, 00011 % nme: total number of triangles, also denoted by `\nme`, 00012 % me: Connectivity array, `3\times\nme` array. <br/> 00013 % `\me(\jl,k)` is the storage index of the 00014 % `\jl`-th vertex of the `k`-th triangle in the array `\q` of vertices coordinates, `\jl\in\{1,2,3\}` and 00015 % `k\in{\ENS{1}{\nme}}`. 00016 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle. 00017 % 00018 % Return values: 00019 % M: Global mass matrix, `\nq\times\nq` sparse matrix. 00020 % 00021 % Example: 00022 % @verbatim 00023 % Th=SquareMesh(10); 00024 % M=MassAssembling2DP1OptV1(Th.nq,Th.nme,Th.me,Th.areas); 00025 % @endverbatim 00026 % Copyright: 00027 % See \ref license 00028 Ig=zeros(9*nme,1);Jg=zeros(9*nme,1);Kg=zeros(9*nme,1); 00029 00030 ii=[1 2 3 1 2 3 1 2 3]; 00031 jj=[1 1 1 2 2 2 3 3 3]; 00032 kk=1:9; 00033 for k=1:nme 00034 E=ElemMassMat2DP1(areas(k)); 00035 Ig(kk)=me(ii,k); 00036 Jg(kk)=me(jj,k); 00037 Kg(kk)=E(:); 00038 kk=kk+9; 00039 end 00040 M=sparse(Ig,Jg,Kg,nq,nq); 00041 %*****