Skip to content

Commit

Permalink
Merge pull request nschloe#375 from nschloe/test-coverage
Browse files Browse the repository at this point in the history
Test coverage
  • Loading branch information
nschloe authored Apr 5, 2019
2 parents 2cb2597 + 81ec842 commit e6bb038
Show file tree
Hide file tree
Showing 4 changed files with 353 additions and 292 deletions.
59 changes: 31 additions & 28 deletions meshio/abaqus_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
#
# "PYRAMID": "pyramid",
"C3D6": "wedge",
#
# 4-node bilinear displacement and pore pressure
"CAX4P": "quad",
}
meshio_to_abaqus_type = {v: k for k, v in abaqus_to_meshio_type.items()}

Expand Down Expand Up @@ -111,33 +114,33 @@ def read_buffer(f):
# EOF
break

if line.startswith("*"):
word = line.strip("*").upper()
if word == "HEADING":
pass
elif word.startswith("PREPRINT"):
pass
elif word.startswith("NODE"):
points, point_gids = _read_nodes(f)
elif word.startswith("ELEMENT"):
key, idx = _read_cells(f, word, point_gids)
cells[key] = idx
elif word.startswith("NSET"):
params_map = get_param_map(word, required_keys=["NSET"])
setids = read_set(f, params_map)
name = params_map["NSET"]
if name not in nsets:
nsets[name] = []
nsets[name].append(setids)
elif word.startswith("ELSET"):
params_map = get_param_map(word, required_keys=["ELSET"])
setids = read_set(f, params_map)
name = params_map["ELSET"]
if name not in elsets:
elsets[name] = []
elsets[name].append(setids)
else:
pass
# Comments
if line.startswith("**"):
continue

keyword = line.strip("*").upper()
if keyword.startswith("NODE"):
points, point_gids = _read_nodes(f)
elif keyword.startswith("ELEMENT"):
key, idx = _read_cells(f, keyword, point_gids)
cells[key] = idx
elif keyword.startswith("NSET"):
params_map = get_param_map(keyword, required_keys=["NSET"])
setids = read_set(f, params_map)
name = params_map["NSET"]
if name not in nsets:
nsets[name] = []
nsets[name].append(setids)
elif keyword.startswith("ELSET"):
params_map = get_param_map(keyword, required_keys=["ELSET"])
setids = read_set(f, params_map)
name = params_map["ELSET"]
if name not in elsets:
elsets[name] = []
elsets[name].append(setids)
else:
# There are just too many Abaqus keywords to explicitly skip them.
pass

return Mesh(
points, cells, point_data=point_data, cell_data=cell_data, field_data=field_data
Expand Down Expand Up @@ -177,7 +180,7 @@ def _read_cells(f, line0, point_gids):
while True:
last_pos = f.tell()
line = f.readline()
if line.startswith("*"):
if line.startswith("*") or line == "":
break
entries = [int(k) for k in filter(None, line.split(","))]
idx = [point_gids[k] for k in entries[1:]]
Expand Down
Loading

0 comments on commit e6bb038

Please sign in to comment.