@@ -2158,7 +2158,15 @@ def _read_fluid_material_data(self):
2158
2158
LOGGER .debug ("_read_fluid_material_data end at byte %d" , self .geometry_section_size )
2159
2159
2160
2160
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
+ """
2162
2170
2163
2171
if not self ._buffer :
2164
2172
return
@@ -2198,14 +2206,12 @@ def _read_sph_element_data_flags(self):
2198
2206
self ._sph_info .has_strainrate = sph_header_data ["isphfg9" ] > 6
2199
2207
self ._sph_info .has_true_strains = sph_header_data ["isphfg9" ] < 0
2200
2208
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" ]
2209
2215
2210
2216
self ._sph_info .n_sph_vars = (
2211
2217
sph_header_data ["isphfg2" ]
@@ -2217,7 +2223,7 @@ def _read_sph_element_data_flags(self):
2217
2223
+ sph_header_data ["isphfg8" ]
2218
2224
+ abs (sph_header_data ["isphfg9" ])
2219
2225
+ sph_header_data ["isphfg10" ]
2220
- + sph_header_data [ "isphfg11" ]
2226
+ + self . _sph_info . n_sph_history_vars
2221
2227
+ 1
2222
2228
) # material number
2223
2229
0 commit comments