Skip to content

Commit 0cf6444

Browse files
committed
fix: Handle inconsistant SPH header between versions
There was an undocumented DB change between old and new versions where isphfg(1) can be 10 or 11. Data flag handling was modified to handle this behaviour.
1 parent bfc132e commit 0cf6444

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/lasso/dyna/d3plot.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,15 @@ def _read_fluid_material_data(self):
21582158
LOGGER.debug("_read_fluid_material_data end at byte %d", self.geometry_section_size)
21592159

21602160
def _read_sph_element_data_flags(self):
2161-
"""Read the sph element data flags"""
2161+
"""Read the sph element data flags
2162+
2163+
The LS-DYNA database has some undocumented behaviour between older and newer
2164+
versions that impact how SPH header data is handled. The manual idnicates that
2165+
isphfg(1) should always be 11. However, in versions of LS-DYNA newer than R9,
2166+
isphfg(1) can be either 10 or 11 as history variables are handled differently.
2167+
Special handling was needed to ensure that old behaviour broken while handling
2168+
this undocumented change.
2169+
"""
21622170

21632171
if not self._buffer:
21642172
return
@@ -2198,14 +2206,12 @@ def _read_sph_element_data_flags(self):
21982206
self._sph_info.has_strainrate = sph_header_data["isphfg9"] > 6
21992207
self._sph_info.has_true_strains = sph_header_data["isphfg9"] < 0
22002208
self._sph_info.has_mass = sph_header_data["isphfg10"] != 0
2201-
self._sph_info.n_sph_history_vars = sph_header_data["isphfg11"]
2202-
2203-
if self._sph_info.n_sph_array_length != 11:
2204-
msg = (
2205-
"Detected inconsistency: "
2206-
f"isphfg = {self._sph_info.n_sph_array_length} but must be 11."
2207-
)
2208-
raise RuntimeError(msg)
2209+
# If isphfg1 = 10, then there are no history variables by default and isphfg11
2210+
# is filled with junk data that causes issues calculating n_sph_vars below
2211+
if sph_header_data["isphfg1"] == 10:
2212+
self._sph_info.n_sph_history_vars = 0
2213+
else:
2214+
self._sph_info.n_sph_history_vars = sph_header_data["isphfg11"]
22092215

22102216
self._sph_info.n_sph_vars = (
22112217
sph_header_data["isphfg2"]
@@ -2217,7 +2223,7 @@ def _read_sph_element_data_flags(self):
22172223
+ sph_header_data["isphfg8"]
22182224
+ abs(sph_header_data["isphfg9"])
22192225
+ sph_header_data["isphfg10"]
2220-
+ sph_header_data["isphfg11"]
2226+
+ self._sph_info.n_sph_history_vars
22212227
+ 1
22222228
) # material number
22232229

0 commit comments

Comments
 (0)