pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
oesnlxr.py
Go to the documentation of this file.
00001 ## GNU Lesser General Public License
00002 ## 
00003 ## Program pyNastran - a python interface to NASTRAN files
00004 ## Copyright (C) 2011-2012  Steven Doyle, Al Danial
00005 ## 
00006 ## Authors and copyright holders of pyNastran
00007 ## Steven Doyle <mesheb82@gmail.com>
00008 ## Al Danial    <al.danial@gmail.com>
00009 ## 
00010 ## This file is part of pyNastran.
00011 ## 
00012 ## pyNastran is free software: you can redistribute it and/or modify
00013 ## it under the terms of the GNU Lesser General Public License as published by
00014 ## the Free Software Foundation, either version 3 of the License, or
00015 ## (at your option) any later version.
00016 ## 
00017 ## pyNastran is distributed in the hope that it will be useful,
00018 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 ## GNU General Public License for more details.
00021 ## 
00022 ## You should have received a copy of the GNU Lesser General Public License
00023 ## along with pyNastran.  If not, see <http://www.gnu.org/licenses/>.
00024 ## 
00025 import sys
00026 from struct import unpack
00027 
00028 from pyNastran.op2.op2Errors import InvalidAnalysisCodeError, InvalidATFSCodeError
00029 from elementsStressStrain import ElementsStressStrain
00030 
00031 class OESNLXR(ElementsStressStrain):
00032     """Table of stresses/strains"""
00033 
00034     def readTable_OESNLXR(self):
00035         table3 = self.readTable_OESNLXR_3
00036         table4Data = self.readTable_OES_4_Data
00037         self.readResultsTable(table3,table4Data,flag=1) # flag=1 defines old style
00038         self.deleteAttributes_OES()
00039 
00040     def deleteAttributes_OESNLXR(self):
00041         params = ['sCode','elementType','obj','markerStart','loadSet','formatCode','sCode','thermal',
00042                   'lsdvmn','mode','eign','modeCycle','freq','mode','eigr','eigi','dt']
00043         self.deleteAttributes(params)
00044 
00045     def readTable_OESNLXR_3(self,iTable):
00046         #print "*iTable3 = ",iTable
00047         #if 0:
00048             #markers = self.readMarkers([0,2])
00049             #print "markers=%s" %(markers)
00050             #block = self.readBlock()
00051             #print "block = ",block
00052             #markers = self.readMarkers([-1,7])
00053             #print "markers=%s" %(markers)
00054             #print self.printSection(200)
00055         
00056         bufferWords = self.getBufferWords()
00057         
00058         data = self.getData(4)
00059         bufferSize, = unpack('i',data)
00060         if self.makeOp2Debug:
00061             self.op2Debug.write('bufferSize=|%s|\n' %(str(bufferSize)))
00062 
00063         data = self.getData(4*50)
00064         #self.printBlock(data)
00065         if self.makeOp2Debug:
00066             self.op2Debug.write('block3header\n')
00067         
00068         self.parseApproachCode(data) # 3
00069         self.addDataParameter(data,'elementType', 'i',3,False)   ## element type
00070         self.addDataParameter(data,'loadSet',     'i',8,False)   ## load set ID
00071         self.addDataParameter(data,'formatCode',  'i',9,False)   ## format code
00072         self.addDataParameter(data,'numWide',     'i',10,False)  ## number of words per entry in record; @note is this needed for this table ???
00073         self.addDataParameter(data,'sCode',       'i',11,False)  ## stress/strain codes
00074         self.addDataParameter(data,'thermal',     'i',23,False)  ## thermal flag; 1 for heat ransfer, 0 otherwise
00075 
00076         #print "loadset=%s formatCode=%s numWordsEntry=%s sCode=%s" %(self.loadSet,self.formatCode,self.numWide,self.sCode)
00077         #print "thermal(23)=%s elementType(3)=%s" %(self.thermal,self.elementType)
00078 
00079 
00080         ## assuming tCode=1
00081         if self.analysisCode==1:   # statics / displacement / heat flux
00082             self.addDataParameter(data,'lsdvmn','i',5,False)   ## load set number
00083         elif self.analysisCode==2: # real eigenvalues
00084             self.addDataParameter(data,'mode',     'i',5)         ## mode number
00085             self.addDataParameter(data,'eign',     'f',6,False)   ## real eigenvalue
00086             self.addDataParameter(data,'modeCycle','f',7,False)   ## mode or cycle @todo confused on the type - F1???
00087         #elif self.analysisCode==3: # differential stiffness
00088         #    self.lsdvmn = self.getValues(data,'i',5) ## load set number
00089         #elif self.analysisCode==4: # differential stiffness
00090         #    self.lsdvmn = self.getValues(data,'i',5) ## load set number
00091 
00092         elif self.analysisCode==5:   # frequency
00093             self.addDataParameter(data,'freq','f',5)   ## frequency
00094         elif self.analysisCode==6: # transient
00095             self.addDataParameter(data,'dt','f',5)   ## time step
00096             #print "DT(5)=%s" %(self.dt)
00097         elif self.analysisCode==7: # pre-buckling
00098             self.addDataParameter(data,'lsdvmn','i',5)   ## load set
00099             #print "LSDVMN(5)=%s" %(self.lsdvmn)
00100         elif self.analysisCode==8: # post-buckling
00101             self.addDataParameter(data,'lsdvmn','i',5)       ## mode number
00102             self.addDataParameter(data,'eigr','f',6,False)   ## real eigenvalue
00103             #print "LSDVMN(5)=%s  EIGR(6)=%s" %(self.lsdvmn,self.eigr)
00104         elif self.analysisCode==9: # complex eigenvalues
00105             self.addDataParameter(data,'mode','i',5)   ## mode number
00106             self.addDataParameter(data,'eigr','f',6,False)   ## real eigenvalue
00107             self.addDataParameter(data,'eigi','f',7,False)   ## imaginary eigenvalue
00108             #print "mode(5)=%s  eigr(6)=%s  eigi(7)=%s" %(self.mode,self.eigr,self.eigi)
00109         elif self.analysisCode==10: # nonlinear statics
00110             self.addDataParameter(data,'lftsfq','f',5)   ## load step
00111             #print "LFTSFQ(5) = %s" %(self.lftsfq)
00112         elif self.analysisCode==11: # old geometric nonlinear statics
00113             self.addDataParameter(data,'lsdvmn','i',5)   ## load set number
00114             #print "LSDVMN(5)=%s" %(self.lsdvmn)
00115         elif self.analysisCode==12: # contran ? (may appear as aCode=6)  --> straight from DMAP...grrr...
00116             self.addDataParameter(data,'dt','f',5)   ## Time step ??? --> straight from DMAP
00117         else:
00118             raise InvalidAnalysisCodeError('invalid analysisCode...analysisCode=%s' %(self.analysisCode))
00119         ###
00120         # tCode=2
00121         #if self.analysisCode==2: # sort2
00122         #    self.lsdvmn = self.getValues(data,'i',5)
00123 
00124         self.readTitle()
00125         #print "n4 = ",self.n
00126 
00127     def readTable_OESNLXR_4_Data(self,iTable):
00128         isTable4Done = False
00129         isBlockDone  = False
00130         #print self.printSection(100)
00131 
00132         data = self.getData(16)
00133         #print self.printBlock(data) # on
00134         #print "16 block..."
00135         #self.printBlock(data)
00136         #self.printBlock(data)
00137         bufferWords, = unpack('i',data[4:8])
00138         #print "bufferWords = ",bufferWords
00139         if self.makeOp2Debug:
00140             self.op2Debug.write('bufferWords=|%s|\n' %(str(bufferWords)))
00141 
00142         #print "*********************"
00143         #bufferWords = self.getMarker() # 87 - buffer
00144         #print "OES4 bufferWords = ",bufferWords,bufferWords*4
00145         #self.verifyBufferSize(bufferWords)
00146         
00147         isBlockDone = not(bufferWords)
00148         #print "self.firstPass = ",self.firstPass
00149         
00150         ## table -4 is done, restarting table -3
00151         if self.isBufferDone: # table is done when the buffer is done
00152             isTable4Done = True
00153             #print "exitA"
00154             return isTable4Done,isBlockDone
00155         if bufferWords==0:
00156             #print "bufferWords 0 - done with Table4"
00157             isTable4Done = True
00158             #isBlockDone  = True
00159             self.printSection(40)
00160             #print "exitB"
00161             return isTable4Done,isBlockDone
00162 
00163         self.readOESNLXR_ElementTable()
00164         return isTable4Done,isBlockDone
00165 
00166     def readOESNLXR_ElementTable(self):
00167         #print "**self.readElementTable"
00168         #print "*elementType = ",self.elementType
00169         #print "op2.tell=%s n=%s" %(self.op2.tell(),self.n)
00170         
00171         self.rewind(4)
00172         self.data = self.readBlock()  # 348
00173         #print "len(self.data) = ",len(self.data)
00174 
00175         if self.makeOp2Debug:
00176             self.op2Debug.write('reading big data block\n')
00177         #print self.printBlock(self.data)
00178 
00179         #msg = 'elementType=%s -> %s' %(self.elementType,self.ElementType(self.elementType))
00180         tfsCode = [self.tableCode,self.formatCode,self.sortCode]
00181 
00182         self.parseStressCode()
00183 
00184         if not self.isValidSubcase():# lets the user skip a certain subcase
00185             self.log.debug("***skipping table=%s iSubcase=%s" %(self.tableName,self.iSubcase))
00186             self.skipOES_Element()
00187         elif self.thermal==0:
00188             # Stress / Strain
00189             self.dataCode['elementName'] = self.ElementType(self.elementType)
00190             if   tfsCode==[5,1,0]:
00191                 self.readOESNLXR_Data_format1_sort0()
00192             else:
00193                 raise InvalidATFSCodeError('invalid atfsCode=%s' %(self.atfsCode))
00194                 self.skipOES_Element()
00195                 pass
00196             ###
00197         else:
00198             raise Exception('invalid thermal option...')
00199         ###
00200         
00201         #print self.obj
00202 
00203     def readOESNLXR_Data_format1_sort0(self):
00204         raise NotImplementedError('code this...')
00205         #msg = 'OES elementType=%-3s -> %-6s\n' %(self.elementType,self.ElementType(self.elementType))
00206         msg = ''
00207         #if self.analysisCode not in [1,6,10]:
00208             #raise InvalidATFSCodeError('self.atfsCode=%s' %(self.atfsCode))
00209 
00210         if self.elementType in [1,3,10]: # crod/ctube/conrod
00211             self.makeOES_Object(self.rodStress,rodStressObject,
00212                                 self.rodStrain,rodStrainObject)
00213             self.basicElement()
00214         elif self.elementType == 2:   # cbeam
00215             #print "    found cbeam_2"
00216             self.dataCode['elementName'] = 'CBEAM'
00217             self.makeOES_Object(self.beamStress,beamStressObject,
00218                                 self.beamStrain,beamStrainObject)
00219             self.CBEAM_2()
00220 
00221         elif self.elementType in [4]: # cshear
00222             #print "    found crod_1"
00223             self.dataCode['elementName'] = 'CSHEAR'
00224             self.makeOES_Object(self.shearStress,shearStressObject,
00225                                 self.shearStrain,shearStrainObject)
00226             self.basicElement()
00227         elif self.elementType in [11,12,13]:   # celas1/celas2/celas3
00228             self.makeOES_Object(self.celasStress,celasStressObject,
00229                                 self.celasStrain,celasStrainObject)
00230             self.basicElement()
00231         elif self.elementType == 34:   # cbar
00232             #print "    found cbar_34"
00233             self.dataCode['elementName'] = 'CBAR'
00234             self.makeOES_Object(self.barStress,barStressObject,
00235                                 self.barStrain,barStrainObject)
00236             self.CBAR_34()
00237 
00238         elif self.elementType==33: # cquad4_33
00239             #print "    found cquad_33"
00240             self.dataCode['elementName'] = 'CQUAD4'
00241             self.makeOES_Object(self.plateStress,plateStressObject,
00242                                 self.plateStrain,plateStrainObject)
00243             self.CQUAD4_33()
00244         elif self.elementType==74:  # ctria
00245             #print "    found ctria_74"
00246             self.dataCode['elementName'] = 'CTRIA3'
00247             self.makeOES_Object(self.plateStress,plateStressObject,
00248                                 self.plateStrain,plateStrainObject)
00249             self.CTRIA3_74() # ctria3
00250         elif self.elementType in [64,144,70,75]: # cquad8/cquad4/ctriar/ctria6
00251             #print "    found cquad_144"
00252             if     self.elementType==64:  self.dataCode['elementName'] = 'CQUAD8'
00253             elif   self.elementType==144: self.dataCode['elementName'] = 'CQUAD4'
00254             elif   self.elementType==70:  self.dataCode['elementName'] = 'CTRIAR'
00255             elif   self.elementType==75:  self.dataCode['elementName'] = 'CTRIA6'
00256             else:  raise Exception('not implemented error')
00257             self.makeOES_Object(self.plateStress,plateStressObject,
00258                                 self.plateStrain,plateStrainObject)
00259             self.CQUAD4_144()
00260 
00261         elif self.elementType in [39,67,68]:   # ctetra/chexa/cpenta
00262             #print "    found ctetra_39 / hexa_67 / cpenta_68"
00263             self.makeOES_Object(self.solidStress,solidStressObject,
00264                                 self.solidStrain,solidStrainObject)
00265             self.CSOLID_67()
00266 
00267         elif self.elementType in [85]:   # ctetra/chexa/cpenta (91,93)
00268             #print "    found ctetra_85 / hexa_93 / cpenta_91"
00269             self.makeOES_Object(self.solidStress,solidStressObject,
00270                                 self.solidStrain,solidStrainObject)
00271             self.CSOLID_85()
00272 
00273         elif self.elementType in [89,92]:   # RODNL
00274             #print "    found RODNL_89"
00275             self.makeOES_Object(self.rodStress,nonlinearRodObject,
00276                                 self.rodStrain,nonlinearRodObject)
00277             self.RODNL_89_92()
00278 
00279         #elif self.elementType in [91]: # CPENTANL
00280         #    #print "hexa_93"
00281         #    self.CPENTANL_91()
00282         #elif self.elementType in [93]: # CHEXANL
00283         #    #print "hexa_93"
00284         #    self.CHEXANL_93()
00285 
00286         elif self.elementType in [95,96,97,98]: # CQUAD4, CQUAD8, CTRIA3, CTRIA6 (composite)
00287             #print "    found a 95/96/97 or 98!"
00288             self.eid2 = None # stores the previous elementID
00289             self.makeOES_Object(self.compositePlateStress,compositePlateStressObject,
00290                                 self.compositePlateStrain,compositePlateStrainObject)
00291             self.CQUAD4_95()
00292             del self.eid2
00293 
00294         elif self.elementType in [94]: # CBEAM (nonlinear)
00295             print "    found a 94!"
00296             #self.eid2 = None # stores the previous elementID
00297             self.makeOES_Object(self.beamStress,beamStressObject,
00298                                 self.beamStrain,beamStrainObject)
00299             self.CBEAM_94()
00300             #sys.exit('stoping at end of CBEAM_94')
00301             #del self.eid2
00302 
00303         elif self.elementType in [139]:   # QUAD4FD
00304             #print "    found QUAD4FD_139"
00305             self.makeOES_Object(self.plateStress,nonlinearQuadObject,
00306                                 self.plateStrain,nonlinearQuadObject)
00307             self.QUAD4FD_139()
00308 
00309         else:
00310             #self.printBlock(self.data[0:100])
00311             self.skipOES_Element()
00312             msg = 'OES format1_sort0 elementType=%-3s -> %s is not supported - fname=%s\n' %(self.elementType,self.ElementType(self.elementType),self.op2FileName)
00313             self.log.debug(msg)
00314             #msg = 'OES format1_sort0 elementType=%-3s -> %s is not supported' %(self.elementType,self.ElementType(self.elementType))
00315             #raise RuntimeError(msg)
00316             self.skippedCardsFile.write(msg)
00317         ###
00318 
 All Classes Namespaces Files Functions Variables