def _read_mat9(self, data, n): """ MAT9(2603,26,300) - record 9 """ ntotal = 140 s = Struct(self._endian + b'i 30f iiii') nmaterials = (len(data) - n) // ntotal for i in range(nmaterials): out = s.unpack(data[n:n + ntotal]) if self.is_debug_file: self.binary_debug.write(' MAT9=%s\n' % str(out)) assert len(out) == 35, out (mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, rho, a1, a2, a3, a4, a5, a6, tref, ge, blank1, blank2, blank3, blank4) = out assert blank1 == 0, blank1 data_in = [ mid, [ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21 ], rho, [a1, a2, a3, a4, a5, a6], tref, ge ] mat = MAT9.add_op2_data(data_in) self.add_op2_material(mat) n += ntotal self.card_count['MAT9'] = nmaterials return n
def _read_mat9(self, data: bytes, n: int) -> int: """ MAT9(2603,26,300) - record 9 """ #self.log.info('skipping MAT9') #return len(data) ndatai = len(data) - n if ndatai % 140 == 0: s2 = Struct(self._endian + b'i 30f iiii') ntotal = 140 else: # pragma: no cover self.log.warning('unexpected MAT9 format...') ntotal = (35 + 21) * 4 # 35 s2 = Struct(self._endian + b'i 30f iiii 21i') #ntotal = 56 * 4 #s1 = Struct(self._endian + b'i 21f 34i') #s2 = Struct(self._endian + b'i 21f 34f') nmaterials = ndatai // ntotal assert ndatai % ntotal == 0, f'ndatai={ndatai} ntotal={ntotal} nmaterials={nmaterials} leftover={ndatai % ntotal}' if self.is_debug_file: self.binary_debug.write( ' MAT9=(mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, ' 'g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, ' 'rho, a1, a2, a3, a4, a5, a6, tref, ge, ' 'blank1, blank2, blank3, blank4)\n') for unused_i in range(nmaterials): out = s2.unpack(data[n:n + ntotal]) if self.is_debug_file: self.binary_debug.write(' MAT9=%s\n' % str(out)) if len(out) == 35: #print(out) (mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, rho, a1, a2, a3, a4, a5, a6, tref, ge, blank1, blank2, blank3, blank4) = out else: (mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, rho, a1, a2, a3, a4, a5, a6, tref, ge, blank1, blank2, blank3, blank4, *blanks) = out self.show_data(data[n:n + ntotal], types='if') self.log.debug(blanks) assert blank1 == 0, blank1 data_in = [ mid, [ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21 ], rho, [a1, a2, a3, a4, a5, a6], tref, ge ] mat = MAT9.add_op2_data(data_in) try: self.add_op2_material(mat) except AssertionError: print(mat) self.card_count['MAT9'] = nmaterials return len(data) n += ntotal self.card_count['MAT9'] = nmaterials return n
def _read_mat9(self, data, n): """ MAT9(2603,26,300) - record 9 """ #self.log.info('skipping MAT9') #return len(data) #if 1: ntotal = 140 # 35 s2 = Struct(self._endian + b'i 30f iiii') #else: # pragma: no cover #ntotal = 56 * 4 #s1 = Struct(self._endian + b'i 21f 34i') #s2 = Struct(self._endian + b'i 21f 34f') nmaterials = (len(data) - n) // ntotal #assert nmaterials % ntotal == 0, self.numwide if self.is_debug_file: self.binary_debug.write( ' MAT9=(mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, ' 'g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, ' 'rho, a1, a2, a3, a4, a5, a6, tref, ge, ' 'blank1, blank2, blank3, blank4)\n') for unused_i in range(nmaterials): #self.show_data(data[n:n+ntotal], types='if') out = s2.unpack(data[n:n + ntotal]) if self.is_debug_file: self.binary_debug.write(' MAT9=%s\n' % str(out)) assert len(out) == 35, out #print(out) (mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, rho, a1, a2, a3, a4, a5, a6, tref, ge, blank1, blank2, blank3, blank4) = out assert blank1 == 0, blank1 data_in = [ mid, [ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21 ], rho, [a1, a2, a3, a4, a5, a6], tref, ge ] #print(data_in) mat = MAT9.add_op2_data(data_in) self.add_op2_material(mat) n += ntotal self.card_count['MAT9'] = nmaterials return n
def _read_mat9(self, data, n): """ MAT9(2603,26,300) - record 9 """ ntotal = 140 s = Struct(b(self._endian + 'i 30f iiii')) nmaterials = (len(data) - n) // ntotal for i in range(nmaterials): out = s.unpack(data[n:n+ntotal]) assert len(out) == 35, out (mid, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21, rho, a1, a2, a3, a4, a5, a6, TRef, ge, blank1, blank2, blank3, blank4) = out assert blank1 == 0, blank1 data_in = [mid, [g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20, g21], rho, [a1, a2, a3, a4, a5, a6], TRef, ge] mat = MAT9.add_op2_data(data_in) self.add_op2_material(mat) n += ntotal self.card_count['MAT9'] = nmaterials return n