pyNastran
0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
|
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 00026 from __future__ import division, print_function 00027 from numpy import argsort 00028 00029 from pyNastran.op2.resultObjects.op2_Objects import scalarObject 00030 00031 class OES_Object(scalarObject): 00032 def __init__(self, dataCode, iSubcase): 00033 scalarObject.__init__(self, dataCode, iSubcase) 00034 self.log.debug("starting OES...elementName=%s iSubcase=%s" %(self.elementName,self.iSubcase)) 00035 #print self.dataCode 00036 00037 def isCurvatureOld(self): 00038 if self.stressBits[2] == 0: 00039 return True 00040 return False 00041 00042 def isCurvature(self): 00043 if self.sCode in [0,1,14,15,16,17,27,30,31]: # fiber distance 00044 return False 00045 elif self.sCode in [10,11,26,]: # fiber curvature 00046 return True 00047 raise NotImplementedError('add sCode=%s' %(self.sCode)) 00048 00049 def isFiberDistance(self): 00050 return not(self.isCurvature()) 00051 00052 def isVonMises(self): 00053 #print self.stressBits 00054 #iMs = not(self.isMaxShear()) 00055 #print 'isVonMises = ',iMs 00056 return not(self.isMaxShear()) 00057 00058 def isMaxShear(self): 00059 #print self.stressBits 00060 if self.stressBits[4] == 0: 00061 #print 'isMaxShear = True' 00062 return True 00063 #print 'isMaxShear = False' 00064 return False 00065 00066 def getOrderedETypes(self, validTypes): 00067 """ 00068 @param validTypes list of valid element types 00069 e.g. ['CTRIA3','CTRIA6','CQUAD4','CQUAD8'] 00070 00071 @retval TypesOut the ordered list of types 00072 @retval orderedETypes dictionary of Type-IDs to write 00073 """ 00074 orderedETypes = {} 00075 00076 #validTypes = ['CTRIA3','CTRIA6','CQUAD4','CQUAD8'] 00077 for eType in validTypes: 00078 orderedETypes[eType] = [] 00079 for eid,eType in sorted(self.eType.items()): 00080 #print "eType = ",eType 00081 assert eType in validTypes, 'unsupported eType=%s' %(eType) 00082 orderedETypes[eType].append(eid) 00083 ### 00084 00085 minVals = [] 00086 for eType in validTypes: 00087 vals = orderedETypes[eType] 00088 #print "len(%s) = %s" %(eType,len(vals)) 00089 if len(vals)==0: 00090 minVals.append(-1) 00091 else: 00092 minVals.append(min(vals)) 00093 00094 #print "minVals = ",minVals 00095 argList = argsort(minVals) 00096 00097 TypesOut = [] 00098 for i in argList: 00099 TypesOut.append(validTypes[i]) 00100 #print "validTypes = %s" %(validTypes) 00101 #print "minVals = %s" %(minVals) 00102 #print "argList = %s" %(argList) 00103 #print "TypesOut = %s" %(TypesOut) 00104 #print "orderedETypes.keys = %s" %(orderedETypes.keys()) 00105 return (TypesOut,orderedETypes) 00106 00107 class stressObject(OES_Object): 00108 def __init__(self, dataCode, iSubcase): 00109 OES_Object.__init__(self, dataCode, iSubcase) 00110 00111 def updateDt(self, dataCode, dt): 00112 self.dataCode = dataCode 00113 self.applyDataCode() 00114 #assert dt>=0. 00115 #print "dataCode=",self.dataCode 00116 self.elementName = self.dataCode['elementName'] 00117 if dt is not None: 00118 self.log.debug("updating stress...%s=%s elementName=%s" %(self.dataCode['name'], dt, self.elementName)) 00119 self.dt = dt 00120 self.addNewTransient(dt) 00121 ### 00122 00123 def isStrain(self): 00124 return True 00125 00126 def isStress(self): 00127 return False 00128 00129 00130 class strainObject(OES_Object): 00131 def __init__(self, dataCode, iSubcase): 00132 OES_Object.__init__(self, dataCode, iSubcase) 00133 00134 def updateDt(self, dataCode, dt): 00135 self.dataCode = dataCode 00136 self.applyDataCode() 00137 #print "dataCode=",self.dataCode 00138 self.elementName = self.dataCode['elementName'] 00139 #assert dt>=0. 00140 if dt is not None: 00141 self.log.debug("updating strain...%s=%s elementName=%s" %(self.dataCode['name'], dt, self.elementName)) 00142 self.dt = dt 00143 self.addNewTransient() 00144 ### 00145 00146 def isStress(self): 00147 return False 00148 00149 def isStrain(self): 00150 return True