Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable writing an .inp file from a vtk file to subtract results on particular set(s) #1

Open
wants to merge 2 commits into
base: 4.4.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/meshio/abaqus/_abaqus.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .._helpers import register
from .._mesh import CellBlock, Mesh


abaqus_to_meshio_type = {
# trusses
"T2D2": "line",
Expand Down Expand Up @@ -418,15 +419,26 @@ def _read_set(f, params_map):
return set_ids, set_names, line


def write(filename, mesh, float_fmt=".16e", translate_cell_names=True):
def write(
filename,
mesh,
float_fmt=".16e",
translate_cell_names=True,
is_initial_frame=False,
):
with open_file(filename, "wt") as f:
f.write("*HEADING\n")
f.write("Abaqus DataFile Version 6.14\n")
f.write(f"written by meshio v{__version__}\n")
f.write("*NODE\n")
fmt = ", ".join(["{}"] + ["{:" + float_fmt + "}"] * mesh.points.shape[1]) + "\n"
for k, x in enumerate(mesh.points):
f.write(fmt.format(k + 1, *x))
id_node_iter = (
mesh.point_data["inp_points"][:, 0] if is_initial_frame else count(1)
)

for k, x in zip(id_node_iter, mesh.points):
f.write(fmt.format(k, *x))

eid = 0
for cell_type, node_idcs in mesh.cells:
name = (
Expand All @@ -435,7 +447,11 @@ def write(filename, mesh, float_fmt=".16e", translate_cell_names=True):
f.write(f"*ELEMENT, TYPE={name}\n")
for row in node_idcs:
eid += 1
nids_strs = (str(nid + 1) for nid in row.tolist())
nids_strs = (
(str(mesh.point_data["inp_points"][nid, 0]) for nid in row.tolist())
if is_initial_frame
else (str(nid + 1) for nid in row.tolist())
)
f.write(str(eid) + "," + ",".join(nids_strs) + "\n")

nnl = 8
Expand Down