| OptFEM2D Toolbox for Matlab V1.2b1 Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D

- Main Page
- Related Pages
- Files

- File List
- File Members

All Files Functions Pages
StiffAssemblingP1OptV0.m
Go to the documentation of this file.
1 function R=StiffAssemblingP1OptV0(nq,nme,q,me,areas)
2 % function R=StiffAssemblingP1OptV0(nq,nme,q,me,areas)
3 % Assembly of the Stiffness Matrix using `P_1`-Lagrange finite elements
4 % - OptV0 version (see report).
5 %
6 % The Stiffness Matrix `\Stiff` is given by
7 % ``\Stiff_{i,j}=\int_\DOMH \DOT{\GRAD\FoncBase_i(\q)}{\GRAD\FoncBase_j(\q)}d\q,\ \forall (i,j)\in{\ENS{1}{\nq}}^2``
8 % where `\FoncBase_i` are `P_1`-Lagrange basis functions.
9 %
10 % Parameters:
11 % nq: total number of nodes of the mesh, also denoted by `\nq`.
12 % nme: total number of triangles, also denoted by `\nme`.
13 % q: Array of vertices coordinates, `2\times\nq` array. <br/>
14 % `{\q}(\il,j)` is the
15 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
16 % `j\in\ENS{1}{\nq}`
17 % me: Connectivity array, `3\times\nme` array.<br/>
18 % `\me(\jl,k)` is the storage index of the
19 % `\jl`-th vertex of the `k`-th triangle in the array `\q` of vertices coordinates, `\jl\in\{1,2,3\}` and
20 % `k\in{\ENS{1}{\nme}}`.
21 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
22 %
23 % Return values:
24 % R: Stiffness Matrix, `\nq\times\nq` sparse matrix.
25 %
26 % Example:
27 % @verbatim
28 % Th=SquareMesh(10);
29 % R=StiffAssemblingP1OptV0(Th.nq,Th.nme,Th.me,Th.q,Th.areas);
30 % @endverbatim
31 %
32 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
33 %
34 % This file is part of OptFEM2DP1.
35 % OptFEM2DP1 is free software: you can redistribute it and/or modify
36 % it under the terms of the GNU General Public License as published by
37 % the Free Software Foundation, either version 3 of the License, or
38 % (at your option) any later version.
39 %
40 % OptFEM2DP1 is distributed in the hope that it will be useful,
41 % but WITHOUT ANY WARRANTY; without even the implied warranty of
42 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 % GNU General Public License for more details.
44 %
45 % You should have received a copy of the GNU General Public License
46 % along with this program. If not, see <http://www.gnu.org/licenses/>.
47 R=sparse(nq,nq);
48 for k=1:nme
49 I=me(:,k);
50 Me=ElemStiffMatP1(q(:,me(1,k)),q(:,me(2,k)),q(:,me(3,k)),areas(k));
51 R(I,I)=R(I,I)+Me;
52 end