forked from dplab/MechMet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadNeperMesh.m
58 lines (53 loc) · 998 Bytes
/
ReadNeperMesh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function m = ReadNeperMesh(fname)
% ReadNeperMesh - read neper mesh from a file
%
% STATUS: in development: usable
%
% USAGE:
%
% m = ReadNeperMesh(fname, <options>)
%
% INPUT:
%
% fname is a string for the full name of the mesh files to be read;
%
% OUTPUT:
%
% m is a structure (see MeshStructure)
%
% NOTES:
%
% * Currently only 10-node tets are available
% * Currently, connectivity is returned in fepx order
%
meshfile = [fname,'.mesh'];
%
fid = fopen(meshfile, 'r');
%
% Header line
%
parms = fscanf(fid, '%d', 3);
numel = parms(1);
numnp = parms(2);
perel = parms(3) + 1;
%
% Read connectivity.
%
con = fscanf(fid, '%d', (perel+1)*numel);
con = reshape(con, [(perel+1), numel]);
con = con(2:end, :) + 1;
%
% Read coordinates.
%
tmp = fscanf(fid, '%d %f %f %f', 4*numnp);
tmp = reshape(tmp, [4, numnp]);
%
crd = tmp(2:4, :);
%
% *** To Be Done: read surface information
%
fclose(fid);
%
m = MeshStructure(crd, con, [], 'ElementType', 'tets:10');
m.name = fname;
%