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


Python BDF.writeBDFAsPatran方法代码示例

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


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

示例1: run_fem2

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import writeBDFAsPatran [as 别名]
def run_fem2(bdfModel, outModel, xref, debug=False, log=None):
    assert os.path.exists(bdfModel), bdfModel
    assert os.path.exists(outModel), outModel
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info('starting fem2')
    sys.stdout.flush()
    try:
        fem2.readBDF(outModel, xref=xref)
    except:
        print("failed reading |%s|" % (outModel))
        raise

    #fem2.sumForces()
    #fem2.sumMoments()
    outModel2 = bdfModel + '_out2'
    fem2.writeBDFAsPatran(outModel2)
    #fem2.writeAsCTRIA3(outModel2)
    os.remove(outModel2)
    return (fem2)
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:21,代码来源:test_bdf.py

示例2: PanelBuckling

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import writeBDFAsPatran [as 别名]

#.........这里部分代码省略.........
                elif edgeCount == 2:
                    for touchingElement in touchingElements:
                        if eid == touchingElement:
                            continue
                        nTouch = Normals[touchingElement]

                        angle = self.Angle(nEid, nTouch)  # degrees
                        if angle < self.maxAngle:
                            print "   *angle[%s,%s] = %g" % (eid, touchingElement, angle)
                            panelEids[touchingElement] = panelID
                        else:
                            print "    angle[%s,%s] = %g" % (eid, touchingElement, angle)

                else:
                    print "  edgeCount = ", edgeCount
                    self.skippedEdges.append(edge)

            print ""

        for edge in self.skippedEdges:
            elements = Edges2[edge]
            for eid in elements:
                if eid in panelEids:
                    del panelEids[eid]
        del Edges

        print "skippedEdges = ", self.skippedEdges

        reversedPanelEids = {}
        # i dont like initializing lists within dictionaries, messy
        for eid, panelID in panelEids.iteritems():
            reversedPanelEids[panelID] = []

        IDsToKeep = [74]
        for eid, panelID in panelEids.iteritems():
            reversedPanelEids[panelID].append(eid)

        eidsToRemove = []
        for panelID, eids in sorted(reversedPanelEids.iteritems()):
            print "panelID=%s nEids=%s eids=%s" % (panelID, len(eids), eids)
            if panelID not in IDsToKeep:
                print "****removing ", panelID
                eidsToRemove += eids

        print "eidsToRemove = ", eidsToRemove
        for eid in eidsToRemove:
            del self.bdf.elements[eid]

        #self.bdf.elements = shells2
        self.bdf.writeBDFAsPatran('fem.out.bdf')
        print "done building panels!!!"

    def Angle(self, nEid, nTouch):
        r"""
        \f[ a \cdot b = cos(\theta) * |a| * |b| \f]
        if \|a\|=\|b\|=1. (unit vectors)
        \f[ a \cdot b = cos(\theta) \f]
        """
        d = dot(nEid, nTouch)
        if d >= 1.0:  # python is stupid...
            return 0.
        elif d <= -1.:
            return pi

        #try:
        angle = degrees(acos(d))
        #except ValueError:
        #    print "nEid=%s nTouch=%s d=%s" %(nEid,nTouch,d)
        #    raise
        return angle

    def angle2(self, other, arcos=False):
        """
        max(min(..)) because acos/asin sometimes are given values slightly outside [-1, 1]
        no idea how to use this...
        """
        pass
        if arcos:
            return acos(max(min((self * other) / (self.length * other.length), 1), -1))
        else:
            return asin(max(min((self * other.ortho()) / (self.length * other.length), 1), -1))

    def removeExtraElements(self, eid, touchingElements):
        return list(set(touchingElements))

        #print "touchingElements1 = ",touchingElements
        for i, touchingElement in enumerate(touchingElements):
            #print "eidsDone = ",self.eidsDone
            if touchingElement in self.eidsDone:
                touchingElements.pop(i)
        # remove eid
        try:
            touchingElements.pop(touchingElements.index(eid))
        except:
            pass
        #print "touchingElements2 = ",touchingElements
        return touchingElements

    def removeExtraElements2(self, elements):
        return list(set(elements))
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:104,代码来源:panelBuckling.py


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