@@ -381,9 +381,32 @@ def _load_materials(self):
381381 def read_mat_data (ptr ):
382382 """reads double precision material data given an offset from ptrMAT"""
383383 arr , sz = self .read_record (self ._geometry_header ["ptrMAT" ] + ptr , True )
384- arr = arr [arr != 0 ]
385- if arr .size == 1 :
386- return arr [0 ]
384+ is_single_value = arr [arr != 0 ].size == 1
385+
386+ if is_single_value :
387+ return arr [arr != 0 ][0 ]
388+ else :
389+ # We need to account for 0 at the temp and properties.
390+ temps_ = arr [:sz ]
391+ values_ = arr [- 1 : - 1 * (sz + 1 ) : - 1 ]
392+
393+ prop_ = np .vstack ((temps_ , values_ ))
394+ for each in range (prop_ .shape [1 ] - 1 , - 1 , - 1 ):
395+ # checking that two records are empty starting from the end.
396+ if (
397+ temps_ [each ] == 0
398+ and values_ [each ] == 0
399+ and temps_ [each - 1 ] == 0
400+ and values_ [each - 1 ] == 0
401+ ):
402+ continue # they are zero, so we keep going.
403+ else :
404+ # found a non-zero report
405+ break
406+
407+ prop_ = prop_ [:, :each ]
408+ prop_ [1 , :] = prop_ [1 , ::- 1 ]
409+ return prop_
387410
388411 mat_table = self .read_record (self ._geometry_header ["ptrMAT" ])
389412 if mat_table [0 ] != - 101 : # pragma: no cover
@@ -423,9 +446,7 @@ def read_mat_data(ptr):
423446 self ._cfile ._seekg (fs )
424447 material [key ] = np .fromstring (self ._cfile ._read (8 ))[0 ]
425448 else :
426- for i in range (- 5 , 10 ):
427- material [key ] = read_mat_data (ptr )
428- # print(read_mat_data(ptr))
449+ material [key ] = read_mat_data (ptr )
429450
430451 # documentation for this is hard to follow, but it boils down to
431452 # the fact that "The record includes MP pointers followed by TB
0 commit comments