OptFEM2D Toolbox for Matlab  V1.2b1
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
MassAssemblingP1base.m
Go to the documentation of this file.
1 function M=MassAssemblingP1base(nq,nme,me,areas)
2 % function M=MassAssemblingP1base(nq,nme,me,areas)
3 % Assembly of the Mass Matrix by `P_1`-Lagrange finite elements
4 % - Basic version (see report).
5 %
6 % The Mass Matrix `\Masse` is given by
7 % ``\Masse_{i,j}=\int_\DOMH \FoncBase_i(\q)\, \FoncBase_j(\q)\, d\q,\ \forall (i,j)\in{\ENS{1}{\nq}}^2``
8 % where `\FoncBase_i` are `P_1`-Lagrange basis functions.
9 % Parameters:
10 % nq: total number of nodes of the mesh, also denoted by `\nq`,
11 % nme: total number of triangles, also denoted by `\nme`,
12 % me: Connectivity array, `3\times\nme` array. <br/>
13 % `\me(\jl,k)` is the storage index of the
14 % `\jl`-th vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and
15 % `k\in{\ENS{1}{\nme}}`.
16 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
17 %
18 % Return values:
19 % M: Global mass matrix, `\nq\times\nq` sparse matrix.
20 %
21 % Example:
22 % @verbatim
23 % Th=SquareMesh(10);
24 % M=MassAssemblingP1base(Th.nq,Th.nme,Th.me,Th.areas);
25 % @endverbatim
26 %
27 % See also:
28 % #ElemMassMatP1
29 %
30 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
31 %
32 % This file is part of OptFEM2DP1.
33 % OptFEM2DP1 is free software: you can redistribute it and/or modify
34 % it under the terms of the GNU General Public License as published by
35 % the Free Software Foundation, either version 3 of the License, or
36 % (at your option) any later version.
37 %
38 % OptFEM2DP1 is distributed in the hope that it will be useful,
39 % but WITHOUT ANY WARRANTY; without even the implied warranty of
40 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 % GNU General Public License for more details.
42 %
43 % You should have received a copy of the GNU General Public License
44 % along with this program. If not, see <http://www.gnu.org/licenses/>.
45 M=sparse(nq,nq);
46 for k=1:nme
47  E=ElemMassMatP1(areas(k));
48  for il=1:3
49  i=me(il,k);
50  for jl=1:3
51  j=me(jl,k);
52  M(i,j)=M(i,j)+E(il,jl);
53  end
54  end
55 end