pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
oug_Objects.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 pack
00027 from pyNastran.op2.resultObjects.op2_Objects import scalarObject
00028 
00029 #---------------------------------------------------------------------------------
00030 #class staticFluxObj(scalarObject): # approachCode=1, tableCode=3 - whatever the static version of this is...
00031 
00032 class fluxObject(scalarObject): # approachCode=1, tableCode=3, thermal=1
00033     def __init__(self,dataCode,iSubcase,dt=None):
00034         scalarObject.__init__(self,dataCode,iSubcase)
00035 
00036         self.dt = dt
00037         self.fluxes = {}
00038         if dt is not None:
00039             self.fluxes = {}
00040             self.isTransient = True
00041             raise NotImplementedError('transient fluxObject is supported...')
00042 
00043     def deleteTransient(self,dt):
00044         del self.fluxes[dt]
00045 
00046     def getTransients(self):
00047         k = self.fluxes.keys()
00048         k.sort()
00049         return k
00050 
00051     def add(self,nodeID,gridType,v1,v2,v3,v4=None,v5=None,v6=None):
00052         assert 0<nodeID<1000000000, 'nodeID=%s' %(nodeID)
00053         assert nodeID not in self.fluxes
00054         self.fluxes[nodeID] = array([v1,v2,v3])
00055 
00056     def writeOp2(self,block3,deviceCode=1):
00057         """
00058         creates the binary data for writing the table
00059         @warning hasnt been tested...
00060         """
00061         msg = block3
00062         for nodeID,flux in sorted(self.fluxes.iteritems()):
00063             grid = nodeID*10+deviceCode
00064             msg += pack('iffffff',grid,flux[0],flux[1],flux[2],0,0,0)
00065         ###
00066         return msg
00067 
00068     def __repr__(self):
00069         if self.isTransient:
00070             return self.__reprTransient__()
00071 
00072         msg = '---HEAT FLUX---\n'
00073         msg += '%-10s %-8s %-8s %-8s\n' %('NodeID','xFlux','yFlux','zFlux')
00074         for nodeID,flux in sorted(self.fluxes.iteritems()):
00075             msg += '%10i ' %(nodeID)
00076 
00077             for val in flux:
00078                 if abs(val)<1e-6:
00079                     msg += '%10s' %(0)
00080                 else:
00081                     msg += '%10.3e ' %(val)
00082                 ###
00083             msg += '\n'
00084         return msg
00085 
 All Classes Namespaces Files Functions Variables