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


Python BDF.read_bdf方法代码示例

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


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

示例1: get_free_edges

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def get_free_edges(bdf_filename, eids=None, maps=None):
    """
    assumes no solids/bars

    Parameters
    ----------
    bdf_filename : str, BDF()
       a BDF object or filename
    maps : List[...] (default=None -> calculate)
       the output from _get_maps(eids, map_names=None,
                              consider_0d=False, consider_0d_rigid=False,
                              consider_1d=False, consider_2d=True, consider_3d=False)

    Returns
    -------
    free_edges : List[(int nid1, int nid2), ...]
       the free edges
    """
    if isinstance(bdf_filename, string_types):
        model = BDF(debug=False)
        model.read_bdf(bdf_filename)
    else:
        model = bdf_filename

    free_edges = []
    if maps is None:
        maps = model._get_maps(eids, map_names=None,
                               consider_0d=False, consider_0d_rigid=False,
                               consider_1d=False, consider_2d=True, consider_3d=False)
    edge_to_eid_map = maps[0]
    for edge, eids in iteritems(edge_to_eid_map):
        if len(eids) == 2:
            continue
        free_edges.append(edge)
    return free_edges
开发者ID:saullocastro,项目名称:pyNastran,代码行数:37,代码来源:dev_utils.py

示例2: test_include_end

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_include_end(self):
        if PY2:
            wb = 'wb'
        else:
            wb = 'w'
        f = open('a.bdf', wb)
        f.write('CEND\n')
        f.write('BEGIN BULK\n')
        f.write('GRID,1,,1.0\n')
        f.write("INCLUDE 'b.bdf'\n\n")

        f = open('b.bdf', wb)
        f.write('GRID,2,,2.0\n')
        f.write("INCLUDE 'c.bdf'\n\n")

        f = open('c.bdf', wb)
        f.write('GRID,3,,3.0\n\n')
        f.write("ENDDATA\n")
        f.close()

        model = BDF(log=log, debug=False)
        model.read_bdf('a.bdf')
        model.write_bdf('a.out.bdf')

        os.remove('a.bdf')
        os.remove('b.bdf')
        os.remove('c.bdf')
        os.remove('a.out.bdf')
        self.assertEqual(len(model.nodes), 3)
        self.assertEqual(model.nnodes, 3, 'nnodes=%s' % model.nnodes)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:32,代码来源:test_read_write.py

示例3: process_nastran

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True):
    """
    Converts Nastran to STL/Cart3d/Tecplot
    """
    assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid', 'nastran'], 'format2=%s' % fmt2
    xref = True
    if fmt2 == 'ugrid':
        xref = False
    model = BDF(debug=debug)
    model.read_bdf(bdf_filename, xref=xref)

    if data['--scale'] != 1.0:
        scale = data['--scale']
        data['--scale'] = 1.0
        for nid, node in iteritems(model.nodes):
            xyz = node.get_position()
            node.xyz *= scale
            node.cp = 0
            del node.cp_ref

    if fmt2 == 'stl':
        nastran_to_stl(model, fname2, is_binary=data['--binary'])
    elif fmt2 == 'cart3d':
        cart3d = nastran_to_cart3d(model)
        cart3d.write_cart3d(fname2)
    elif fmt2 == 'tecplot':
        tecplot = nastran_to_tecplot(model)
        tecplot_filename = fname2
        tecplot.write_tecplot(tecplot_filename, adjust_nids=False)
    elif fmt2 == 'ugrid':
        ugrid = nastran_to_ugrid(model, fname2)
    elif fmt2 == 'nastran':
        model.write_bdf(fname2, size=16)
    else:
        raise NotImplementedError(fmt2)
开发者ID:hurlei,项目名称:pyNastran,代码行数:37,代码来源:type_converter.py

示例4: example4

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def example4():
    """
    Example 4: Get Element ID & Type - Level 2
    """
    # Print the Element ID and its type(e.g. CQUAD4, CTRIA3, etc.) to a file

    # note this skips rigidElements

    # this example will demonstate:
    #  - accessing element type information

    # our model
    import pyNastran
    pkg_path = pyNastran.__path__[0]
    test_path = os.path.join(pkg_path, '..', 'models', 'solid_bending')
    bdf_filename = os.path.join(test_path, 'solid_bending.bdf')

    # instantiate the model
    from pyNastran.bdf.bdf import BDF
    model = BDF()
    model.read_bdf(bdf_filename, xref=True)
    f = open('junk.out', 'w')

    ####
    ####Method 1 - using objects
    ####---------------------------------
    ####
    for eid,element in sorted(model.elements.items()):
        msg = 'eid=%s type=%s\n' %(eid, element.type)
    f.write(msg)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:32,代码来源:bdf_doc.py

示例5: example5

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def example5():
    """
    Example 5: Get Elements by Node ID - Level 2
    """

    # this example will demonstate:
    #  - getting the list of elements that share a certain node

    # our model
    import pyNastran
    pkg_path = pyNastran.__path__[0]
    test_path = os.path.join(pkg_path, '..', 'models', 'solid_bending')
    bdf_filename = os.path.join(test_path, 'solid_bending.bdf')

    # instantiate the model
    from pyNastran.bdf.bdf import BDF
    model = BDF()
    model.read_bdf(bdf_filename, xref=True)
    f = open('junk.out', 'w')

    # given a Node, get the Elements Attached to that Node
    # assume node 55
    # doesnt support 0d/1d elements yet
    nid_to_eids_map = model.get_node_id_to_element_ids_map()
    eids = nid_to_eids_map[55]

    # convert to elements instead of element IDs
    elements = []
    for eid in eids:
        elements.append(model.Element(eid))

    print("eids = %s" % eids)
    print("elements =\n %s" % elements)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:35,代码来源:bdf_doc.py

示例6: test_strain

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
 def test_strain(self):
     for folder, prefix, subcase in CASES:
         bdf = BDF(debug=False)
         op2 = OP2(debug=False)
         basepath = os.path.join(pkg_path, 'op2', 'test', folder)
         bdf.read_bdf(os.path.join(basepath, prefix + '.bdf'))
         op2.read_op2(os.path.join(basepath, prefix + '.op2'))
         op2_new = data_in_material_coord(bdf, op2)
         for vecname in strain_vectors:
             vector = getattr(op2_new, vecname).get(subcase)
             if vector is None:
                 continue
             name = os.path.join(basepath, '{0}_subcase_{1:02d}.txt'.format(vecname, subcase))
             if not os.path.isfile(name):
                 raise AssertionError('Not found reference result {0}'.format(name))
             ref_result = np.loadtxt(name)
             data = vector.data
             eids = get_eids_from_op2_vector(vector)
             check = eids != 0
             if 'cquad8' in vecname:
                 assert np.allclose(data[:, check][:, 0::10, :], ref_result[0::10], rtol=RTOL, atol=ATOL)
                 assert np.allclose(data[:, check][:, 1::10, :], ref_result[1::10], rtol=RTOL, atol=ATOL)
             else:
                 assert np.allclose(data[:, check], ref_result, rtol=RTOL, atol=ATOL)
         print('OK')
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:27,代码来源:test_op2_in_material_coord.py

示例7: run_model

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def run_model(self, bdf_name=None, f06_name=None, op2_name=None,
                  op4_name=None, dynamic_vars=None, f06_has_weight=True):
        outputs = []
        if bdf_name:
            bdf = BDF(debug=False, log=None)
            if dynamic_vars is not None:
                bdf.set_dynamic_syntax(dynamic_vars)
            bdf.read_bdf(bdf_name)
            bdf.write_bdf(bdf_name+'.out', interspersed=False)
            bdf.write_bdf(bdf_name+'.out', interspersed=True)
            outputs.append(bdf)

        if op2_name:
            op2 = OP2(debug=False)
            op2.read_op2(op2_name, vectorized=False)
            op2.write_f06(op2_name[:-4] + '.test_op2.out')
            outputs.append(op2)

        if f06_name:
            f06 = F06(debug=False, log=None)
            f06.read_f06(f06_name)
            f06.write_f06(f06_name[:-4] + '.test_f06.out')
            outputs.append(f06)
            if f06_has_weight:
                assert f06.grid_point_weight.reference_point is not None
            else:
                assert f06.grid_point_weight.reference_point is None

        if op4_name:
            op4 = OP4()
            op4.read_op4(op4_name, matrixNames=None, precision='default')

        assert len(outputs) > 0
        if len(outputs) == 1: return outputs[0]
        return outputs
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:37,代码来源:f06_unit_tests.py

示例8: test_op2_bcell_01

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_op2_bcell_01(self):
        folder = os.path.abspath(os.path.join(test_path, '..', 'models'))
        bdf_filename = os.path.join(folder, 'other', 'bcell9p0.bdf')
        op2_filename = os.path.join(folder, 'other', 'bcell9p0.op2')
        make_geom = False
        write_bdf = False
        write_f06 = True
        debug = False
        op2file = os.path.join(folder, op2_filename)
        bdf = BDF(debug=False)
        bdf.read_bdf(bdf_filename, xref=False)

        debug = False
        debug_file = 'debug.out'
        op2 = OP2(debug=debug, debug_file=debug_file)
        op2.read_op2(op2_filename)
        assert os.path.exists(debug_file), os.listdir('.')

        self._verify_ids(bdf, op2, isubcase=1)

        msg = ''
        for isubcase, keys in sorted(iteritems(op2.subcase_key)):
            if len(keys) != 1:
                msg += 'isubcase=%s keys=%s len(keys) != 1\n' % (isubcase, keys)
                if len(keys) == 0:
                    continue
            if isubcase != keys[0]:
                msg += 'isubcase=%s != key0=%s keys=%s\n' % (isubcase, keys[0], keys)
        if msg:
            assert msg == '', msg
        op2.write_f06('junk.f06')
        os.remove('junk.f06')
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:34,代码来源:op2_unit_tests.py

示例9: test_loads_sum_02

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_loads_sum_02(self):
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'sol_101_elements', 'static_solid_shell_bar.bdf')
        model.read_bdf(bdf_filename)
        loadcase_id = 10000
        #print("keys2", model.loads.keys())

        p0 = array([0., 0., 0.])
        F_expected = array([0., 0., 10000.])
        M_expected = array([5000., -5000., 0.])
        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        loadcase_id = 123458
        p0 = array([0., 0., 0.])
        F_expected = array([0., 0., 10000.])
        M_expected = array([5000., -5000., 0.])
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:33,代码来源:test_sum_loads.py

示例10: remove_unassociated_nodes

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def remove_unassociated_nodes(bdf_filename, bdf_filename_out, renumber=False):
    """
    Removes nodes from a model that are not referenced.

    .. warning only considers elements
    .. renumber=False is not supported
    """
    model = BDF()
    model.read_bdf(bdf_filename, xref=True)

    nids_used = set([])
    for element in itervalues(model.elements):
        nids_used.update(element.node_ids)
    #for element in itervalues(model.masses):
        #nids_used.update(element.node_ids)
    all_nids = set(model.nodes.keys())

    nodes_to_remove = all_nids - nids_used
    for nid in nodes_to_remove:
        del model.nodes[nid]

    if renumber:
        starting_id_dict = {
            'nid' : 1,
            'eid' : 1,
            'pid' : 1,
            'mid' : 1,
        }
        bdf_renumber(model, bdf_filename_out, size=8, is_double=False,
                     starting_id_dict=starting_id_dict)
    else:
        model.write_bdf(bdf_filename_out)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:34,代码来源:dev_utils.py

示例11: test_include_05

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_include_05(self):
        #if PY2:
            #wb = 'wb'
        #else:
            #wb = 'w'

        with codec_open('include5.bdf', 'w') as f:
            f.write('$ pyNastran: punch=True\n')
            f.write('$ pyNastran: dumplines=True\n')
            f.write("INCLUDE 'include5b.inc'\n\n")

        with codec_open('include5b.inc', 'w') as f:
            f.write('ECHOON\n')
            f.write('$ GRID comment\n')
            f.write('GRID,2,,2.0\n')
            f.write('ECHOOFF\n')
            f.write('GRID,3,,3.0\n')
            f.write('grid,4,,4.0\n')
            f.write('grid ,5,,5.0\n')

        model = BDF(log=log, debug=False)
        model.read_bdf('include5.bdf')
        assert model.echo == False, model.echo
        #model.write_bdf('include4.out.bdf')

        os.remove('include5.bdf')
        #os.remove('include5.out.bdf')
        os.remove('include5b.inc')
        # os.remove('c.bdf')
        # os.remove('executive_control.inc')
        # os.remove('case_control.inc')

        self.assertEqual(len(model.nodes), 4)
        self.assertEqual(model.nnodes, 4, 'nnodes=%s' % model.nnodes)
开发者ID:marcinch18,项目名称:pyNastran,代码行数:36,代码来源:test_read_write.py

示例12: run_map_deflections

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
def run_map_deflections(nodeList, bdf_filename, out_filename, cart3d, cart3d2, log=None):
    fbase, ext = os.path.splitext(out_filename)
    if ext == '.op2':
        deflections = read_op2(out_filename)
    elif ext == '.f06':
        deflections = read_f06(out_filename)
    else:
        raise NotImplementedError('out_filename = %r' % out_filename)

    mesh = BDF(debug=True, log=log)
    mesh.read_bdf(bdf_filename, include_dir=None, xref=True, punch=False)

    nodeList = remove_duplicate_nodes(nodeList, mesh)
    C = getCmatrix(nodeList, mesh)
    wS = get_WS(nodeList, deflections)
    del deflections

    aPoints = read_cart3d_points(cart3d)
    wA = get_WA(nodeList, C, wS, mesh, aPoints)
    del C
    #del wS
    del mesh

    write_new_cart3d_mesh(cart3d, cart3d2, wA)
    return (wA,wS)
开发者ID:sukhbinder,项目名称:cyNastran,代码行数:27,代码来源:runSpline.py

示例13: test_case_control_08

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_case_control_08(self):
        lines_expected = [
            '$pyNastran: version=msc\n',
            '$pyNastran: punch=True\n',
            '$pyNastran: encoding=ascii\n',
            '$NODES\n',
            'GRID,100000,,43.91715,-29.,.8712984\n',
        ]
        bdf_filename = 'test7.bdf'
        bdf_filename2 = 'test7_bad.bdf'
        with codec_open(bdf_filename, 'w', encoding='ascii') as f:
            for line in lines_expected:
                f.write(line)
        bdf = BDF()
        bdf.read_bdf(bdf_filename)
        bdf.write_bdf(bdf_filename2)

        with codec_open(bdf_filename, 'r', encoding='ascii') as f:
            lines = f.readlines()
            i = 0
            for line, line_expected in zip(lines, lines_expected):
                line = line.rstrip()
                line_expected = line_expected.rstrip()
                msg = 'The lines are not the same...i=%s\n' % i
                msg += 'line     = %r\n' % line
                msg += 'expected = %r\n' % line_expected
                msg += '-------------\n--Actual--\n%s' % ''.join(lines)
                msg += '-------------\n--Expected--\n%s' % ''.join(lines_expected)
                self.assertEqual(line, line_expected, msg)
                i += 1
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:32,代码来源:test_case_control_deck.py

示例14: test_disable_cards

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
 def test_disable_cards(self):
     bdf_filename = os.path.join(root_path, '..', 'models',
         'solid_bending', 'solid_bending.bdf')
     model = BDF(debug=False)
     model.disable_cards(['CTETRA'])
     model.read_bdf(bdf_filename)
     assert len(model.elements) == 0, len(model.elements)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:9,代码来源:test_read_write.py

示例15: test_include_end_02

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import read_bdf [as 别名]
    def test_include_end_02(self):
        with codec_open('a.bdf', 'w') as f:
            f.write('CEND\n')
            f.write('BEGIN BULK\n')
            f.write('GRID,1,,1.0\n')
            f.write("INCLUDE 'b.bdf'\n\n")
            f.write('GRID,4,,4.0\n')

        with codec_open('b.bdf', 'w') as f:
            f.write('GRID,2,,2.0\n')
            f.write("INCLUDE 'c.bdf'\n\n")
            f.write('GRID,5,,5.0\n')

        with codec_open('c.bdf', 'w') as f:
            f.write('GRID,3,,3.0\n\n')

        model = BDF(log=log, debug=False)
        model.read_bdf('a.bdf')
        model.write_bdf('a.out.bdf')

        os.remove('a.bdf')
        os.remove('b.bdf')
        os.remove('c.bdf')
        os.remove('a.out.bdf')
        self.assertEqual(len(model.nodes), 5)
        self.assertEqual(model.nnodes, 5, 'nnodes=%s' % model.nnodes)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:28,代码来源:test_read_write.py


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