|
1 | | -function [nodes] = Input_NodeDatRead(fname, StressData, numNodes) |
2 | | -%% Description |
3 | | -% This script builds node objects from the stress data read in from |
4 | | -% nodeDat.m. The initial reason this was not implemented in one parse was |
5 | | -% inconsistent node's coming from the files. This seemed to be happening |
6 | | -% when ANSYS would delete midside nodes, hence not storing their stress |
7 | | -% values, but keeping the numbering system. I built this as a workaround. |
8 | | -% |
9 | | -% Since then however, I cam up with a better way of doing this which I am |
10 | | -% yet to implement for nodes, but implemented for elements. |
11 | | - |
12 | | - clear nodes |
13 | | - if ismac |
14 | | - path_separator = '/'; |
15 | | - elseif ispc |
16 | | - path_separator = '\'; |
17 | | - end |
18 | | - fname = strjoin([fname path_separator 'ds.dat'],''); |
19 | | - |
20 | | - nodeNums = StressData(1,:); |
21 | | - xstress = StressData(2,:); |
22 | | - ystress = StressData(3,:); |
23 | | - zstress = StressData(4,:); |
24 | | - xystress = StressData(5,:); |
25 | | - yzstress = StressData(6,:); |
26 | | - xzstress = StressData(7,:); |
27 | | - |
28 | | - %Opening file and scanning to the first useful string. |
29 | | - datafile = fopen(fname); |
30 | | - |
31 | | - trashdata = 'a'; |
32 | | - startelements = '/com,*********** Nodes '; |
33 | | - |
34 | | - while ~strncmpi(trashdata,startelements, 23) |
35 | | - trashdata = fgetl(datafile); |
36 | | - end |
37 | | - |
38 | | - nid = 'a'; |
39 | | - |
40 | | - while ~strncmpi(nid(1), '(', 1) |
41 | | - nid = strtrim(fgetl(datafile)); |
42 | | - end |
43 | | - |
44 | | - nodes(1,numNodes) = Input_Node(); |
45 | | - |
46 | | - linetest = fgetl(datafile); |
47 | | - linetest = strsplit(linetest); |
48 | | - linetest = str2double(linetest); |
49 | | - |
50 | | - %Building node objects to store stress data |
51 | | - i = 1; |
52 | | - while linetest(1) ~= -1 |
53 | | - if i == linetest(2) |
54 | | - |
55 | | - nodes(i) = Input_Node(linetest(2), linetest(3), linetest(4),linetest(5),... |
56 | | - xstress(i), ystress(i),zstress(i),xystress(i),... |
57 | | - yzstress(i),xzstress(i)); |
58 | | - linetest = fgetl(datafile); |
59 | | - linetest = strsplit(linetest); |
60 | | - linetest = str2double(linetest); |
61 | | - else |
62 | | - nodes(i) = Node(i, NaN, NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN); |
63 | | - end |
64 | | - |
65 | | - i = i+1; |
66 | | - end |
67 | | - fclose(datafile); |
68 | | -end |
| 1 | +function [nodes] = Input_NodeDatRead(fname, StressData, numNodes) |
| 2 | +%% Description |
| 3 | +% This script builds node objects from the stress data read in from |
| 4 | +% nodeDat.m. The initial reason this was not implemented in one parse was |
| 5 | +% inconsistent node's coming from the files. This seemed to be happening |
| 6 | +% when ANSYS would delete midside nodes, hence not storing their stress |
| 7 | +% values, but keeping the numbering system. I built this as a workaround. |
| 8 | +% |
| 9 | +% Since then however, I cam up with a better way of doing this which I am |
| 10 | +% yet to implement for nodes, but implemented for elements. |
| 11 | + |
| 12 | + clear nodes |
| 13 | + path_separator = '/'; |
| 14 | + if ispc |
| 15 | + path_separator = '\'; |
| 16 | + end |
| 17 | + fname = strjoin([fname path_separator 'ds.dat'],''); |
| 18 | + |
| 19 | + nodeNums = StressData(1,:); |
| 20 | + xstress = StressData(2,:); |
| 21 | + ystress = StressData(3,:); |
| 22 | + zstress = StressData(4,:); |
| 23 | + xystress = StressData(5,:); |
| 24 | + yzstress = StressData(6,:); |
| 25 | + xzstress = StressData(7,:); |
| 26 | + |
| 27 | + %Opening file and scanning to the first useful string. |
| 28 | + datafile = fopen(fname); |
| 29 | + |
| 30 | + trashdata = 'a'; |
| 31 | + startelements = '/com,*********** Nodes '; |
| 32 | + |
| 33 | + while ~strncmpi(trashdata,startelements, 23) |
| 34 | + trashdata = fgetl(datafile); |
| 35 | + end |
| 36 | + |
| 37 | + nid = 'a'; |
| 38 | + |
| 39 | + while ~strncmpi(nid(1), '(', 1) |
| 40 | + nid = strtrim(fgetl(datafile)); |
| 41 | + end |
| 42 | + |
| 43 | + nodes(1,numNodes) = Input_Node(); |
| 44 | + |
| 45 | + linetest = fgetl(datafile); |
| 46 | + linetest = strsplit(linetest); |
| 47 | + linetest = str2double(linetest); |
| 48 | + |
| 49 | + %Building node objects to store stress data |
| 50 | + i = 1; |
| 51 | + while linetest(1) ~= -1 |
| 52 | + if i == linetest(2) |
| 53 | + |
| 54 | + nodes(i) = Input_Node(linetest(2), linetest(3), linetest(4),linetest(5),... |
| 55 | + xstress(i), ystress(i),zstress(i),xystress(i),... |
| 56 | + yzstress(i),xzstress(i)); |
| 57 | + linetest = fgetl(datafile); |
| 58 | + linetest = strsplit(linetest); |
| 59 | + linetest = str2double(linetest); |
| 60 | + else |
| 61 | + nodes(i) = Node(i, NaN, NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN); |
| 62 | + end |
| 63 | + |
| 64 | + i = i+1; |
| 65 | + end |
| 66 | + fclose(datafile); |
| 67 | +end |
0 commit comments