| OptFEM2DP1 Toolbox V1.2b2 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

All Files Functions Pages
MassAssemblingP1OptV2.m
Go to the documentation of this file.
1 function M=MassAssemblingP1OptV2(nq,nme,me,areas)
2 % function M=MassAssemblingP1OptV2(nq,nme,me,areas)
3 % Assembly of the Mass Matrix using `P_1`-Lagrange finite elements
4 % - OptV2 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` of vertices coordinates, `\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=MassAssemblingP1OptV2(Th.nq,Th.nme,Th.me,Th.areas);
25 % @endverbatim
26 % Copyright:
27 % See \ref license
28 Ig = me([1 2 3 1 2 3 1 2 3],:);
29 Jg = me([1 1 1 2 2 2 3 3 3],:);
30 a6=areas/6;
31 a12=areas/12;
32 Kg = [a6;a12;a12;a12;a6;a12;a12;a12;a6];
33 M = sparse(Ig,Jg,Kg,nq,nq);