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