3 % Initialization of the Mesh structure from a FreeFEM++ mesh file
7 % cFileName: FreeFEM++ mesh file name (
string)
10 % Mesh: mesh structure
12 % Generated fields of Mesh:
13 % nq: total number of vertices.
14 % q: Array of vertices coordinates, 3-by-nq array.
15 % q(il,j) is the il-th coordinate of the j-th vertex, il in {1,3}
16 % and j in {1,...,nq}.
17 % ql: Array of vertices labels, 1-by-nq array.
18 % nme: total number of elements.
19 % me: Connectivity array, 4-by-nme array.
20 % me(jl,
k) is the storage index of the jl-th vertex
21 % of the k-th triangle in the array q of vertices coordinates,
22 % jl in {1,..,4} and
k in {1,...,nme}.
23 % mel: Array of elements labels, 1-by-nme array.
24 % nbf: total number of boundary faces, also denoted by `\nbf`
25 % bf: Connectivity array for boundary faces, 3-by-nbf array.
26 % bf(il,l) is the storage index of the il-th vertex
27 % of the l-th boundary face in the array q of vertices coordinates,
28 % il in {1,3} and l in {1,...,nbf}.
29 % bfl: Array of boundary faces labels, 1-by-nbf array.
30 % volumes: Array of volumes, 1-by-nme array. volumes(
k) is the volume
31 % of the k-th triangle.
32 % abf: Array of faces areas, 1-by-nbf array. abf(j) is
33 % the area of the j-th boundary face.
36 % Th=GetMesh('cube.mesh')
41 % Copyright (C) 2013 CJS (LAGA)
42 % see README for details
43 [fid,message]=fopen(cFileName,'r');
45 error([message,
' : ',cFileName]);
51 nq=fscanf(fid,'%d',1);
53 R=fscanf(fid,'%f %f %f %d',[4,nq]);
59 nme=fscanf(fid,'%d',1);
60 R=fscanf(fid,'%d %d %d %d %d',[5,nme]);
67 nbf=fscanf(fid,'%d',1);
68 R=fscanf(fid,'%d %d %d %d',[4,nbf]);
73 nq=fscanf(fid,'%d',1);
75 R=textscan(fid,'%f %f %f %d',nq);
82 nme=fscanf(fid,
'%ld',1);
84 R=textscan(fid,
'%d %d %d %d %d',nme);
85 me=[R{1},R{2},R{3},R{4}]
';
90 nbf=fscanf(fid,
'%d',1);
92 R=textscan(fid,
'%d %d %d %d',nbf);
98 Mesh=
struct(
'q',q,
'me',double(me),
'ql',ql,
'mel',double(mel),
'bf',double(bf),
'bfl',double(bfl), ...
103 'abf',FaceArea(bf,q));