Fix handling of SPH arrays and database changes between versions#88
Merged
codie3611 merged 2 commits intoopen-lasso-python:developfrom Aug 30, 2025
Merged
Conversation
Reshapes complete SPH data array to allow for correct indexing. To deal with old and new database versions, which may or may not include strain rate, flags for strain and strain rate were separated, as `isphfg(9)` can be 6 or 12.
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.
codie3611
approved these changes
Aug 30, 2025
Contributor
codie3611
left a comment
There was a problem hiding this comment.
Nice! We tested SPH in an old version in the past, but knew it was a weakspot due to lack of tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses two bugs related to reading SPH data from d3plot files.
First, as noted in issue #67, SPH arrays were not being read correctly. This stemmed from raw SPH data arrays being incorrectly reshaped and indexed. Both of which were fixed in the
_read_sph_element_data_flags()function. Note, this PR doesn't address the problem with nodal rigid body also raised in issue #67.Second, a series of documented and undocumented database changes occurred between older and newer versions of LS-DYNA, which impacted how SPH header data was read. As documented in the 2017 and 2020 databases manuals, the flag
isphfg(9)changed from 6 to 12 to output both strain and strain rates. Changes to how state data was read were implemented to handle reading strain and strain rate separately to account for both old and new database versions.An undocumented change somewhere between R7 and R9 was that
isphfg(1)could vary between 10 and 11, depending on whether any history variables were requested in*DATABASE_EXTENT_BINARY. This behaviour was likely why the existing code base threw a runtime error ifisphfg(1)did not equal 11, as noted in #34. Ifisphfg(1)was equal to 10, the junk value in the 11th spot would cause overflow errors when parsing binary data. Parsing behaviour in_read_sph_element_data_flags()for SPH header information was updated to handle cases whereisphfg(1)was equal to both 10 and 11.While not included in this PR, I performed a series of tests on SPH models from Dyna Examples for versions R7.1.2, R9.3.1, and R12.2.1 (both single and double precision), with and without the requested history variables, and obtained correct outputs each time. I didn't include that data here as it was a lot of d3plot files, and I wasn't sure what the copyright situation was using models from Dyna Examples.