nschloe / meshio

:spider_web: input/output for many mesh formats
MIT License
1.94k stars 400 forks source link

[BUG] NASTRAN shell elements with material orientation and z-offset #1396

Open meyer-nils opened 1 year ago

meyer-nils commented 1 year ago

Describe the bug Conversion of NASTRAN files with floats for THETA, MCID or ZOFFS results in a ValueError.

ValueError: invalid literal for int() with base 10: '0.1'

To Reproduce This should be a valid NASTRAN file, but results in the error above:

CEND
BEGIN BULK

GRID           1        0.0     0.0     0.0                           
GRID           2        1.0     0.0     0.0                         
GRID           3        1.0     1.0     0.0                      
GRID           4        0.0     1.0     0.0    
CQUAD4         1       1       1       2       3       4            0.1
$
ENDDATA

Diagnose Obviously the mapping to integer fails in line 74 of _nastran.py list(map(int, cell)) , if the last entries are no integers. I propose to check for shell elements similar to the check for 1D elements and to strip the last chunks, if they are floats. If you agree with this suggestion or have another suggestion, I could prepare a pull request.

giovap95 commented 6 months ago

Hi, I also encountered this issue. Have you published your fixes somewhere or could you share them with me? Thanks!

meyer-nils commented 6 months ago

I don't recall my exact solution, but you can find a similar treatment of floating point orientation vectors for 1D elements in the same file.

Simply adjust it to something like this:

if keyword in ["CBAR", "CBEAM", "CBUSH", "CBUSH1D", "CGAP"]:
    cell = chunks[3:5]
if keyword in ["CQUAD4"]:
    cell = chunks[3:7]
else:
    cell = chunks[3:]

You may want to adjust the list of keywords or the slice.