OptFEM2D  0.1
Matlab optimized FEM2D
 All Files Functions Groups 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 % Assembling Mass Matrix by `P_1`-Lagrange finite elements
4 % using "base" 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=MassAssemblingP1base(Th.nq,Th.nme,Th.me,Th.areas);@endverbatim
24 %
25 % See also:
26 % #SquareMesh
27 %
28 % @author Francois Cuvelier @date 2012-01-21
29 %
30 % @new{1,1,fc,2012-11-22} Added doxygen documentation using mtoc++ tool
31 %
32 % Copyright (c) 2012, Francois Cuvelier, Gilles Scarella
33 % All rights reserved.
34 %
35 % Redistribution and use in source and binary forms, with or without
36 % modification, are permitted only in compliance with the BSD license, see
37 % http://www.opensource.org/licenses/bsd-license.php
38 M=sparse(nq,nq);
39 for k=1:nme
40  E=ElemMassMatP1(areas(k));
41  for il=1:3
42  i=me(il,k);
43  for jl=1:3
44  j=me(jl,k);
45  M(i,j)=M(i,j)+E(il,jl);
46  end
47  end
48 end