OptFEM2D  0.1
Matlab optimized FEM2D
 All Files Functions Groups Pages
MassAssemblingP1OptV0.m
Go to the documentation of this file.
1 function M=MassAssemblingP1OptV0(nq,nme,me,areas)
2 % function M=MassAssemblingP1OptV0(nq,nme,me,areas)
3 % Assembling Mass Matrix by `P_1`-Lagrange finite elements
4 % using "OptV0" version (see report).
5 %
6 % The Mass Matrix 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 noted `\nq`,
11 % nme: number of triangles, also noted `\nme`,
12 % me: `3\times\nme` 'int32' array,`\me(\jl,k)` index of storage, in the array `q`, of the `\jl`-th
13 % vertex of the triangle of index `k`, `\jl\in\{1,2,3\}` and `k\in\{1,\hdots,\nme\}.`
14 % Also noted `\me`.
15 % areas: `1\times\nme` array, areas(k) is the area of triangle k.
16 %
17 % Return values:
18 % M: `\nq\times\nq` sparse matrix
19 %
20 % Example:
21 % @verbatim
22 % Th=SquareMesh(10);
23 % M=MassAssemblingP1OptV0(Th.nq,Th.nme,Th.me,Th.areas);
24 % @endverbatim
25 %
26 % See also:
27 % #SquareMesh
28 %
29 % @author Francois Cuvelier @date 2012-01-21
30 %
31 % @new{1,1,fc,2012-11-22} Added doxygen documentation using mtoc++ tool
32 % - \c Homepage http://www.morepas.org/software/mtocpp/.
33 % - \c License http://www.morepas.org/software/mtocpp/docs/licensing.html
34 %
35 % @change{1,1,fc,2012-11-22}
36 % - ...
37 %
38 % Copyright (c) 2012, Francois Cuvelier, Gilles Scarella
39 % All rights reserved.
40 %
41 % Redistribution and use in source and binary forms, with or without
42 % modification, are permitted only in compliance with the BSD license, see
43 % http://www.opensource.org/licenses/bsd-license.php
44 M=sparse(nq,nq);
45 for k=1:nme
46  I=me(:,k);
47  M(I,I)=M(I,I)+ElemMassMatP1(areas(k));
48 end