rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
load_alu3d_hexa.m
1 function M = load_alu3d_hexa(fn)
2 %function M = load_alu3D_hexa(fn)
3 %
4 % load given ALU3D hexaeder file into mesh-structure M
5 % resulting fields:
6 % num_vertices number of vertices
7 % vertices matrix of vertex coordinates (columnwise)
8 % num_elements number of elements
9 % elements matrix of element vertex indices (columnwise)
10 % num_faces number of boundary faces
11 % faces matrix of boundary faces (columnwise)
12 %
13 % note that the numbering of the vertices in elements and faces is
14 % C-style, i.e. starting from 0
15 % for working in matlab, the offset 1 has to be added, e.g.
16 % z-coordinates of 2nd vertex of element 5 is
17 % vertices(3,M.elements(2,5)+1);
18 % The boundary faces are coded by 6 integers (for hexamesh)
19 % \#bndtypeId \#nvertices=4 \#vind1 \#vind2 \#vind3 \#vind4
20 
21 % Bernard Haasdonk 13.3.2006
22 
23  clear('M');
24 
25  fid = fopen(fn,'r');
26  e = fscanf(fid,'%s',1);
27  if ~isequal(e,'!Hexaeder')
28  keyboard
29  error('wrong file format');
30  end;
31 
32  % load vertex number
33  M.num_vertices = fscanf(fid,'%d',1);
34 
35  % load vertices
36  disp(['reading ',num2str(M.num_vertices),' vertices']);
37  M.vertices = reshape(fscanf(fid,'%f',M.num_vertices*3),3,M.num_vertices);
38 
39  % load element number
40  M.num_elements = fscanf(fid,'%d',1);
41 
42  % load elements
43  disp(['reading ',num2str(M.num_elements),' elements']);
44  M.elements = reshape(fscanf(fid,'%d',...
45  M.num_elements * 8),8,M.num_elements);
46 
47  % load boundary segment number
48  M.num_faces = fscanf(fid,'%d',1);
49 
50  % load boundary segments
51  disp(['reading ',num2str(M.num_faces),' boundary faces']);
52  M.faces = reshape(fscanf(fid,'%d',M.num_faces*6),6,M.num_faces);
53 
54 % disp('ignoring occasionally processor-distribution information');
55 
56  fclose(fid);
57 
58 
59 % TO BE ADJUSTED TO NEW SYNTAX
60 %| \docupdate