pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
panairIO.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 vtk
00026 from vtk import vtkQuad
00027 from panairGrid import PanairGrid
00028 
00029 class PanairIO(object):
00030     def __init__(self):
00031         pass
00032 #if __name__=='__main__':
00033 #    lawgs = LaWGS('tmx1242.wgs')
00034 #    lawgs.run()
00035 
00036     def loadPanairGeometry(self,panairFileName,dirname,isNodal,isCentroidal):
00037         self.isNodal = isNodal
00038         self.isCentroidal = isCentroidal
00039         #key = self.caseKeys[self.iCase]
00040         #case = self.resultCases[key]
00041         
00042         skipReading = self.removeOldGeometry(panairFileName)
00043         if skipReading:
00044             return
00045 
00046         model = PanairGrid(panairFileName)
00047         self.modelType = model.modelType
00048         model.readGrid()
00049         
00050         nodes,elements = model.getPointsElements()
00051         #for nid,node in enumerate(nodes):
00052             #print "node[%s] = %s" %(nid,str(node))
00053 
00054         self.nNodes = len(nodes)
00055         self.nElements = len(elements)
00056 
00057         #print "nNodes = ",self.nNodes
00058         print "nElements = ",self.nElements
00059 
00060         self.grid.Allocate(self.nElements, 1000)
00061         self.gridResult.SetNumberOfComponents(self.nElements)
00062         self.grid2.Allocate(1, 1000)
00063 
00064         points = vtk.vtkPoints()
00065         points.SetNumberOfPoints(self.nNodes)
00066         self.gridResult.Allocate(self.nNodes,1000)
00067         #vectorReselt.SetNumberOfComponents(3)
00068         self.nidMap = {}
00069         #elem.SetNumberOfPoints(nNodes)
00070         if 0:
00071             fraction = 1./nNodes # so you can color the nodes by ID
00072             for nid,node in sorted(nodes.iteritems()):
00073                 points.InsertPoint(nid-1, *point)
00074                 self.gridResult.InsertNextValue(nid*fraction)
00075                 #print str(element)
00076 
00077                 #elem = vtk.vtkVertex()
00078                 #elem.GetPointIds().SetId(0, i)
00079                 #self.aQuadGrid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
00080                 #vectorResult.InsertTuple3(0, 0.0, 0.0, 1.0)
00081 
00082         for nid,node in enumerate(nodes):
00083             points.InsertPoint(nid, *node)
00084         #print "nid = ",nid
00085 
00086         for eid,element in enumerate(elements):
00087             (p1,p2,p3,p4) = element
00088             #print "element = ",element
00089             elem = vtkQuad()
00090             elem.GetPointIds().SetId(0, p1)
00091             elem.GetPointIds().SetId(1, p2)
00092             elem.GetPointIds().SetId(2, p3)
00093             elem.GetPointIds().SetId(3, p4)
00094             self.grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
00095         ###
00096         print "eid = ",eid
00097         self.grid.SetPoints(points)
00098         #self.grid2.SetPoints(points2)
00099         #self.grid.GetPointData().SetScalars(self.gridResult)
00100         #print dir(self.grid) #.SetNumberOfComponents(0)
00101         #self.grid.GetCellData().SetNumberOfTuples(1);
00102         #self.grid.GetCellData().SetScalars(self.gridResult)
00103         self.grid.Modified()
00104         self.grid2.Modified()
00105         self.grid.Update()
00106         self.grid2.Update()
00107         print "updated grid"
00108 
00109         return
00110 
00111         # loadCart3dResults - regions/loads
00112         self.TurnTextOn()
00113         self.scalarBar.VisibilityOn()
00114         self.scalarBar.Modified()
00115 
00116         self.iSubcaseNameMap = {1:['Cart3d','']}
00117         cases = {}
00118         ID = 1
00119         
00120         #print "nElements = ",nElements
00121         cases = self.fillCart3dCase(cases,ID,regions,loads)
00122 
00123         self.resultCases = cases
00124         self.caseKeys = sorted(cases.keys())
00125         #print "caseKeys = ",self.caseKeys
00126         #print "type(caseKeys) = ",type(self.caseKeys)
00127         self.iCase = -1
00128         self.nCases = len(self.resultCases)-1 # number of keys in dictionary
00129         self.cycleResults() # start at nCase=0
00130 
00131 if __name__=='__main__':
00132     print ''
00133     def removeOldGeometry(self):
00134         pass
00135 
00136     test = PanairIO()
00137     test.removeOldGeometry = removeOldGeometry
00138 
00139     #test.loadPanairGeometry('SWB.INP','',True,True)
00140     test.loadPanairGeometry('models/NAC6.INP','',True,True)
 All Classes Namespaces Files Functions Variables