Skip to content

Commit 6ef8bee

Browse files
committed
nastran fixes for long format
1 parent abfbfac commit 6ef8bee

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/meshio/nastran/_nastran.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ def add_cell(nastran_type, cell, cell_ref):
7575

7676
# Treat 2nd order CTETRA, CPYRA, CPENTA, CHEXA elements
7777
if len(cell) > num_nodes_per_cell[cell_type]:
78-
assert cell_type in ["tetra", "pyramid", "wedge", "hexahedron"]
78+
assert cell_type in [
79+
"tetra",
80+
"pyramid",
81+
"wedge",
82+
"hexahedron",
83+
], f"Illegal cell type {cell_type}"
7984
if cell_type == "tetra":
8085
cell_type = "tetra10"
8186
nastran_type = "CTETRA_"
@@ -160,31 +165,30 @@ def add_cell(nastran_type, cell, cell_ref):
160165
# strip chunks
161166
chunks = [chunk.strip() for chunk in chunks]
162167

163-
# remove empty chunks
164-
chunks = [c for c in chunks if c != ""]
165-
166168
keyword = chunks[0]
167169

168170
# Points
169171
if keyword == "GRID":
172+
# remove empty chunks
173+
chunks = [c for c in chunks if c != ""]
170174
point_id = int(chunks[1])
171175
pref = chunks[2].strip()
172176
if len(pref) > 0:
173177
point_refs.append(int(pref))
174178
points_id.append(point_id)
175179
points.append([_nastran_string_to_float(i) for i in chunks[3:6]])
180+
176181
elif keyword == "GRID*": # large field format: 8 + 16*4 + 8
177182
point_id = int(chunks[1] + chunks[2])
178183
pref = (chunks[3] + chunks[4]).strip()
179184
if len(pref) > 0:
180185
point_refs.append(int(pref))
181186
points_id.append(point_id)
182-
chunks2, _ = _chunk_line(next_line)
183-
next_line = f.readline()
184187
points.append(
185188
[
186189
_nastran_string_to_float(i + j)
187-
for i, j in [chunks[5:7], chunks[7:9], chunks2[1:3]]
190+
# TODO why 10:12, not 9:11? check this in the manual
191+
for i, j in [chunks[5:7], chunks[7:9], chunks[10:12]]
188192
]
189193
)
190194

0 commit comments

Comments
 (0)