![]() |
OptFEM2DP1 Toolbox
V1.2
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
|
00001 function R=StiffAssembling2DP1base(nq,nme,q,me,areas) 00002 % function R=StiffAssembling2DP1base(nq,nme,q,me,areas) 00003 % Assembly of the Stiffness Matrix by `P_1`-Lagrange finite elements 00004 % - Basic version (see report). 00005 % 00006 % The Stiffness Matrix `\Stiff` is given by 00007 % ``\Stiff_{i,j}=\int_\DOMH \DOT{\GRAD\FoncBase_i(\q)}{\GRAD\FoncBase_j(\q)}d\q,\ \forall (i,j)\in{\ENS{1}{\nq}}^2`` 00008 % where `\FoncBase_i` are `P_1`-Lagrange basis functions. 00009 % 00010 % Parameters: 00011 % nq: total number of nodes of the mesh, also denoted by `\nq`. 00012 % nme: total number of triangles, also denoted by `\nme`. 00013 % q: Array of vertices coordinates, `2\times\nq` array. <br/> 00014 % `{\q}(\il,j)` is the 00015 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and 00016 % `j\in\ENS{1}{\nq}` 00017 % me: Connectivity array, `3\times\nme` array. <br/> 00018 % `\me(\jl,k)` is the storage index of the 00019 % `\jl`-th vertex of the `k`-th triangle in the array `\q`, `\jl\in\{1,2,3\}` and 00020 % `k\in{\ENS{1}{\nme}}`. 00021 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle. 00022 % 00023 % Return values: 00024 % R: Global stiffness matrix, `\nq\times\nq` sparse matrix. 00025 % 00026 % Example: 00027 % @verbatim 00028 % Th=SquareMesh(10); 00029 % R=StiffAssembling2DP1base(Th.nq,Th.nme,Th.q,Th.me,Th.areas); 00030 % @endverbatim 00031 % 00032 % See also: 00033 % #ElemStiffMat2DP1 00034 % Copyright: 00035 % See \ref license 00036 R=sparse(nq,nq); 00037 for k=1:nme 00038 E=ElemStiffMat2DP1(q(:,me(1,k)),q(:,me(2,k)),q(:,me(3,k)),areas(k)); 00039 for il=1:3 00040 i=me(il,k); 00041 for jl=1:3 00042 j=me(jl,k); 00043 R(i,j)=R(i,j)+E(il,jl); 00044 end 00045 end 00046 end