当前位置: 首页>>代码示例>>Python>>正文


Python BDF.nElements方法代码示例

本文整理汇总了Python中pyNastran.bdf.bdf.BDF.nElements方法的典型用法代码示例。如果您正苦于以下问题:Python BDF.nElements方法的具体用法?Python BDF.nElements怎么用?Python BDF.nElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyNastran.bdf.bdf.BDF的用法示例。


在下文中一共展示了BDF.nElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_nastran_geometry

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import nElements [as 别名]
    def load_nastran_geometry(self, bdf_filename, dirname):
        self.eidMap = {}
        self.nidMap = {}
        #print('bdf_filename=%r' % bdf_filename)
        #key = self.caseKeys[self.iCase]
        #case = self.resultCases[key]

        #skipReading = self.removeOldGeometry(bdfFileName)
        #if skipReading:
            #return
        if bdf_filename is None or bdf_filename is '':
            #self.grid = vtk.vtkUnstructuredGrid()
            #self.gridResult = vtk.vtkFloatArray()
            #self.emptyResult = vtk.vtkFloatArray()
            #self.vectorResult = vtk.vtkFloatArray()
            #self.grid2 = vtk.vtkUnstructuredGrid()
            #self.scalarBar.VisibilityOff()
            return
        else:
            self.TurnTextOff()
            self.grid.Reset()
            self.grid2.Reset()
            #self.gridResult = vtk.vtkFloatArray()
            #self.gridResult.Reset()
            #self.gridResult.Modified()
            #self.eidMap = {}
            #self.nidMap = {}

            self.resultCases = {}
            self.nCases = 0
        for i in ('caseKeys', 'iCase', 'iSubcaseNameMap'):
            if hasattr(self, i):
                del i

            #print dir(self)
        self.scalarBar.VisibilityOff()
        self.scalarBar.Modified()

        fname_base, ext = os.path.splitext(bdf_filename)
        punch = False
        if ext.lower() in '.pch':
            punch = True

        #if bdf_filename.lower().endswith('.op2'):  # read the OP2; requires make_geom
            #op2_filename = bdf_filename
            #model = OP2(# make_geom=True,
                       #debug=True, log=self.log)
            #model.read_op2(op2_filename)
            #model.cross_reference(xref=True, xref_loads=False, xref_constraints=False)
        if 0:
            pass
        else:  # read the bdf/punch
            model = BDF(log=self.log, debug=True)
            self.modelType = model.modelType
            model.read_bdf(bdf_filename, include_dir=dirname, punch=punch)

        nNodes = model.nNodes()
        assert nNodes > 0
        nElements = model.nElements()
        assert nElements > 0
        nCAeros = model.nCAeros()
        self.nNodes = nNodes
        self.nElements = nElements

        print "nNodes = ",self.nNodes
        self.log_info("nElements = %i" % self.nElements)
        msg = model.get_bdf_stats(return_type='list')
        #self.log_info(msg)
        for msgi in msg:
            model.log.debug(msgi)

        #self.aQuadGrid.Allocate(nElements+nNodes, 1000)

        if 'CONM2' in model.card_count:
            nCONM2 = model.card_count['CONM2']
        else:
            nCONM2 = 0
        self.grid.Allocate(self.nElements, 1000)
        #self.gridResult.SetNumberOfComponents(self.nElements)
        self.grid2.Allocate(nCAeros + nCONM2, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.nNodes)
        #self.gridResult.Allocate(self.nNodes, 1000)
        #vectorReselt.SetNumberOfComponents(3)
        #elem.SetNumberOfPoints(nNodes)
        if 0:
            i = 0
            fraction = 1. / nNodes  # so you can color the nodes by ID
            for (nid, node) in sorted(model.nodes.iteritems()):
                point = node.Position()
                points.InsertPoint(i, *point)
                #self.gridResult.InsertNextValue(i * fraction)

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

#.........这里部分代码省略.........
开发者ID:sukhbinder,项目名称:cyNastran,代码行数:103,代码来源:nastranIO.py

示例2: loadGeometry

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import nElements [as 别名]
    def loadGeometry(self, bdf_filename):
        model = BDF()
        model.readBDF(bdf_filename)

        nNodes = model.nNodes()
        nElements = model.nElements()
        nCAeros = model.nCAeros()

        #print "nNodes = ",nNodes
        print "nElements = ", nElements

        self.grid = vtk.vtkUnstructuredGrid()
        self.grid2 = vtk.vtkUnstructuredGrid()
        #self.aQuadGrid.Allocate(nElements+nNodes, 1000)

        if 'CONM2' in model.cardCount:
            nCONM2 = model.cardCount['CONM2']
        else:
            nCONM2 = 0
        self.grid.Allocate(nElements, 1000)
        self.grid2.Allocate(nCAeros + nCONM2, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(nNodes)
        nidMap = {}
        i = 0
        #elem.SetNumberOfPoints(nNodes)
        for nid, node in sorted(model.nodes.iteritems()):
            #print "i = ",i
            point = node.Position()
            #print "point = ",point
            #sys.stdout.flush()
            #aVoxel = vtk.vtkPixel()
            #print "made voxel"; sys.stdout.flush()
            points.InsertPoint(i, *point)

            #print str(element)

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

            nidMap[nid] = i
            i += 1

        j = 0
        points2 = vtk.vtkPoints()
        points2.SetNumberOfPoints(nCAeros * 4 + nCONM2)
        for eid, element in sorted(model.caeros.iteritems()):
            if isinstance(element, CAERO1):
                cpoints = element.Points()
                elem = vtkQuad()
                elem.GetPointIds().SetId(0, j)
                elem.GetPointIds().SetId(1, j + 1)
                elem.GetPointIds().SetId(2, j + 2)
                elem.GetPointIds().SetId(3, j + 3)
                points2.InsertPoint(j, *cpoints[0])
                points2.InsertPoint(j + 1, *cpoints[1])
                points2.InsertPoint(j + 2, *cpoints[2])
                points2.InsertPoint(j + 3, *cpoints[3])
                self.grid2.InsertNextCell(
                    elem.GetCellType(), elem.GetPointIds())
                j += 4
        self.mapElements(points, points2, nidMap, model, j)
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:66,代码来源:demoGui.py

示例3: loadNastranGeometry

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import nElements [as 别名]
    def loadNastranGeometry(self, bdfFileName, dirname, isNodal, isCentroidal):
        self.isNodal = isNodal
        self.isCentroidal = isCentroidal
        #key = self.caseKeys[self.iCase]
        #case = self.resultCases[key]

        #skipReading = self.removeOldGeometry(bdfFileName)
        #if skipReading:
            #return
        if bdfFileName is None:
            self.grid = vtk.vtkUnstructuredGrid()
            self.gridResult = vtk.vtkFloatArray()
            #self.emptyResult = vtk.vtkFloatArray()
            #self.vectorResult = vtk.vtkFloatArray()
            self.grid2 = vtk.vtkUnstructuredGrid()
            self.scalarBar.VisibilityOff()
            return
        else:
            self.TurnTextOff()
            self.grid.Reset()
            self.grid2.Reset()
            self.gridResult = vtk.vtkFloatArray()
            self.gridResult.Reset()
            self.gridResult.Modified()
            self.eidMap = {}
            self.nidMap = {}

            self.resultCases = {}
            self.nCases = 0
            try:
                if hasattr(self, caseKeys):
                    del self.caseKeys
                del self.iCase
                del self.iSubcaseNameMap
            except NameError:
                print("cant delete geo")
                #pass
            ###
            #print dir(self)
        self.scalarBar.VisibilityOff()
        self.scalarBar.Modified()

        model = BDF()
        self.modelType = model.modelType
        model.readBDF(bdfFileName, includeDir=dirname)

        nNodes = model.nNodes()
        nElements = model.nElements()
        nCAeros = model.nCAeros()
        self.nNodes = nNodes
        self.nElements = nElements

        #print "nNodes = ",self.nNodes
        print("nElements = %i" % (self.nElements))

        #self.aQuadGrid.Allocate(nElements+nNodes, 1000)

        if 'CONM2' in model.cardCount:
            nCONM2 = model.cardCount['CONM2']
        else:
            nCONM2 = 0
        self.grid.Allocate(self.nElements, 1000)
        #self.gridResult.SetNumberOfComponents(self.nElements)
        #self.gridResult.SetNumberOfComponents(0)
        self.gridResult.SetNumberOfComponents(self.nElements)
        #self.gridResult.Allocate(self.nNodes,1000)

        self.grid2.Allocate(nCAeros + nCONM2, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.nNodes)
        self.gridResult.Allocate(self.nNodes, 1000)
        #vectorReselt.SetNumberOfComponents(3)
        self.nidMap = {}
        #elem.SetNumberOfPoints(nNodes)
        if 0:
            i = 0
            fraction = 1. / nNodes  # so you can color the nodes by ID
            for (nid, node) in sorted(model.nodes.iteritems()):
                #print "i = ",i
                point = node.Position()
                #print "point = ",point
                points.InsertPoint(i, *point)
                self.gridResult.InsertNextValue(i * 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)

                self.nidMap[nid] = i
                i += 1
        if 1:
            i = 0
            for (nid, node) in sorted(model.nodes.iteritems()):
                point = node.Position()
                points.InsertPoint(i, *point)
                self.nidMap[nid] = i
#.........这里部分代码省略.........
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:103,代码来源:nastranIO.py


注:本文中的pyNastran.bdf.bdf.BDF.nElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。