pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
oef_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 # pylint: disable=E1101,C0103,R0902,R0904,R0914
00026 
00027 from __future__ import division, print_function
00028 
00029 from numpy import array
00030 
00031 from pyNastran.op2.resultObjects.op2_Objects import scalarObject
00032 
00033 
00034 class nonlinearFluxObject(scalarObject): # approachCode=10, sortCode=0
00035     def __init__(self, dataCode, iSubcase, loadStep):
00036         scalarObject.__init__(self, dataCode, iSubcase)
00037 
00038         self.loadStep = loadStep
00039         self.eTypes = {}
00040         self.fluxes = {}
00041         self.gradients = {}
00042         if loadStep is not None:
00043             self.addNewTransient()
00044             #self.isTransient = True
00045             #raise Exception('transient not supported for flux yet...')
00046         ###
00047 
00048     def updateDt(self, dataCode, loadStep):
00049         self.dataCode = dataCode
00050         self.applyDataCode()
00051         assert loadStep >= 0.
00052         self.loadStep = loadStep
00053         self.addNewTransient()
00054 
00055     def addNewTransient(self):
00056         """
00057         initializes the transient variables
00058         @note make sure you set self.dt first
00059         """
00060         self.fluxes[self.loadStep]    = {}
00061         self.gradients[self.loadStep] = {}
00062 
00063     def add(self, nodeID, eType, v1, v2, v3, v4=None, v5=None, v6=None):
00064         assert 0 < nodeID < 1000000000, 'nodeID=%s' %(nodeID)
00065         #print("nodeID=%s eType=%s v1=%s v2=%s v3=%s v4=%s v5=%s v6=%s"
00066         #    %(nodeID,eType,v1,v2,v3,v4,v5,v6))
00067         assert nodeID not in self.fluxes[self.loadStep], 'nodeID=%s' %(nodeID)
00068         self.gradients[self.loadStep][nodeID] = array([v1, v2, v3])
00069         self.fluxes[   self.loadStep][nodeID] = array([v4, v5, v6])
00070         self.eTypes[nodeID] = eType
00071 
00072     def __repr__(self):
00073         msg = '---NONLINEAR GRADIENTS & HEAT FLUX---\n'
00074         msg += 'loadStep = %g\n' %(self.loadStep)
00075 
00076         for (dt, fluxPack) in sorted(self.fluxes.iteritems()):
00077             msg += ('%-10s %-8s %-10s %-10s %-10s %-10s %-10s %-10s\n'
00078                   %('GRID','eType','xGrad','yGrad','zGrad',
00079                      'xFlux','yFlux','zFlux'))
00080             
00081             for (nodeID, flux) in sorted(fluxPack.iteritems()):
00082                 eType = self.eTypes[nodeID]
00083                 msg += '%-10i %-8s ' %(nodeID, eType)
00084                 gradients = self.gradients[dt][nodeID]
00085 
00086                 for val in list(gradients)+list(flux):
00087                     if abs(val) < 1e-6:
00088                         msg += '%-10s ' %('0.')
00089                     else:
00090                         msg += '%-10i ' %(val)
00091                     ###
00092                 msg += '\n'
00093             ###
00094         return msg
00095 
 All Classes Namespaces Files Functions Variables