pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
ougWriter.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 from struct import pack
00026 
00027 class Ougv1Writer(object):
00028     def writeOUGV1(self):
00029         msg = ''
00030         self.deviceCode = 1 # print the OP2...
00031 
00032         self.writeStringBlock('OUGV1', 8)
00033 
00034         msg += self.writeMarkers([-1, 7])
00035         out = [101, 0, 4136, 0, 0, 0, 1]  ## @todo what this is - DMAP -> "no def or month,year,one,one"...huh???
00036         msg += pack('iiiiiii',*out)
00037 
00038         msg += self.writeMarkers([-2, 1, 0])
00039 
00040         # approachCode=1, tableCode=1
00041         self.iTable = -3
00042         data = self.displacements
00043         for iSubcase in data:
00044             msg += self.writeMarkers([self.iTable, 1, 0])
00045             msg += self.writeOUG_displacements(iSubcase, data)
00046             self.iTable -= 1
00047         
00048         data = self.temperatures
00049         for iSubcase in data:
00050             msg += self.writeMarkers([self.iTable, 1, 0])
00051             msg += self.writeOUG_displacements(iSubcase, data, thermal=1)
00052             self.iTable -= 1
00053 
00054         # approachCode=3, tableCode=1
00055         #for iSubcase in self.fluxes:
00056         #    msg += writeMarkers([iTable,1,0])
00057         #    msg += self.writeOUG_temperatures(iSubcase,iTable)
00058         #    iTable-=1
00059 
00060         # approachCode=6, tableCode=1
00061         #data = self.nonlinearDisplacements
00062         #for iSubcase in self.nonlinearDisplacements:
00063         #    msg += writeMarkers([iTable,1,0])
00064         #    msg += self.writeOUG_temperatures(iSubcase,iTable)
00065         #    iTable-=1
00066 
00067         #data = self.nonlinearTemperatures
00068         #for iSubcase in self.nonlinearTemperatures:
00069         #    msg += writeMarkers([iTable,1,0])
00070         #    msg += self.writeOUG_temperatures(iSubcase,iTable)
00071         #    iTable-=1
00072         
00073         msg += self.writeMarkers([self.iTable-1, 1, 0])
00074         #self.displacements = {}
00075         #self.temperatures  = {}
00076 
00077     def writeOUG_displacements(self, iSubcase, data, thermal=0):
00078         """
00079         this function writes table 3 for the OUGV1 Table
00080         @todo add the buffer and block caps
00081         """
00082         msg = ''
00083         disp = data[iSubcase]
00084         self.writeMarkers([146, 584])
00085         
00086         lsdvmn = iSubcase  ## @todo is this correct???
00087 
00088         if disp.dt==None:
00089             approachCode = 1  # statics
00090             five = lsdvmn
00091             FiveSixSeven = [lsdvmn,0,0] # fields five,six,seven
00092         else:
00093             approachCode = 6  # transient
00094             FiveSixSeven = [disp.dt,0,0] # fields five,six,seven
00095         ###
00096 
00097         tableCode  = 1  ## statics
00098         sortCode   = 0
00099         randomCode = 0 # 8 @todo no idea...
00100         formatCode = 1 # 9 - Real numbers
00101         numWide    = 7 # 10
00102         #thermal   = 0 # 23
00103         (aCode,tCode) = self.aCode_tCode(approachCode, tableCode, sortCode)
00104 
00105         #12345
00106         zero = pack('i',0)
00107         msg += pack('iiii', aCode, tCode, 0, iSubcase) # 1,2,3,4
00108         msg += pack('iii', *FiveSixSeven) # 5,6,7
00109         msg += pack('iii', randomCode, formatCode, numWide) # 8,9,10
00110 
00111         #22-11 = 11
00112         msg += zero*11
00113 
00114         msg += pack('i',thermal)
00115 
00116         #51-23 = 28
00117         msg += zero*28
00118         msg += self.packTitle(iSubcase)
00119         
00120         msg += data[iSubcase].writeOp2('', self.deviceCode)
00121         #msg += pack('i',4) # data length...
00122         return msg
00123 
 All Classes Namespaces Files Functions Variables