-
Notifications
You must be signed in to change notification settings - Fork 0
/
WriteNewInpFun2_2_2.m
112 lines (96 loc) · 2.78 KB
/
WriteNewInpFun2_2_2.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function [filenameTemp] = WriteNewInpFun2_2_2(node,element,CTimes,inpfilename,Ver,CVer)
% inpfilename = 'TTT20161013drop';
CTimes = num2str(CTimes);
% load restNode7.mat
% load restElem7.mat
% Node = num2str(restNode9);
%% Create New file
filenameTemp = [inpfilename CVer '_V' num2str(Ver) '_' CTimes];
fidin=fopen([inpfilename '.inp']);
%% Write p1
fidout=fopen([filenameTemp '.txt'],'w'); % ??MKMATLAB.txt??
%
while ~feof(fidin) % ?????????
tline=fgetl(fidin);
if strfind(tline,'(1i8,3e20.9e3)') %????ESACC?????
break
end
if ~isempty(tline)
str=tline;
fprintf(fidout,'%s ',str);
end
fprintf(fidout,'\r\n');
end
fprintf(fidout,'%s ','(1i8,3e20.9e3)');
fprintf(fidout,'\r\n');
%fclose(fidout);
%
%% Put in Nodes
formatSpec = ' %7.0f %19.9e %19.9e %19.9e\r\n';
fprintf(fidout,formatSpec,node');
%
%% Write p2
file_end_signal = 0;
index2 = fgetl(fidin);
while isempty(findstr(index2,'! end of nblock command'))
index2 = fgets(fidin);
end
yes = 1;
fprintf(fidout,'%s ','! end of nblock command');
fprintf(fidout,'\r\n');
while ~feof(fidin) % ?????????
tline=fgetl(fidin);
if strfind(tline,'(19i8)') %????ESACC?????
break
end
if ~isempty(tline)
str=tline;
fprintf(fidout,'%s ',str);
end
fprintf(fidout,'\r\n');
end
fprintf(fidout,'%s ','(19i8)');
fprintf(fidout,'\r\n');
%% Put in Element
formatSpec2 = ' %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f %7.0f\r\n';
fprintf(fidout,formatSpec2,element');
%% Write p3
file_end_signal = 0;
index3 = fgetl(fidin);
while isempty(findstr(index3,'-1'))
index3 = fgets(fidin);
end
yes = 1;
fprintf(fidout,'%s ','-1');
fprintf(fidout,'\r\n');
while ~feof(fidin) % ?????????
tline=fgetl(fidin);
if strfind(tline,'/GOPR') %????ESACC?????
break
end
if ~isempty(tline)
str=tline;
fprintf(fidout,'%s ',str);
end
fprintf(fidout,'\r\n');
end
fprintf(fidout,'%s ','/GOPR');fprintf(fidout,'\r\n');
fprintf(fidout,'%s ','!');fprintf(fidout,'\r\n');
fprintf(fidout,'%s ','FINI');fprintf(fidout,'\r\n');
fprintf(fidout,'\r\n');
fprintf(fidout,'%s ','/GOPR');fprintf(fidout,'\r\n');
fclose(fidout);
%% Change txt to inp
%
fidin2=fopen([filenameTemp '.txt']);
fidout2=fopen([filenameTemp '.inp'],'w'); % ??MKMATLAB.txt??
while ~feof(fidin2) % ?????????
tline=fgetl(fidin2); % ?????
if ~isempty(tline)
str=tline;
fprintf(fidout2,'%s ',str);
end
fprintf(fidout2,'\r\n');
end
fclose(fidout2);
end