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


Python BDF.add_cards方法代码示例

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


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

示例1: _get_nodes

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import add_cards [as 别名]
    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,代码行数:31,代码来源:test_coords.py

示例2: test_cord2r_02

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import add_cards [as 别名]
    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,代码行数:33,代码来源:test_coords.py

示例3: test_cord1s_01

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import add_cards [as 别名]
    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,代码行数:31,代码来源:test_coords.py

示例4: test_cord2c_01

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import add_cards [as 别名]
    def test_cord2c_01(self):
        lines_a = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        lines_b = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card_count = {
            'CORD2C' : 1,
            'CORD2R' : 1,
        }

        model = BDF(debug=False)
        cards = {
            'CORD2C' : ['', lines_a],
            'CORD2R' : ['', lines_b],
        }
        model.add_cards(cards, card_count)
        #model.allocate(cards, card_count)
        card = model.add_card(lines_a, 'CORD2C', is_list=False)
        card = model.add_card(lines_b, 'CORD2R', is_list=False)
        model.build()

        cord2r = model.coords.slice_by_coord_id(3)
        #print(type(cord2r))
        self.assertEquals(cord2r.get_cid_by_coord_id(), 3)
        self.assertEquals(cord2r.get_rid_by_coord_id(), 0)

        cord2r = model.coords.slice_by_coord_id(4)
        #print(type(cord2r))
        self.assertEquals(cord2r.get_cid_by_coord_id(), 4)
        self.assertEquals(cord2r.get_rid_by_coord_id(), 3)

        i = model.coords.get_coord_index_by_coord_id(4)
        T = model.coords.T[i, :, :].reshape(3, 3)
        Ti = T[0, :]
        Tj = T[1, :]
        Tk = T[2, :]
        msg = 'i=%s expected=(0., 0., 1.)'  % Ti
        self.assertTrue(allclose(Ti, array([0., 0., 1.])), msg)
        delta = Tj - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(Tj, array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = Tk - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(Tk, array([-1., 1., 0.]) / 2**0.5), str(delta))
开发者ID:hurlei,项目名称:pyNastran,代码行数:49,代码来源:test_coords.py

示例5: test_cord2r_bad_01

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import add_cards [as 别名]
    def test_cord2r_bad_01(self):
        model = BDF(debug=True)

        card_count = {
            'GRID' : 4,
            'CORD2R' : 3,
        }
        cards = {'GRID' : [], 'CORD2R' : []}
        grids = [
            ['GRID', 1, 0],
            ['GRID', 20, 0],
            ['GRID', 30, 0],
            ['GRID', 11, 5],
        ]
        for grid in grids:
            cards['GRID'].append(('', grid))

        coord_cards = [
            ['CORD2R', 1, 0, 0., 0., 0.,
                             0., 0., 0.,
                             0., 0., 0.],  # fails on self.k
            ['CORD2R', 2, 0, 0., 0., 0.,
                             1., 0., 0.,
                             0., 0., 0.],  # fails on normalize self.j
            ['CORD2R', 3, 0, 0., 0., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
            ['CORD2R', 4, 0, 0., 1., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
            ['CORD2R', 5, 4, 0., 1., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
        ]
        for card in coord_cards:
            card_name = card[0]
            cid = card[1]
            if cid in [1, 2]:
                with self.assertRaises(RuntimeError):
                    cards[card_name].append(('', card))
            else:
                cards[card_name].append(('', card))
        model.add_cards(cards, card_count)
        model.build()

        # this runs because it's got rid=0
        coords = model.coords #.slice_by_coord_id(4)
        coords.transform_node_id_to_global_xyz(30) # nid
        coords.transform_node_id_to_global_xyz([30, 1, 11]) # [nid, nid, nid]
        coords.transform_node_id_to_local_by_coord_id([30, 1, 11], 4)  # [nid, ...], cp_goal
        coords.transform_node_id_to_local_by_coord_id([30, 1, 11], 0)  # [nid, ...], cp_goal

        xyz = [0., 0., 0.]
        coords.transform_xyz_to_global_by_coord_id(xyz, 4) # [xyz], cp_initial
        xyz = [
            [0., 0., 0.],
            [1., 1., 1.],
        ]
        coords.transform_xyz_to_global_by_coord_id(xyz, 4) # [xyz], cp_initial

        # global from global
        coords.transform_xyz_to_global_by_coord_id(xyz, 0) # [xyz], cp_initial

        # this doesn't run because rid != 0
        with self.assertRaises(RuntimeError):
            # cp=0 doesn't exist
            coords.transform_xyz_to_global_by_coord_id(xyz, 2)
开发者ID:hurlei,项目名称:pyNastran,代码行数:69,代码来源:test_coords.py


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