2 %
function Mesh=
GetMesh(cFileName)
3 % Initialization of the Mesh structure from a FreeFEM++ mesh file -
8 % cFileName: FreeFEM++ mesh file name (
string)
11 % Mesh: mesh structure
13 % Generated fields of Mesh:
14 % q: Array of vertices coordinates, `2\times\nq` array. <br/>
15 % `{\q}(\il,j)` is the
16 % `\il`-th coordinate of the `j`-th vertex, `\il\in\{1,2\}` and
18 % me: Connectivity array, `3\times\nme` array. <br/>
19 % `\me(\jl,k)` is the storage index of the
20 % `\jl`-th vertex of the `k`-th triangle in the array `\q` of vertices coordinates, `\jl\in\{1,2,3\}` and
21 % `k\in{\ENS{1}{\nme}}`.
22 % ql: Array of vertices labels, `1\times\nq` array.
23 % mel: Array of elements labels, `1\times\nme` array.
24 % be: Connectivity array
for boundary edges, `2\times\nbe` array.<br/>
25 % `\be(\il,l)` is the storage index of the
26 % `\il`-th vertex of the `l`-th edge in the array `\q` of vertices coordinates, `\il\in\{1,2\}` and
27 % `l\in{\ENS{1}{\nbe}}`.
28 % bel: Array of boundary edges labels, `1\times\nbe` array.
29 % nq: total number of vertices, also denoted by `\nq`
30 % nme: total number of elements, also denoted by `\nme`
31 % nbe: total number of boundary edges, also denoted by `\nbe`
32 % areas: Array of areas, `1\times\nme` array. areas(k) is the area of the `k`-th triangle.
33 % lbe: Array of edges lengths, `1\times\nbe` array. `\lbe(j)` is the length of the `j`-th edge.
36 %
#ComputeAreaOpt, #EdgeLength
48 % @author François Cuvelier
51 [fid,message]=fopen(cFileName,
'r');
53 error([message,
' : ',cFileName]);
56 [n]=fscanf(fid,
'%d %d %d',3);
58 R=fscanf(fid,
'%f %f %d',[3,n(1)]);
61 R=fscanf(fid,
'%d %d %d %d',[4,n(2)]);
65 R=fscanf(fid,
'%d %d %d',[3,n(3)]);
70 n=textscan(fid,
'%d %d %d',1); % n(1) -> number of vertices
71 % n(2) -> number of triangles
72 % n(3) -> number of boundary edges
74 R=textscan(fid,
'%f %f %d',n{1});
77 R=textscan(fid,
'%d %d %d %d',n{2});
81 R=textscan(fid,
'%d %d %d',n{3});
87 Mesh=
struct(
'q',q,
'me',double(me),
'ql',ql,
'mel',double(mel), ...
88 'be',double(be),
'bel',double(bel), ...