OptFEM2D  0.1
Matlab optimized FEM2D
 All Files Functions Groups Pages
GetMesh.m
Go to the documentation of this file.
1 function Mesh=GetMesh(cFileName)
2 % function Mesh=GetMesh(cFileName)
3 % Initialization of the Mesh structure from a FreeFEM++ mesh file
4 %
5 % Description plus longue...
6 %
7 % Parameters:
8 % cFileName: file name (string)
9 %
10 % Return values:
11 % Mesh: mesh structure
12 %
13 % Generated fields of Mesh:
14 % q: @code $\int_a^b f(x) dx$ @endcode
15 % me:
16 %
17 % usage: Th=GetMesh('carre.msh')
18 % This program is open source. For license terms, see the COPYING file.
19 %
20 % --------------------------------------------------------------------
21 % ATTRIBUTION NOTICE:
22 % This product includes software developed for the RBmatlab project at
23 % (C) Universities of Stuttgart and Münster, Germany.
24 %
25 % RBmatlab is a MATLAB software package for model reduction with an
26 % emphasis on Reduced Basis Methods. The project is maintained by
27 % M. Dihlmann, M. Drohmann, B. Haasdonk, M. Ohlberger and M. Schaefer.
28 % For Online Documentation and Download we refer to www.morepas.org.
29 % --------------------------------------------------------------------
30 [fid,message]=fopen(cFileName,'r');
31 if ( fid == -1 )
32  error([message,' : ',cFileName]);
33 end
34 n=fscanf(fid,'%d',3); ; % n(1) -> number of vertices
35  % n(2) -> number of triangles
36  % n(3) -> number of boundary edges
37 me=zeros(3,n(2));
38 ql=zeros(1,n(1));
39 q=zeros(2,n(1));
40 mel=zeros(1,n(2));
41 for i=1:n(1)
42  d_tmp=fscanf(fid,'%g',2);
43  q(1,i)=d_tmp(1);
44  q(2,i)=d_tmp(2);
45  ql(i)=fscanf(fid,'%d',1);
46 end
47 for i=1:n(2)
48  i_tmp=fscanf(fid,'%d',4);
49  me(1,i)=i_tmp(1);
50  me(2,i)=i_tmp(2);
51  me(3,i)=i_tmp(3);
52  mel(i)=i_tmp(4);
53 end
54 
55 for i=1:n(3)
56  i_tmp=fscanf(fid,'%d',3);
57  be(1,i)=i_tmp(1);
58  be(2,i)=i_tmp(2);
59  bel(i) =i_tmp(3);
60 end
61 
62 fclose(fid);
63 
64 Mesh=struct('q',q,'me',me,'ql',ql,'mel',mel,'be',be,'bel',bel, ...
65  'nq',size(q,2), ...
66  'nme',size(me,2), ...
67  'nbe',size(be,2), ...
68  'areas',ComputeArea(q,me),...
69  'lbe',EdgeLength(be,q));