OptFEM2D Toolbox for Matlab  V1.2b1
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
ComputeAreaOpt.m
Go to the documentation of this file.
1 function area=ComputeAreaOpt(q,me)
2 % function area=ComputeAreaOpt(q,me)
3 % Computation of areas of triangles in the mesh
4 % - Optimized version
5 %
6 % Parameters:
7 % q: Array of vertices coordinates, `2\times\nq` array. <br/>
8 % `{\q}(\il,j)` is the
9 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
10 % `j\in\ENS{1}{\nq}`
11 % me: Connectivity array, `3\times\nme` array.<br/>
12 % `\me(\jl,k)` is the storage index of the
13 % `\jl`-th vertex of the `k`-th triangle in the array `\q` of vertices coordinates, `\jl\in\{1,2,3\}` and
14 % `k\in{\ENS{1}{\nme}}`.
15 %
16 % Return values:
17 % area: Array of areas, `1\times\nme` array. area(k) is the area of the `k`-th triangle.
18 %
19 % OptFEM2DP1 [V1.2b1] - Copyright (C) 2013 CJS (LAGA)
20 %
21 % This file is part of OptFEM2DP1.
22 % OptFEM2DP1 is free software: you can redistribute it and/or modify
23 % it under the terms of the GNU General Public License as published by
24 % the Free Software Foundation, either version 3 of the License, or
25 % (at your option) any later version.
26 %
27 % OptFEM2DP1 is distributed in the hope that it will be useful,
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 % GNU General Public License for more details.
31 %
32 % You should have received a copy of the GNU General Public License
33 % along with this program. If not, see <http://www.gnu.org/licenses/>.
34 c1 = q(:,me(1,:));
35 d21 = q(:,me(2,:))-c1;
36 d31 = q(:,me(3,:))-c1;
37 area = 0.5*(d21(1,:).*d31(2,:)-d21(2,:).*d31(1,:));