def write_f06(self, f, header=None, page_stamp='PAGE %s', page_num=1, is_mag_phase=False, is_sort1=True): if header is None: header = [] #msg, nnodes, is_bilinear = self._get_msgs() if self.is_von_mises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' if self.is_strain(): words = [' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] else: words = [' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] if self.element_type == 95: # CQUAD4 if self.is_strain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words #elif self.element_type == 96: # CQUAD8 #nnodes_per_element = 1 elif self.element_type == 97: # CTRIA3 if self.is_strain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words elif self.element_type == 96: # QUAD8 # good if self.is_strain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 8 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 8 )\n'] + words elif self.element_type == 98: # CTRIA6 # good if self.is_strain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 6 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 6 )\n'] + words else: raise NotImplementedError('element_name=%s element_type=%s' % (self.element_name, self.element_type)) # write the f06 ntimes = self.data.shape[0] eids = self.element_layer[:, 0] layers = self.element_layer[:, 1] for itime in range(ntimes): dt = self._times[itime] header = _eigenvalue_header(self, header, itime, ntimes, dt) f.write(''.join(header + msg)) #print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) #[o11, o22, t12, t1z, t2z, angle, major, minor, ovm] o11 = self.data[itime, :, 0] o22 = self.data[itime, :, 1] t12 = self.data[itime, :, 2] t1z = self.data[itime, :, 3] t2z = self.data[itime, :, 4] angle = self.data[itime, :, 5] major = self.data[itime, :, 6] minor = self.data[itime, :, 7] ovm = self.data[itime, :, 8] for eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi in zip( eids, layers, o11, o22, t12, t1z, t2z, angle, major, minor, ovm): ([o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi], is_all_zeros) = writeFloats12E([ o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi]) f.write('0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %s\n' % (eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi)) f.write(page_stamp % page_num) page_num += 1 return page_num - 1
def write_f06(self, header, pageStamp, pageNum=1, f=None, is_mag_phase=False): if self.nonlinear_factor is not None: return self._write_f06_transient(header, pageStamp, pageNum, f) if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [ ' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % (von), ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % (mises) ] eTypes = list(self.eType.values()) if 'CQUAD4' in eTypes or 'QUAD4LC' in eTypes: quadMsg = header + [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words isQuad = True else: quadMsg = [] isQuad = False if 'CTRIA3' in eTypes or 'TRIA3LC' in eTypes: isTri = True triMsg = header + [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words else: isTri = False triMsg = [] for eid, o11s in sorted(self.o11.items()): out = '' eType = self.eType[eid] for iLayer in range(len(o11s)): o11 = self.o11[eid][iLayer] o22 = self.o22[eid][iLayer] t12 = self.t12[eid][iLayer] t1z = self.t1z[eid][iLayer] t2z = self.t2z[eid][iLayer] angle = self.angle[eid][iLayer] major = self.majorP[eid][iLayer] minor = self.minorP[eid][iLayer] ovm = self.ovmShear[eid][iLayer] (vals2, isAllZeros) = writeFloats12E( [o11, o22, t12, t1z, t2z, major, minor, ovm]) [o11, o22, t12, t1z, t2z, major, minor, ovm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % ( eid, iLayer + 1, o11, o22, t12, t1z, t2z, angle, major, minor, ovm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) #else: # raise NotImplementedError('eType = |%r|' %(eType)) # CQUAD8LC if isQuad: quadMsg.append(pageStamp + str(pageNum) + '\n') pageNum += 1 if isTri: triMsg.append(pageStamp + str(pageNum) + '\n') pageNum += 1 msg = ''.join(quadMsg + triMsg) return (msg, pageNum)
def _write_f06_transient(self, header, pageStamp, pageNum=1, f=None, is_mag_phase=False): if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [ ' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % (von), ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % (mises) ] eTypes = list(self.eType.values()) if 'CQUAD4' in eTypes or 'QUAD4LC' in eTypes: quadWords = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words isQuad = True else: quadWords = [] isQuad = False if 'CTRIA3' in eTypes or 'TRIA3LC' in eTypes: isTri = True triWords = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words else: isTri = False triWords = [] msg = [] for dt, e11s in sorted(self.e11.items()): quadMsg = [] triMsg = [] header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt) if isQuad: quadMsg = header + quadWords if isTri: triMsg = header + triWords for eid, e11s in sorted(e11s.items()): out = '' eType = self.eType[eid] for iLayer in range(len(e11s)): e11 = self.e11[dt][eid][iLayer] e22 = self.e22[dt][eid][iLayer] e12 = self.e12[dt][eid][iLayer] e1z = self.e1z[dt][eid][iLayer] e2z = self.e2z[dt][eid][iLayer] angle = self.angle[dt][eid][iLayer] major = self.majorP[dt][eid][iLayer] minor = self.minorP[dt][eid][iLayer] evm = self.evmShear[dt][eid][iLayer] (vals2, isAllZeros) = writeFloats12E( [e11, e22, e12, e1z, e2z, major, minor, evm]) [e11, e22, e12, e1z, e2z, major, minor, evm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % ( eid, iLayer + 1, e11, e22, e12, e1z, e2z, angle, major, minor, evm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) else: raise NotImplementedError('eType = |%r|' % (eType)) if isQuad: quadMsg.append(pageStamp + str(pageNum) + '\n') pageNum += 1 if isTri: triMsg.append(pageStamp + str(pageNum) + '\n') pageNum += 1 msg += quadMsg + triMsg return (''.join(msg), pageNum - 1)
def _write_f06_transient(self, header, pageStamp, page_num=1, f=None, is_mag_phase=False): if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [ ' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises ] eTypes = self.eType.values() if 'CQUAD4' in eTypes or 'QUAD4LC' in eTypes: quadWords = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words isQuad = True else: quadWords = [] isQuad = False if 'CTRIA3' in eTypes or 'TRIA3LC' in eTypes: isTri = True triWords = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words else: isTri = False triWords = [] for dt, O11s in sorted(iteritems(self.o11)): quadMsg = [] triMsg = [] header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt) if isQuad: quadMsg = header + quadWords if isTri: triMsg = header + triWords for eid, o11s in sorted(iteritems(O11s)): out = '' eType = self.eType[eid] for iLayer in range(len(o11s)): o11 = self.o11[dt][eid][iLayer] o22 = self.o22[dt][eid][iLayer] t12 = self.t12[dt][eid][iLayer] t1z = self.t1z[dt][eid][iLayer] t2z = self.t2z[dt][eid][iLayer] angle = self.angle[dt][eid][iLayer] major = self.majorP[dt][eid][iLayer] minor = self.minorP[dt][eid][iLayer] ovm = self.ovmShear[dt][eid][iLayer] (vals2, is_all_zeros) = writeFloats12E( [o11, o22, t12, t1z, t2z, major, minor, ovm]) [o11, o22, t12, t1z, t2z, major, minor, ovm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % ( eid, iLayer + 1, o11, o22, t12, t1z, t2z, angle, major, minor, ovm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) #else: # raise NotImplementedError('eType = %r' % eType) # CQUAD8LC if isQuad: quadMsg.append(pageStamp % page_num) f.write(''.join(quadMsg)) page_num += 1 if isTri: triMsg.append(pageStamp % page_num) f.write(''.join(triMsg)) page_num += 1 return page_num - 1
def write_f06(self, header, pageStamp, page_num=1, f=None, is_mag_phase=False): if self.nonlinear_factor is not None: return self._write_f06_transient(header, pageStamp, page_num, f) if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [ ' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises ] eTypes = self.eType.values() if 'CQUAD4' in eTypes or 'QUAD4LC' in eTypes: quadMsg = header + [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words isQuad = True else: quadMsg = [] isQuad = False if 'CTRIA3' in eTypes or 'TRIA3LC' in eTypes: isTri = True triMsg = header + [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words else: isTri = False triMsg = [] for eid, e11s in sorted(iteritems(self.e11)): out = '' eType = self.eType[eid] for iLayer in range(len(e11s)): e11 = self.e11[eid][iLayer] e22 = self.e22[eid][iLayer] e12 = self.e12[eid][iLayer] e1z = self.e1z[eid][iLayer] e2z = self.e2z[eid][iLayer] angle = self.angle[eid][iLayer] major = self.majorP[eid][iLayer] minor = self.minorP[eid][iLayer] evm = self.evmShear[eid][iLayer] (vals2, is_all_zeros) = writeFloats12E( [e11, e22, e12, e1z, e2z, major, minor, evm]) [e11, e22, e12, e1z, e2z, major, minor, evm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % ( eid, iLayer + 1, e11, e22, e12, e1z, e2z, angle, major, minor, evm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) #else: #raise NotImplementedError('eType = %r' % eType) # CQUAD8LC if isQuad: quadMsg.append(pageStamp % page_num) page_num += 1 if isTri: triMsg.append(pageStamp % page_num) page_num += 1 f.write(''.join(quadMsg + triMsg)) return page_num
def write_f06(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False): #msg, nnodes, is_bilinear = self._get_msgs() if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' if self.isStrain(): words = [ ' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises ] else: words = [ ' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises ] if self.element_type == 95: # CQUAD4 if self.isStrain(): msg = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words else: msg = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n' ] + words #elif self.element_type == 96: # CQUAD8 #nnodes_per_element = 1 elif self.element_type == 97: # CTRIA3 if self.isStrain(): msg = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words else: msg = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n' ] + words elif self.element_type == 96: # QUAD8 # good if self.isStrain(): msg = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 8 )\n' ] + words else: msg = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 8 )\n' ] + words elif self.element_type == 98: # CTRIA6 # good if self.isStrain(): msg = [ ' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 6 )\n' ] + words else: msg = [ ' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 6 )\n' ] + words else: raise NotImplementedError('element_name=%s element_type=%s' % (self.element_name, self.element_type)) # write the f06 (ntimes, ntotal, nine) = self.data.shape eids = self.element_layer[:, 0] layers = self.element_layer[:, 1] for itime in range(ntimes): dt = self._times[itime] if self.nonlinear_factor is not None: dtLine = ' %14s = %12.5E\n' % (self.data_code['name'], dt) header[1] = dtLine if hasattr(self, 'eigr'): header[2] = ' %14s = %12.6E\n' % ('EIGENVALUE', self.eigrs[itime]) f.write(''.join(header + msg)) # TODO: can I get this without a reshape? #print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) #[o11, o22, t12, t1z, t2z, angle, major, minor, ovm] o11 = self.data[itime, :, 0] o22 = self.data[itime, :, 1] t12 = self.data[itime, :, 2] t1z = self.data[itime, :, 3] t2z = self.data[itime, :, 4] angle = self.data[itime, :, 5] major = self.data[itime, :, 6] minor = self.data[itime, :, 7] ovm = self.data[itime, :, 8] # loop over all the elements for eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi in zip( eids, layers, o11, o22, t12, t1z, t2z, angle, major, minor, ovm): ([o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi], is_all_zeros) = writeFloats12E( [o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi]) f.write( '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %s\n' % (eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi)) f.write(page_stamp % page_num) page_num += 1 return page_num - 1
def _write_f06_transient(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False): if self.is_von_mises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] etypes = set(self.eType.values()) if 'CQUAD4' in etypes or 'QUAD4LC' in etypes: quad_words = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words is_quad = True else: quad_words = [] is_quad = False if 'CTRIA3' in etypes or 'TRIA3LC' in etypes: is_tria = True tria_words = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words else: is_tria = False tria_words = [] for dt, e11s in sorted(iteritems(self.e11)): quad_msg = [] tria_msg = [] header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt) if is_quad: quad_msg = header + quad_words if is_tria: tria_msg = header + tria_words for eid, e11s in sorted(iteritems(e11s)): out = '' eType = self.eType[eid] for iLayer in range(len(e11s)): e11 = self.e11[dt][eid][iLayer] e22 = self.e22[dt][eid][iLayer] e12 = self.e12[dt][eid][iLayer] e1z = self.e1z[dt][eid][iLayer] e2z = self.e2z[dt][eid][iLayer] angle = self.angle[dt][eid][iLayer] major = self.majorP[dt][eid][iLayer] minor = self.minorP[dt][eid][iLayer] evm = self.evmShear[dt][eid][iLayer] (vals2, is_all_zeros) = writeFloats12E([e11, e22, e12, e1z, e2z, major, minor, evm]) [e11, e22, e12, e1z, e2z, major, minor, evm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % (eid, iLayer + 1, e11, e22, e12, e1z, e2z, angle, major, minor, evm) if eType in ['CQUAD4', 'QUAD4LC']: quad_msg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: tria_msg.append(out) else: raise NotImplementedError('eType = |%r|' % (eType)) if is_quad: quad_msg.append(page_stamp % page_num) page_num += 1 f.write(''.join(quad_msg)) if is_tria: tria_msg.append(page_stamp % page_num) page_num += 1 f.write(''.join(tria_msg)) return page_num - 1
def write_f06(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False): if self.nonlinear_factor is not None: return self._write_f06_transient(header, page_stamp, page_num, f) if self.is_von_mises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] etypes = list(self.eType.values()) if 'CQUAD4' in etypes or 'QUAD4LC' in etypes: quadMsg = header + [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words isQuad = True else: quadMsg = [] isQuad = False if 'CTRIA3' in etypes or 'TRIA3LC' in etypes: isTri = True triMsg = header + [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words else: isTri = False triMsg = [] for eid, e11s in sorted(iteritems(self.e11)): out = '' eType = self.eType[eid] for iLayer in range(len(e11s)): e11 = self.e11[eid][iLayer] e22 = self.e22[eid][iLayer] e12 = self.e12[eid][iLayer] e1z = self.e1z[eid][iLayer] e2z = self.e2z[eid][iLayer] angle = self.angle[eid][iLayer] major = self.majorP[eid][iLayer] minor = self.minorP[eid][iLayer] evm = self.evmShear[eid][iLayer] (vals2, is_all_zeros) = writeFloats12E([e11, e22, e12, e1z, e2z, major, minor, evm]) [e11, e22, e12, e1z, e2z, major, minor, evm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % (eid, iLayer + 1, e11, e22, e12, e1z, e2z, angle, major, minor, evm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) #else: #raise NotImplementedError('eType = %r' % eType) # CQUAD8LC if isQuad: quadMsg.append(page_stamp % page_num) page_num += 1 if isTri: triMsg.append(page_stamp % page_num) page_num += 1 f.write(''.join(quadMsg + triMsg)) return page_num
def _write_f06_transient(self, header, pageStamp, page_num=1, f=None, is_mag_phase=False): if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' words = [' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] eTypes = self.eType.values() if 'CQUAD4' in eTypes or 'QUAD4LC' in eTypes: quadWords = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words isQuad = True else: quadWords = [] isQuad = False if 'CTRIA3' in eTypes or 'TRIA3LC' in eTypes: isTri = True triWords = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words else: isTri = False triWords = [] for dt, O11s in sorted(self.o11.iteritems()): quadMsg = [] triMsg = [] header[1] = ' %s = %10.4E\n' % (self.data_code['name'], dt) if isQuad: quadMsg = header + quadWords if isTri: triMsg = header + triWords for eid, o11s in sorted(O11s.iteritems()): out = '' eType = self.eType[eid] for iLayer in xrange(len(o11s)): o11 = self.o11[dt][eid][iLayer] o22 = self.o22[dt][eid][iLayer] t12 = self.t12[dt][eid][iLayer] t1z = self.t1z[dt][eid][iLayer] t2z = self.t2z[dt][eid][iLayer] angle = self.angle[dt][eid][iLayer] major = self.majorP[dt][eid][iLayer] minor = self.minorP[dt][eid][iLayer] ovm = self.ovmShear[dt][eid][iLayer] (vals2, is_all_zeros) = writeFloats12E([o11, o22, t12, t1z, t2z, major, minor, ovm]) [o11, o22, t12, t1z, t2z, major, minor, ovm] = vals2 out += '0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %-s\n' % (eid, iLayer + 1, o11, o22, t12, t1z, t2z, angle, major, minor, ovm) if eType in ['CQUAD4', 'QUAD4LC']: quadMsg.append(out) elif eType in ['CTRIA3', 'TRIA3LC']: triMsg.append(out) #else: # raise NotImplementedError('eType = |%r|' %(eType)) # CQUAD8LC if isQuad: quadMsg.append(pageStamp % page_num) f.write(''.join(quadMsg)) page_num += 1 if isTri: triMsg.append(pageStamp % page_num) f.write(''.join(triMsg)) page_num += 1 return page_num - 1
def write_f06(self, header, page_stamp, page_num=1, f=None, is_mag_phase=False): #msg, nnodes, is_bilinear = self._get_msgs() if self.isVonMises(): von = 'VON' mises = 'MISES' else: von = 'MAX' mises = 'SHEAR' if self.isStrain(): words = [' ELEMENT PLY STRAINS IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRAINS PRINCIPAL STRAINS (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] else: words = [' ELEMENT PLY STRESSES IN FIBER AND MATRIX DIRECTIONS INTER-LAMINAR STRESSES PRINCIPAL STRESSES (ZERO SHEAR) %s\n' % von, ' ID ID NORMAL-1 NORMAL-2 SHEAR-12 SHEAR XZ-MAT SHEAR YZ-MAT ANGLE MAJOR MINOR %s\n' % mises] if self.element_type == 95: # CQUAD4 if self.isStrain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( Q U A D 4 )\n'] + words #elif self.element_type == 96: # CQUAD8 #nnodes_per_element = 1 elif self.element_type == 97: # CTRIA3 if self.isStrain(): msg = [' S T R A I N S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words else: msg = [' S T R E S S E S I N L A Y E R E D C O M P O S I T E E L E M E N T S ( T R I A 3 )\n'] + words #elif self.element_type == 98: # CTRIA6 #nnodes_per_element = 1 else: raise NotImplementedError('element_name=%s element_type=%s' % (self.element_name, self.element_type)) # write the f06 (ntimes, ntotal, nine) = self.data.shape eids = self.element_layer[:, 0] layers = self.element_layer[:, 1] for itime in xrange(ntimes): dt = self.times[itime] # TODO: rename this... if self.nonlinear_factor is not None: dtLine = ' %14s = %12.5E\n' % (self.data_code['name'], dt) header[1] = dtLine if hasattr(self, 'eigr'): header[2] = ' %14s = %12.6E\n' % ('EIGENVALUE', self.eigrs[itime]) f.write(''.join(header + msg)) # TODO: can I get this without a reshape? #print("self.data.shape=%s itime=%s ieids=%s" % (str(self.data.shape), itime, str(ieids))) #[o11, o22, t12, t1z, t2z, angle, major, minor, ovm] o11 = self.data[itime, :, 0] o22 = self.data[itime, :, 1] t12 = self.data[itime, :, 2] t1z = self.data[itime, :, 3] t2z = self.data[itime, :, 4] angle = self.data[itime, :, 5] major = self.data[itime, :, 6] minor = self.data[itime, :, 7] ovm = self.data[itime, :, 8] # loop over all the elements for eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi in izip( eids, layers, o11, o22, t12, t1z, t2z, angle, major, minor, ovm): ([o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi], is_all_zeros) = writeFloats12E([ o11i, o22i, t12i, t1zi, t2zi, majori, minori, ovmi]) f.write('0 %8s %4s %12s %12s %12s %12s %12s %6.2F %12s %12s %s\n' % (eid, layer, o11i, o22i, t12i, t1zi, t2zi, anglei, majori, minori, ovmi)) f.write(page_stamp % page_num) page_num += 1 return page_num - 1