-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadInpTakeMashFun.m
77 lines (66 loc) · 2.07 KB
/
LoadInpTakeMashFun.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function [Nodes,Elements] = LoadInpTakeMashFun(filename)
%% Get Nodes
filenameNode = [filename '_Nodes'];
filenameEle = [filename '_Elements'];
fidin=fopen([filename '.inp']); % ??txt??
fidout=fopen([filenameNode '.txt'],'w'); % ??MKMATLAB.txt??
file_end_signal = 0;
index = fgetl(fidin);
while isempty(findstr(index,'(1i8,3e20.9e3)'))
index = fgets(fidin);
end
yes = 1;
while ~feof(fidin) % ?????????
tline=fgetl(fidin); % ?????
temp=strfind(tline,' ');
%temp = fgets(fid); %?????
if strfind(tline,'! end of nblock command') %????ESACC?????
break
end
if ~isempty(temp)
str=tline(temp:end);
temp=strfind(str,' ');
temp(4)=length(str)+1;
for m=1:3
fprintf(fidout,'%s ',str(temp(m)+1:temp(m+1)-1));
end
fprintf(fidout,'\r\n');
end
end
fclose(fidout);
%% Get Elements
fidin=fopen([filename '.inp']); % ??txt??
fidout=fopen([filenameEle '.txt'],'w'); % ??MKMATLAB.txt??
file_end_signal = 0;
index = fgetl(fidin);
while isempty(findstr(index,'(19i8)'))
index = fgets(fidin);
end
yes = 1;
while ~feof(fidin) % ?????????
tline=fgetl(fidin); % ?????
temp=strfind(tline,' ');
if strfind(tline,'-1') %????ESACC?????
break
end
if ~isempty(temp)
str=tline(temp:end);
temp=strfind(str,' ');
temp(4)=length(str)+1;
for m=1:3
fprintf(fidout,'%s ',str(temp(m)+1:temp(m+1)-1));
end
fprintf(fidout,'\r\n');
end
end
fclose(fidout);
%% Load Nodes
%load([filenameNode '.txt']);
Nodes=load([filenameNode '.txt']);
%save([filenameNode '.mat'],filenameNode);
%save('node.mat',filenameNode);
%% Load Elements
%load([filenameEle '.txt']);
Elements=load([filenameEle '.txt']);
%save([filenameEle '.mat'],filenameEle);
end