OptFEM2DP1 Toolbox  V1.2b3
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
ElemStiffMatP1.m
Go to the documentation of this file.
1 function AElem=ElemStiffMatP1(q1,q2,q3,area)
2 % function AElem=ElemStiffMatP1(q1,q2,q3,area)
3 % Computation of the element stiffness matrix for
4 % `P_1`-Lagrange finite elements
5 %
6 % Parameters:
7 % q1: Coordinates of the first vertex in the triangle, `2\times 1` array
8 % q2: Coordinates of the second vertex in the triangle, `2\times 1` array
9 % q3: Coordinates of the third vertex in the triangle, `2\times 1` array
10 % area: triangle area
11 %
12 % Return values:
13 % AElem: Element stiffness matrix, `3\times 3` matrix
14 %
15 % Example:
16 % @verbatim
17 % q1=[0;0];q2=[0;1];q3=[1;0];
18 % area=1/2.;
19 % AElem=ElemStiffMatP1(q1,q2,q3,area);
20 % @endverbatim
21 % Copyright:
22 % See \ref license
23 M=[q2-q3, q3-q1, q1-q2];
24 AElem=(1/(4*area))*M'*M;