OptFEM3DP1 Toolbox  V1.0
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D
 All Files Functions Variables Pages
MassAssembling3DP1base.m
Go to the documentation of this file.
1 function M=MassAssembling3DP1base(nq,nme,me,volumes)
2 % function M=MassAssembling3DP1base(nq,nme,me,volumes)
3 % Assembly of the Mass Matrix by `P_1`-Lagrange finite elements in 3D
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 vertices, also denoted by `\nq`.
11 % nme: total number of elements, also denoted by `\nme`.
12 % me: Connectivity array, `4\times\nme` array. <br/>
13 % `\me(\jl,k)` is the storage index of the
14 % `\jl`-th vertex of the `k`-th tetrahedron in the array `\q` of vertices coordinates, `\jl\in\{1,2,3,4\}` and
15 % `k\in{\ENS{1}{\nme}}`.
16 % volumes: Array of volumes, `1\times\nme array`. volumes(k) is the volume
17 % of the k-th tetrahedron.
18 %
19 % Return values:
20 % M: Global mass matrix, `\nq\times\nq` sparse matrix.
21 %
22 % Example:
23 % @verbatim
24 % Th=CubeMesh(10);
25 % M=MassAssembling3DP1base(Th.nq,Th.nme,Th.me,Th.volumes);
26 % @endverbatim
27 %
28 % See also:
29 % #ElemMassMat3DP1D0
30 % Copyright:
31 % See \ref license
32 M=sparse(nq,nq);
33 for k=1:nme
34  E=ElemMassMat3DP1D0(volumes(k));
35  for il=1:4
36  i=me(il,k);
37  for jl=1:4
38  j=me(jl,k);
39  M(i,j)=M(i,j)+E(il,jl);
40  end
41  end
42 end