OptFEM3DP1 Toolbox  V1.0
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D
 All Files Functions Variables Pages
MassVFAssembling3DP1OptV2.m
Go to the documentation of this file.
1 function M=MassVFAssembling3DP1OptV2(nq,nme,me,volumes,Num)
2 % function M=MassVFAssembling3DP1OptV2(nq,nme,me,volumes,Num)
3 % Assembly of the Mass vectors fields Matrix by `P_1`-Lagrange finite elements in 3D
4 % using OptV2 version (see report).
5 %
6 % The Mass vectors fields is given by
7 % ``\MassVF_{i,j}=\int_\DOMH \DOT{\BasisFuncTwoD_m(\q)}{ \BasisFuncTwoD_l(\q)}d(\q), \ \forall (m,l)\in\ENS{1}{3\,\nq}^2,``
8 % where `\BasisFuncTwoD_m` are `P_1`-Lagrange vector basis functions.
9 %
10 % Parameters:
11 % nq: total number of vertices, also denoted by `\nq`.
12 % nme: total number of elements, also denoted by `\nme`.
13 % me: Connectivity array, `4\times\nme` array. <br/>
14 % `\me(\jl,k)` is the storage index of the
15 % `\jl`-th vertex of the `k`-th tetrahedron in the array `\q` of vertices coordinates, `\jl\in\{1,2,3,4\}` and
16 % `k\in{\ENS{1}{\nme}}`.
17 % volumes: Array of volumes, `1\times\nme array`. volumes(k) is the volume
18 % of the k-th tetrahedron.
19 % Num:
20 % - 0 global alternate numbering with local alternate numbering (classical method),
21 % - 1 global block numbering with local alternate numbering,
22 % - 2 global alternate numbering with local block numbering,
23 % - 3 global block numbering with local block numbering.
24 %
25 % Return values:
26 % M: `3\nq\times 3\nq` Global Mass vectors fields sparse matrix
27 %
28 % Example:
29 % @verbatim
30 % Th=CubeMesh(10);
31 % Mvf=MassVFAssembling3DP1OptV2(Th.nq,Th.nme,Th.me,Th.areas,0);@endverbatim
32 %
33 % See also:
34 % #BuildIgJgP1VF, #BuildElemMassVFMatFunc
35 % Copyright:
36 % See \ref license
37 
38 ElemMassVFMat=BuildElemMassVFMatFunc(Num);
39 E=ElemMassVFMat(20);
40 E=E(:)';
41 [Ig,Jg]=BuildIgJgP1VF(Num,me,nq);
42 Kg=zeros(144,nme);
43 
44 It=find(E==2);
45 Vt=volumes/10;
46 for i=It
47  Kg(i,:)=Vt;
48 end
49 
50 It=find(E==1);
51 Vt=volumes/20;
52 for i=It
53  Kg(i,:)=Vt;
54 end
55 
56 M=sparse(Ig(:),Jg(:),Kg(:),3*nq,3*nq);