-
Notifications
You must be signed in to change notification settings - Fork 0
/
mOP2block_ONR.m
179 lines (162 loc) · 5.44 KB
/
mOP2block_ONR.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
classdef mOP2block_ONR < mOP2block
%OP2BLOCK_ONR Reads table of strain energies
% OP2BLOCK_OQG reads the table of strain energies
% from a NASTRAN binary output 2 file.
%
% BLOCKINFO is the structure describing the block.
% DATA is a structure, containing the following fields:
%
% DATA(I), with I = 1:numel(DATA)
% |- TCODE
% |- ACODE
% |- ETOTAL
% |- SUBCASE
% |- MODE
% |- ELNAME
% |- LOADSET
% |- FCODE
% |- NUMWDE
% |- CVALRES
% |- ESUBT
% |- SETID
% |- EIGENR
% |- EIGENI
% |- FREQ
% |- ETOTPOS
% |- ETOTNEG
% |- TITLE
% |- SUBTITL
% |- LABEL
% |- EKEY
% |- ENERGY
% |- PCT
% |- DEN
%
% Note: fields marked with (*) are present only in the appropriate cases.
%
% Block described in ???.
% See also MOP2READ, MOP2INFO, MOP2BLOCK, MOP2BLOCK_*.
% $Revision: 1.1.0 $ $Date: 2022/09/08 $
%% Disclaimer
% Copyright (c) 2022 Giulio Molinari
%
% This file is part of mOP2.
% mOP2 is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% any later version. Also see the file "LICENSE".
properties
end % properties
properties(SetAccess=private)
end % properties(SetAccess=protected)
properties(Access=private)
data_copy
data_set = false
end % properties(Access=private)
properties(SetAccess=private, Dependent = true)
data
end % properties(SetAccess=private, Dependent = true)
methods
function block = mOP2block_ONR(blockInfo, fid, tableFmt)
block = block@mOP2block(blockInfo, fid, tableFmt);
block.interpreter = 'ONR';
end % mOP2block_ONR
function data = get.data(block)
if block.data_set == true
data = block.data_copy;
return
end
fid = block.fid;
blockInfo = block.blockInfo;
if isempty(strmatch('ONR', blockInfo.name))
error('mOP2block_ONR: Wrong block type')
end
for recordID = 1:(length(blockInfo.record)-1)/2
%% RECORD 1: IDENT
fseek(fid, blockInfo.record(recordID*2 - 1).TablesStart + 4, -1);
data(recordID).ACODE = fread(fid, 1, 'int32');
data(recordID).TCODE = fread(fid, 1, 'int32');
data(recordID).ETOTAL = fread(fid, 1, 'float32');
data(recordID).SUBCASE = fread(fid, 1, 'int32');
switch mOP2block.functionCodes(data(recordID).ACODE, 4)
case {0 1 3 4 7 11}
fseek(fid, 1*4, 0);
case {2 8 9} % Real and Complex Eigenvalues
data(recordID).MODE = fread(fid, 1, 'int32');
case {5}
data(recordID).EIGN = fread(fid, 1, 'float32');
case {6}
data(recordID).TIME = fread(fid, 1, 'float32');
case {10} % Nonlinear static
data(recordID).LOADFAC = fread(fid, 1, 'float32');
otherwise
warning('mOP2block_ONR: ACODE %d not implemented', data(recordID).ACODE)
fseek(fid, 1*4, 0);
end
data(recordID).ELNAME = sprintf('%c', fread(fid, 2*4, 'char'));
data(recordID).LOADSET = fread(fid, 1, 'int32');
data(recordID).FCODE = fread(fid, 1, 'int32');
data(recordID).NUMWDE = fread(fid, 1, 'int32');
data(recordID).CVALRES = fread(fid, 1, 'int32');
data(recordID).ESUBT = fread(fid, 1, 'float32');
data(recordID).SETID = fread(fid, 1, 'int32');
data(recordID).EIGENR = fread(fid, 1, 'float32');
data(recordID).EIGENI = fread(fid, 1, 'float32');
data(recordID).FREQ = fread(fid, 1, 'float32');
fseek(fid, 1*4, 0);
data(recordID).ETOTPOS = fread(fid, 1, 'float32');
data(recordID).ETOTNEG = fread(fid, 1, 'float32');
fseek(fid, 1*4, 0);
data(recordID).TITLE = sprintf('%c', fread(fid, 32*4, 'char'));
data(recordID).SUBTITL = sprintf('%c', fread(fid, 32*4, 'char'));
data(recordID).LABEL = sprintf('%c', fread(fid, 32*4, 'char'));
%% RECORD 2: DATA
fseek(fid, blockInfo.record(recordID*2).TablesStart(1), -1);
fseek(fid, 1*4, 0);
curTablePos = 0;
curTable = 1;
TablesLength = blockInfo.record(recordID*2).TablesLength;
data(recordID).num_entries = sum(TablesLength) / (data(recordID).NUMWDE);
% Read all data
FloatData = block.readMatrix(blockInfo.record(recordID*2), data(recordID), 'float32');
IntData = block.readMatrix(blockInfo.record(recordID*2), data(recordID), 'int32');
CharData = block.readMatrix(blockInfo.record(recordID*2), data(recordID), 'int8=>char');
switch mOP2block.functionCodes(data(recordID).TCODE, 1)
case 1
switch data(recordID).NUMWDE
case 4
EKEY = IntData(:,1);
data(recordID).ElementID = floor(EKEY*.1);
case 5
data(recordID).DMIGNAME = CharData(:,1);
end
case 2
switch mOP2block.functionCodes(data(recordID).ACODE, 4)
case {0}
case {1 2 3 4 7 8 9 11 12}
EKEY = IntData(:,1);
data(recordID).ElementID = floor(EKEY*.1);
case {5}
data(recordID).FREQ = FloatData(:,1);
case {6}
data(recordID).TIME = FloatData(:,1);
case 10
data(recordID).FQTS = FloatData(:,1);
end
end
% data(recordID).Value = FloatData(:,2:4);
dataType = ['nnff'];
% Create output data
if numel(dataType) > 0
data(recordID).Value = block.buildTable(dataType, IntData, FloatData, CharData);
end
end
% If the record is empty, initialize "data" as []
if length(blockInfo.record)-1 == 0
data = [];
end
block.data_set = true;
block.data_copy = data;
end % get.data
end % methods
end