コード例 #1
0
    def loadCart3dGeometry(self, cart3dFileName, dirname, isNodal,
                           isCentroidal):
        self.isNodal = isNodal
        self.isCentroidal = isCentroidal
        #key = self.caseKeys[self.iCase]
        #case = self.resultCases[key]

        skipReading = self.removeOldGeometry(cart3dFileName)
        if skipReading:
            return

        model = genericCart3DReader(cart3dFileName)
        self.modelType = model.modelType
        (nodes, elements, regions, loads) = model.readCart3d(cart3dFileName)
        self.nNodes = model.nPoints
        self.nElements = model.nElementsRead

        #print "nNodes = ",self.nNodes
        print "nElements = ", self.nElements

        self.grid.Allocate(self.nElements, 1000)
        self.gridResult.SetNumberOfComponents(self.nElements)
        self.grid2.Allocate(1, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.nNodes)
        self.gridResult.Allocate(self.nNodes, 1000)
        #vectorReselt.SetNumberOfComponents(3)
        self.nidMap = {}
        #elem.SetNumberOfPoints(nNodes)
        if 0:
            fraction = 1. / self.nNodes  # so you can color the nodes by ID
            for nid, node in sorted(nodes.iteritems()):
                points.InsertPoint(nid - 1, *node)
                self.gridResult.InsertNextValue(nid * fraction)
                #print str(element)

                #elem = vtk.vtkVertex()
                #elem.GetPointIds().SetId(0, i)
                #self.aQuadGrid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
                #vectorResult.InsertTuple3(0, 0.0, 0.0, 1.0)

        assert nodes is not None
        for nid, node in sorted(nodes.iteritems()):
            points.InsertPoint(nid - 1, *node)

        for eid, nodeIDs in sorted(elements.iteritems()):
            #print "ctria3"
            elem = vtkTriangle()
            elem.GetPointIds().SetId(0, nodeIDs[0] - 1)
            elem.GetPointIds().SetId(1, nodeIDs[1] - 1)
            elem.GetPointIds().SetId(2, nodeIDs[2] - 1)
            self.grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
        ###
        self.grid.SetPoints(points)
        #self.grid2.SetPoints(points2)
        #self.grid.GetPointData().SetScalars(self.gridResult)
        #print dir(self.grid) #.SetNumberOfComponents(0)
        #self.grid.GetCellData().SetNumberOfTuples(1);
        #self.grid.GetCellData().SetScalars(self.gridResult)
        self.grid.Modified()
        #self.grid2.Modified()
        self.grid.Update()
        #self.grid2.Update()
        print "updated grid"

        # loadCart3dResults - regions/loads
        self.TurnTextOn()
        self.scalarBar.VisibilityOn()
        self.scalarBar.Modified()

        self.iSubcaseNameMap = {1: ['Cart3d', '']}
        cases = {}
        ID = 1

        #print "nElements = ",nElements
        cases = self.fillCart3dCase(cases, ID, regions, loads)

        self.resultCases = cases
        self.caseKeys = sorted(cases.keys())
        #print "caseKeys = ",self.caseKeys
        #print "type(caseKeys) = ",type(self.caseKeys)
        self.iCase = -1
        self.nCases = len(self.resultCases) - 1  # number of keys in dictionary
        self.cycleResults()  # start at nCase=0
コード例 #2
0
ファイル: toPanair.py プロジェクト: xirxa/pynastran-locr
    def run(self, cart3dGeom, oname, BCMap):
            f = open(oname, 'wb')
            print "oname", oname
            self.mach = mach
            self.ncases = 1
            self.alphaC = alphaCompressibility
            self.alphas = [alphas]

            self.betaC = betaCompressibility
            self.betas = [beta]
            self.xref = xref
            self.yref = yref
            self.zref = zref
            self.sref = Sref
            self.bref = Bref
            self.cref = Cref
            self.dref = Dref
            self.isEnd = True
            msg = ''
            #msg += self.writeTitle()
            msg += self.writeMach()
            msg += self.writeCases()
            msg += self.writeAlphas()
            msg += self.writeBetas()
            msg += self.writeReferenceQuantities()
            msg += self.printout
            f.write(msg)

            cart = genericCart3DReader(cart3dGeom)
            (points, elements, regions, loads) = cart.readCart3d(cart3dGeom)

            for pid, point in sorted(points.iteritems()):
                #if pid<85:
                #    print pid,point
                pass
            for eid, element in sorted(elements.iteritems()):
                region = regions[eid]
                if region not in BCMap:
                    continue
                (kt, cpNorm) = BCMap[region]
                if cpNorm is None:
                    cpNorm = ''

                #print "****"
                #print "element =",element
                #print "region  =",region
                #if eid==2:
                #    print "points = ",points
                nid1, nid2, nid3 = element
                n1, n2, n3 = points[nid1], points[nid2], points[nid3]
                #print "n1=%s" %(n1)
                #print "n2=%s" %(n2)
                #print "n3=%s" %(n3)
                #p1 =
                #sys.exit()

                netName = 'e%s' % (eid)

                header = '$points - surface panels\n'

                header += '%-10s%-10s\n' % ('1.', cpNorm)  # nNetworks is 1
                header += '%-10s\n' % (sInt(kt))
                header += '%-10s%-10s%50s%-10s\n' % (
                    sInt(2), sInt(2), '', netName)
                pointsOut = self.writePoints(n1, n2)
                pointsOut += self.writePoints(n3, n3)
                f.write(header + pointsOut)
                #break
            #print points
            #print outfilename

            f.write('$end of panair inputs\n')
コード例 #3
0
    def run(self, cart3dGeom, oname, BCMap):
        f = open(oname, 'wb')
        print "oname", oname
        self.mach = mach
        self.ncases = 1
        self.alphaC = alphaCompressibility
        self.alphas = [alphas]

        self.betaC = betaCompressibility
        self.betas = [beta]
        self.xref = xref
        self.yref = yref
        self.zref = zref
        self.sref = Sref
        self.bref = Bref
        self.cref = Cref
        self.dref = Dref
        self.isEnd = True
        msg = ''
        #msg += self.writeTitle()
        msg += self.writeMach()
        msg += self.writeCases()
        msg += self.writeAlphas()
        msg += self.writeBetas()
        msg += self.writeReferenceQuantities()
        msg += self.printout
        f.write(msg)

        cart = genericCart3DReader(cart3dGeom)
        (points, elements, regions, loads) = cart.readCart3d(cart3dGeom)

        for pid, point in sorted(points.iteritems()):
            #if pid<85:
            #    print pid,point
            pass
        for eid, element in sorted(elements.iteritems()):
            region = regions[eid]
            if region not in BCMap:
                continue
            (kt, cpNorm) = BCMap[region]
            if cpNorm is None:
                cpNorm = ''

            #print "****"
            #print "element =",element
            #print "region  =",region
            #if eid==2:
            #    print "points = ",points
            nid1, nid2, nid3 = element
            n1, n2, n3 = points[nid1], points[nid2], points[nid3]
            #print "n1=%s" %(n1)
            #print "n2=%s" %(n2)
            #print "n3=%s" %(n3)
            #p1 =
            #sys.exit()

            netName = 'e%s' % (eid)

            header = '$points - surface panels\n'

            header += '%-10s%-10s\n' % ('1.', cpNorm)  # nNetworks is 1
            header += '%-10s\n' % (sInt(kt))
            header += '%-10s%-10s%50s%-10s\n' % (sInt(2), sInt(2), '', netName)
            pointsOut = self.writePoints(n1, n2)
            pointsOut += self.writePoints(n3, n3)
            f.write(header + pointsOut)
            #break
        #print points
        #print outfilename

        f.write('$end of panair inputs\n')
コード例 #4
0
ファイル: cart3dIO.py プロジェクト: xirxa/pynastran-locr
    def loadCart3dGeometry(self, cart3dFileName, dirname, isNodal, isCentroidal):
        self.isNodal = isNodal
        self.isCentroidal = isCentroidal
        #key = self.caseKeys[self.iCase]
        #case = self.resultCases[key]

        skipReading = self.removeOldGeometry(cart3dFileName)
        if skipReading:
            return

        model = genericCart3DReader(cart3dFileName)
        self.modelType = model.modelType
        (nodes, elements, regions, loads) = model.readCart3d(cart3dFileName)
        self.nNodes = model.nPoints
        self.nElements = model.nElementsRead

        #print "nNodes = ",self.nNodes
        print "nElements = ", self.nElements

        self.grid.Allocate(self.nElements, 1000)
        self.gridResult.SetNumberOfComponents(self.nElements)
        self.grid2.Allocate(1, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.nNodes)
        self.gridResult.Allocate(self.nNodes, 1000)
        #vectorReselt.SetNumberOfComponents(3)
        self.nidMap = {}
        #elem.SetNumberOfPoints(nNodes)
        if 0:
            fraction = 1. / self.nNodes  # so you can color the nodes by ID
            for nid, node in sorted(nodes.iteritems()):
                points.InsertPoint(nid - 1, *node)
                self.gridResult.InsertNextValue(nid * fraction)
                #print str(element)

                #elem = vtk.vtkVertex()
                #elem.GetPointIds().SetId(0, i)
                #self.aQuadGrid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
                #vectorResult.InsertTuple3(0, 0.0, 0.0, 1.0)

        assert nodes is not None
        for nid, node in sorted(nodes.iteritems()):
            points.InsertPoint(nid - 1, *node)

        for eid, nodeIDs in sorted(elements.iteritems()):
            #print "ctria3"
            elem = vtkTriangle()
            elem.GetPointIds().SetId(0, nodeIDs[0] - 1)
            elem.GetPointIds().SetId(1, nodeIDs[1] - 1)
            elem.GetPointIds().SetId(2, nodeIDs[2] - 1)
            self.grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
        ###
        self.grid.SetPoints(points)
        #self.grid2.SetPoints(points2)
        #self.grid.GetPointData().SetScalars(self.gridResult)
        #print dir(self.grid) #.SetNumberOfComponents(0)
        #self.grid.GetCellData().SetNumberOfTuples(1);
        #self.grid.GetCellData().SetScalars(self.gridResult)
        self.grid.Modified()
        #self.grid2.Modified()
        self.grid.Update()
        #self.grid2.Update()
        print "updated grid"

        # loadCart3dResults - regions/loads
        self.TurnTextOn()
        self.scalarBar.VisibilityOn()
        self.scalarBar.Modified()

        self.iSubcaseNameMap = {1: ['Cart3d', '']}
        cases = {}
        ID = 1

        #print "nElements = ",nElements
        cases = self.fillCart3dCase(cases, ID, regions, loads)

        self.resultCases = cases
        self.caseKeys = sorted(cases.keys())
        #print "caseKeys = ",self.caseKeys
        #print "type(caseKeys) = ",type(self.caseKeys)
        self.iCase = -1
        self.nCases = len(self.resultCases) - 1  # number of keys in dictionary
        self.cycleResults()  # start at nCase=0