Skip to content

Commit b11cd26

Browse files
committed
Fix wrong writing of material pointers and string encoding
1 parent db1e5a5 commit b11cd26

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lasso/dyna/d3plot.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6620,7 +6620,7 @@ def _write_geom_particle_flags(self, fp: typing.IO[Any], settings: D3plotWriterS
66206620
# only the first byte to the ascii char code
66216621
fmt_string = "{0:" + str(settings.wordsize) + "}"
66226622
for name, _ in nlist_names_typecodes:
6623-
name_formatted = fmt_string.format(name).encode("ascii")
6623+
name_formatted = fmt_string.format(name).encode("utf-8")
66246624
for ch in name_formatted:
66256625
barray = bytearray(settings.wordsize)
66266626
barray[0] = ch
@@ -6836,16 +6836,17 @@ def _write_geom_user_ids(self, fp: typing.IO[Any], settings: D3plotWriterSetting
68366836
n_bytes_written += fp.write(settings.pack(nsrtd))
68376837

68386838
if ArrayType.part_ids in self.arrays:
6839-
# some lsdyna material pointer
6840-
nsrma = info.ptr_material_ids
6841-
n_bytes_written += fp.write(settings.pack(nsrma))
6839+
# some lsdyna material pointer - Used by LS-Prepost in labelling materials
68426840

6843-
# some lsdyna material pointer
6844-
nsrmu = info.ptr_material_ids_defined_order
6845-
n_bytes_written += fp.write(settings.pack(nsrmu))
6841+
# Unsorted material ID pointer
6842+
nsrmu = nsrt + settings.header["nelth"]
6843+
# Sorted material ID pointer
6844+
nsrma = nsrmu + settings.header["nmmat"]
6845+
# Mapping array between sorted and unsorted
6846+
nsrmp = nsrma + settings.header["nmmat"]
68466847

6847-
# some lsdyna material pointer
6848-
nsrmp = info.ptr_material_ids_crossref
6848+
n_bytes_written += fp.write(settings.pack(nsrma))
6849+
n_bytes_written += fp.write(settings.pack(nsrmu))
68496850
n_bytes_written += fp.write(settings.pack(nsrmp))
68506851

68516852
# "Total number of materials (parts)"
@@ -7376,7 +7377,7 @@ def _write_header_part_contact_interface_titles(
73767377
max_len = 18 * title_wordsize
73777378
fmt_name = "{0:" + str(max_len) + "}"
73787379
for pid, title in zip(part_titles_ids, part_titles):
7379-
title = title.decode("ascii")
7380+
title = title.decode("utf-8")
73807381
n_bytes_written += fp.write(settings.pack(pid))
73817382

73827383
formatted_title = fmt_name.format(title[:max_len])

0 commit comments

Comments
 (0)