• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python bdf.BDF类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run_fem2

def run_fem2(bdf_model, out_model, xref, punch, sum_load, size, is_double, reject, debug=False, log=None):
    """
    Reads/writes the BDF to verify nothing has been lost

    Parameters
    ----------
    bdf_model : str
        the filename to run
    xref : bool
       xrefs
    punch : bool
       punches
    """
    assert os.path.exists(bdf_model), bdf_model
    assert os.path.exists(out_model), out_model
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info("starting fem2")
    sys.stdout.flush()
    try:
        fem2.read_bdf(out_model, xref=xref, punch=punch)
    except:
        print("failed reading %r" % out_model)
        raise

    # fem2.sumForces()
    # fem2.sumMoments()
    out_model2 = bdf_model + "_out2"
    fem2.write_bdf(out_model2, interspersed=True)
    # fem2.writeAsCTRIA3(out_model_2)
    os.remove(out_model2)
    return fem2
开发者ID:hurlei,项目名称:pyNastran,代码行数:31,代码来源:test_bdf_vectorized2.py


示例2: test_grid_01

    def test_grid_01(self):
        nid = 1
        cp = 2
        cd = 0
        ps = ''
        seid = 0
        card_count = {'GRID': 1,}

        model = BDF()
        model.allocate(card_count)
        data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid])

        nodes = model.grid
        nodes.add(data1)

        #print n1
        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
        nodes.write_bdf(f, size=16, write_header=False)
        nodes.write_bdf(f, size=16, is_double=True, write_header=False)

        # small field
        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
        msg = f.getvalue()
        card = 'GRID           1       2      0.      0.      0.\n'
        self.assertCardEqual(msg, card)

        # large field
        f = StringIO()
        nodes.write_bdf(f, size=16, write_header=False)
        card = ('GRID*                  1               2              0.              0.\n'
                '*                     0.\n')
        msg = f.getvalue()
        self.assertCardEqual(msg, card)
开发者ID:umvarma,项目名称:pynastran,代码行数:35,代码来源:test_nodes.py


示例3: test_combo_1

    def test_combo_1(self):
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        # these are valid
        eids, mass = model.elements.get_mass_by_element_id([8, 9])
        print('massA = %s' % mass)
        eids, mass = model.elements.get_mass_by_element_id(range(1, 10))
        print('massB = %s' % mass)

        # no analysis - out of range
        elements = model.elements[[100000, 100001]]
        eids, mass = model.elements.get_mass_by_element_id(range(100000, 100005))
        print('elementsC = %s' % eids)
        print('massC = %s' % mass)

        eids, mass = model.elements.get_mass_by_element_id(range(-10, -5))
        print('elementsD = %s' % eids)
        print('massD = %s' % mass)

        print('-------------------------')
        eids, mass = model.elements.get_mass_by_element_id(range(-3, 20))
        print('massE = %s' % mass)
        print('eidsE = %s' % eids)
        print('\neid   mass')
        print('----------')
        for eidi, massi in zip(eids, mass):
            print('%-5s %-5s' % (eidi, massi))
开发者ID:umvarma,项目名称:pynastran,代码行数:29,代码来源:test_mass.py


示例4: add_card

    def add_card(self, card_lines, card_name, comment='', is_list=True):
        card_name = card_name.upper()
        self._increase_card_count(card_name)
        if card_name in ['DEQATN']:
            card_obj = card_lines
            card = card_lines
        else:
            if is_list:
                fields = card_lines
            else:
                fields = to_fields(card_lines, card_name)

            # apply OPENMDAO syntax
            if self._is_dynamic_syntax:
                fields = [self._parse_dynamic_syntax(field) if '%' in
                          field[0:1] else field for field in fields]

                card = wipe_empty_fields([interpret_value(field, fields)
                                          if field is not None
                                          else None for field in fields])
            else:  # leave everything as strings
                card = wipe_empty_fields(fields)
            card_obj = BDFCard(card)

        if card_name == 'HYPER':
            hyper = HYPER(card_obj, comment)
            self.hyper[hyper.pid] = hyper
            return
        elif card_name == 'FLOW':
            flow = FLOW(card_obj, comment)
            self.flow[flow.flow_id] = flow
            return
        BDF.add_card(self, card, card_name, comment=comment, is_list=True)
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:33,代码来源:hyper_vector.py


示例5: _get_nodes

    def _get_nodes(self, grids, grids_expected, coords):
        model = BDF(debug=False)

        card_count = {
            'GRID' : len(grids),
            'CORD2R' : len(coords),
        }
        cards = {'GRID' : [], 'CORD2R' : []}
        for grid in grids:
            nid, cid, x, y, z = grid
            card = ['GRID', nid, cid, x, y, z]
            cards['GRID'].append(('', card))

        for coord in coords:
            cid, rid, x, y, z = coord
            card = ['CORD2R', cid, rid] + x + y + z
            cards['CORD2R'].append(('', card))
            #coordObj = model.coords.slice_by_coord_id(cid)
        model.add_cards(cards, card_count)
        model.build()

        for (i, grid) in enumerate(grids_expected):
            nid, cid, x, y, z = grid
            nodes = model.grid
            pos = nodes.get_position_by_node_id([nid])[0]
            n = array([x, y, z])
            msg = 'i=%s expected=%s actual=%s\n' % (i, n, pos)
            #print(msg)
            assert allclose(n, pos), msg
开发者ID:hurlei,项目名称:pyNastran,代码行数:29,代码来源:test_coords.py


示例6: test_cord2c_01

    def test_cord2c_01(self):
        lines = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        model = BDF(debug=False)
        card = model.process_card(lines)
        card = BDFCard(card)
        model.coords.add_cord2c(card)

        lines = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card = model.process_card(lines)
        card = BDFCard(card)
        model.coords.add_cord2r(card)
        model.cross_reference()

        cord2r = model.Coord(3)
        self.assertEquals(cord2r.Cid(), 3)
        self.assertEquals(cord2r.Rid(), 0)

        cord2r = model.Coord(4)
        self.assertEquals(cord2r.Cid(), 4)
        self.assertEquals(cord2r.Rid(), 3)

        self.assertTrue(allclose(cord2r.i, array([0., 0., 1.])))
        delta = cord2r.j - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.j, array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = cord2r.k - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.k, array([-1., 1., 0.]) / 2**0.5), str(delta))
开发者ID:umvarma,项目名称:pynastran,代码行数:33,代码来源:test_coords.py


示例7: test_cord2r_02

    def test_cord2r_02(self):
        grid = ['GRID       20143       7 -9.31-4  .11841 .028296']
        coord = [
            'CORD2R         7           1.135 .089237  -.0676    .135 .089237  -.0676',
            '           1.135 .089237   .9324']

        model = BDF(debug=False)
        card_count = {
            'GRID' : 1,
            'CORD2R' : 1,
        }
        cards = {
            'CORD2R' : [('', coord)],
            'GRID' : [('', grid)],
        }
        model.add_cards(cards, card_count)
        model.build()

        g = model.grid.slice_by_node_id(20143)
        #xyz = g.get_position()
        xyz = model.coords.get_global_position_by_node_id(20143, g.cp[0])[0]

        # by running it through Patran...
        #GRID     20143          1.1067  .207647 -.068531
        expected = array([1.106704, .207647, -0.068531])
        diff = xyz - expected

        msg = '\nexpected=%s \nactual  =%s \ndiff    =%s' % (expected, xyz, diff)
        assert allclose(diff, 0.), msg
        coord = model.coords.slice_by_coord_id(7)
        T = coord.T[0, :, :]
开发者ID:hurlei,项目名称:pyNastran,代码行数:31,代码来源:test_coords.py


示例8: test_cord1s_01

    def test_cord1s_01(self):
        cord1s = ['cord1s,2, 1,4,3']
        grids = [
            ['GRID', 4, 0, 0.0, 0., 0.],
            ['GRID', 3, 0, 0.0, 0., 1.],
            ['GRID', 1, 0, 0.0, 1., 0.],
        ]
        card_count = {
            'CORD1S' : 1,
            'GRID' : 3,
        }
        model = BDF(debug=False)
        cards = {
            'GRID' : [
                ('', grids[0]),
                ('', grids[1]),
                ('', grids[2]),
            ],
            'CORD1S' : [('', cord1s)]
        }
        model.add_cards(cards, card_count)
        model.build()

        size = 8
        bdf_file = StringIO()
        card = model.coords.slice_by_coord_id(2)
        self.assertEquals(card.get_cid_by_coord_id(), 2)
        self.assertEquals(card.get_rid_by_coord_id(), 0)
        card.write_card(bdf_file, size=8, is_double=False)
开发者ID:hurlei,项目名称:pyNastran,代码行数:29,代码来源:test_coords.py


示例9: getNodes

    def getNodes(self, grids, grids_expected, coords):
        model = BDF(debug=False)

        card_count = {
            'GRID' : len(grids),
            'CORD2R' : len(coords),
        }
        model.allocate(card_count)
        for grid in grids:
            (nid, cid, x, y, z) = grid
            model.add_card(['GRID', nid, cid, x, y, z], 'GRID')

        for coord in coords:
            (cid, rid, x, y, z) = coord
            model.add_card(['CORD2R', cid, rid] + x + y + z, 'CORD2R')
            #coordObj = model.Coord(cid)

        model.cross_reference()

        for (i, grid) in enumerate(grids_expected):
            (nid, cid, x, y, z) = grid
            nodes = model.grid
            pos = nodes.get_position_by_node_id([nid])[0]
            n = array([x, y, z])
            msg = 'i=%s expected=%s actual=%s\n' % (i, n, pos)
            print(msg)
            assert allclose(n, pos), msg
开发者ID:umvarma,项目名称:pynastran,代码行数:27,代码来源:test_coords.py


示例10: test_cord1c_01

    def test_cord1c_01(self):
        lines = ['cord1c,2,1,4,3']
        grids = [
            ['GRID', 4, 0, 0.0, 0., 0.],
            ['GRID', 3, 0, 0.0, 0., 1.],
            ['GRID', 1, 0, 0.0, 1., 0.],
        ]

        card_count = {
            'CORD1C' : 1,
            'GRID' : 3,
        }

        model = BDF(debug=False)
        model.allocate(card_count)
        model.add_card(lines, 'CORD1C', is_list=False)
        for grid in grids:
            model.add_card(grid, grid[0], is_list=True)
        model.build()

        size = 8
        bdf_file = StringIO()
        card = model.coords.slice_by_coord_id(2)
        self.assertEquals(card.get_cid_by_coord_id(), 2)
        self.assertEquals(card.get_rid_by_coord_id(), 0)
        card.write_card(bdf_file, size=8, is_double=False)
开发者ID:hurlei,项目名称:pyNastran,代码行数:26,代码来源:test_coords.py


示例11: test_ctetra_01

    def test_ctetra_01(self):
        model = BDF()
        lines = ['CTETRA,85,22,201,202,203,205']
        card = model.process_card(lines)
        card = BDFCard(card)

        size = 8
        f = StringIO()
        hexa = CTETRA4(model)
        hexa.allocate(1)
        hexa.add(card)
        hexa.write_bdf(f, size)
        #card.rawFields()
        print(f.getvalue())
开发者ID:umvarma,项目名称:pynastran,代码行数:14,代码来源:test_solids.py


示例12: test_cpenta_01

    def test_cpenta_01(self):
        model = BDF()
        lines = ['CPENTA,85,22,201,202,203,205,206,207']
        card = model.process_card(lines)
        card = BDFCard(card)

        size = 8
        f = StringIO()
        penta = CPENTA6(model)
        penta.allocate(1)
        penta.add(card)
        penta.write_bdf(f, size)
        #card.rawFields()
        print(f.getvalue())
开发者ID:umvarma,项目名称:pynastran,代码行数:14,代码来源:test_solids.py


示例13: run_bdf

def run_bdf(folder, bdf_filename, debug=False, xref=True, check=True, punch=False,
            cid=None, meshForm='combined', isFolder=False, print_stats=False,
            sum_load=False, size=8, precision='single',
            reject=False, dynamic_vars=None):
    if dynamic_vars is None:
        dynamic_vars = {}
    bdfModel = str(bdf_filename)
    print("bdfModel = %r" % bdfModel)
    if isFolder:
        bdfModel = os.path.join(test_path, folder, bdf_filename)

    assert os.path.exists(bdfModel), '%r doesnt exist' % bdfModel

    print("before read bdf, Memory usage: %s (Mb) " % memory_usage_psutil())
    #print('before read bdf, Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
    fem1 = BDF(debug=debug, log=None)
    if dynamic_vars:
        fem1.set_dynamic_syntax(dynamic_vars)

    fem1.log.info('starting fem1')
    sys.stdout.flush()
    fem2 = None
    diffCards = []
    try:
        outModel = run_fem1(fem1, bdfModel, meshForm, xref, punch, sum_load, size, precision, cid)
        fem2 = run_fem2(bdfModel, outModel, xref, punch, sum_load, size, precision, reject, debug=debug, log=None)
        diffCards = compare(fem1, fem2, xref=xref, check=check, print_stats=print_stats)

    except KeyboardInterrupt:
        sys.exit('KeyboardInterrupt...sys.exit()')
    #except IOError:
        #pass
    #except AttributeError:  # only temporarily uncomment this when running lots of tests
        #pass
    #except SyntaxError:  # only temporarily uncomment this when running lots of tests
        #pass
    #except AssertionError:  # only temporarily uncomment this when running lots of tests
        #pass
    except SystemExit:
        sys.exit('sys.exit...')
    except:
        #exc_type, exc_value, exc_traceback = sys.exc_info()
        #print "\n"
        traceback.print_exc(file=sys.stdout)
        #print msg
        print("-" * 80)
        raise

    print("-" * 80)
    return (fem1, fem2, diffCards)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:50,代码来源:test_bdf.py


示例14: test_bad_01

    def test_bad_01(self):
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        # this passes silently
        print(model.elements[['cat']])

        # this does not
        with self.assertRaises(TypeError):
            print(model.elements[None])

        #print(model.get_elements('cat'))
        with self.assertRaises(KeyError):
            model.get_elements('cat')
开发者ID:umvarma,项目名称:pynastran,代码行数:15,代码来源:test_mass.py


示例15: test_crod_01

    def test_crod_01(self):
        model = BDF(debug=debug)
        model.allocate({"CROD": 1})

        lines = ["CROD          10     100      10       2"]
        model.add_card(lines, "CROD", is_list=False)

        size = 8
        f = StringIO()
        # card = CROD(card)
        card = model.crod.slice_by_element_id([10])
        card.write_card(f, size)
        # card.rawFields()
        self.assertEquals(card.get_element_id_by_element_index(), 10)
        self.assertEquals(card.get_property_id_by_element_index(), 100)
开发者ID:hurlei,项目名称:pyNastran,代码行数:15,代码来源:test_rods.py


示例16: test_chexa_02

    def test_chexa_02(self):
        model = BDF()
        lines = ['CHEXA,85,22,201,202,203,205,206,207,+PN2',
                 '+PN2,209,210,217,  ,  ,  ,213,214,218']
        card = model.process_card(lines)
        card = BDFCard(card)

        size = 8
        f = StringIO()
        hexa = CHEXA20(model)
        hexa.allocate(1)
        hexa.add(card)
        hexa.write_bdf(f, size)
        #card.rawFields()
        print(f.getvalue())
开发者ID:umvarma,项目名称:pynastran,代码行数:15,代码来源:test_solids.py


示例17: test_cpenta_02

    def test_cpenta_02(self):
        model = BDF()
        lines = ['CPENTA,85,22,201,202,203,205,206,207,+PN2',
                 '+PN2,209,210,217,  ,  ,  ,213,214,218']
        card = model.process_card(lines)
        card = BDFCard(card)

        size = 8
        f = StringIO()
        penta = CPENTA15(model)
        penta.allocate(1)
        penta.add(card)
        penta.write_card(f, size)
        #card.rawFields()
        print(f.getvalue())
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:15,代码来源:test_solids.py


示例18: test_grid_04

    def test_grid_04(self):
        model = BDF()
        nid = 1
        cp = 2
        cd = 0
        ps = ''
        seid = 0
        card_count = {'GRID': 2,}

        model = BDF()
        model.allocate(card_count)

        nodes = model.grid
        data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid])
        data2 = BDFCard(['GRID', nid+1, cp, 0., 0., 0., cd, ps, seid])
        data3 = BDFCard(['GRID', nid+2, cp, 0., 0., 0., cd, ps, seid])
        data4 = BDFCard(['GRID', nid+3, cp, 0., 0., 0., cd, ps, seid])
        nodes.add(data1)
        nodes.add(data2)
        nodes.resize(4, refcheck=False)
        #print('nodes.node_id = %s' % nodes.node_id)
        nodes.add(data3)
        self.assertEqual(len(nodes.node_id), 4)
        self.assertEqual(nodes.n, 4)
        self.assertEqual(nodes.i, 3)
        nodes.shrink(refcheck=False)
        #print('nodes.node_id = %s' % nodes.node_id)
        self.assertEqual(len(nodes.node_id), 3)
        self.assertEqual(nodes.n, 3)
        self.assertEqual(nodes.i, 3)

        nodes.resize(4, refcheck=False)
        nodes.add(data4)
        self.assertEqual(len(nodes.node_id), 4)
        self.assertEqual(nodes.n, 4)
        self.assertEqual(nodes.i, 4)

        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
        #print(f.getvalue())

        nodes.resize(2, refcheck=False)
        self.assertEqual(len(nodes.node_id), 2)
        self.assertEqual(nodes.n, 2)
        self.assertEqual(nodes.i, 2)

        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
开发者ID:umvarma,项目名称:pynastran,代码行数:48,代码来源:test_nodes.py


示例19: _write_common

 def _write_common(self, size, card_writer):
     msg = ''
     for fid,flow in sorted(iteritems(self.flow)):
         msg += str(flow)
     for fid,subsonic in sorted(iteritems(self.subsonic)):
         msg += str(subsonic)
     msg += BDF._write_common(self, size, card_writer)
     return msg
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:8,代码来源:sub.py


示例20: test_cord1r_02

 def test_cord1r_02(self):
     model = BDF(debug=False)
     card_count = {
         'CORD1R' : 1,
         'GRID' : 3,
     }
     #model.allocate(card_count)
     cards = [
         ['CORD1R', 1, 1, 2, 3],  # fails on self.k
         ['GRID', 1, 0, 0., 0., 0.],
         ['GRID', 2, 0, 1., 0., 0.],
         ['GRID', 3, 0, 1., 1., 0.],
     ]
     for card in cards:
         model.add_card(card, card[0], comment='comment\n', is_list=True)
     model.build()
     c1 = model.coords.slice_by_coord_id(1)
开发者ID:hurlei,项目名称:pyNastran,代码行数:17,代码来源:test_coords.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vectorized_card.VectorizedCard类代码示例发布时间:2022-05-25
下一篇:
Python base_card.expand_thru函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap