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


Python BDF.write_bdf方法代码示例

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


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

示例1: remove_unassociated_nodes

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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

示例2: process_nastran

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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

示例3: test_include_end

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

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

        with codec_open('c.bdf', 'w') as bdf_file:
            bdf_file.write('GRID,3,,3.0\n\n')
            bdf_file.write("ENDDATA\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), 3)
        self.assertEqual(model.nnodes, 3, 'nnodes=%s' % model.nnodes)
开发者ID:hurlei,项目名称:pyNastran,代码行数:27,代码来源:test_read_write.py

示例4: test_encoding_write

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_encoding_write(self):
        from pyNastran.bdf.bdf import BDF

        mesh = BDF()
        mesh.add_card(['GRID', 100000, 0, 43.91715, -29., .8712984], 'GRID')
        mesh.write_bdf('out.bdf')
        lines_expected = [
            '$pyNastran: version=msc',
            '$pyNastran: punch=False',
            '$pyNastran: encoding=ascii',
            '$NODES',
            'GRID      100000        43.91715    -29..8712984',
        ]
        bdf_filename = 'out.bdf'
        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,代码行数:29,代码来源:test_read_write.py

示例5: test_include_end

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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

示例6: run_model

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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

示例7: test_include_end_02

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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

示例8: test_enddata_2

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_enddata_2(self):
        """
        There is no ENDDATA is in the baseline BDF, so None -> no ENDDATA
        """
        model = BDF(debug=False)
        full_path = os.path.join(test_path, 'include_dir')
        model2 = BDF(debug=False)
        bdf_name = os.path.join(test_path, 'test_mass.dat')
        model2.read_bdf(bdf_name, xref=True, punch=False)
        for out_filename, is_enddata, write_flag in [
            ('test_mass1.dat', False, None),
            ('test_mass2.dat', True, True),
            ('test_mass3.dat', False, False)]:
            model2.write_bdf(out_filename=out_filename, interspersed=True, size=8,
                             is_double=False, enddata=write_flag)

            with codec_open(out_filename, 'r') as f:
                data = f.read()

            msg = 'outfilename=%r expected=%r write_flag=%s card_count=%r' % (out_filename, is_enddata, write_flag, model2.card_count.keys())
            if is_enddata:
                self.assertTrue('ENDDATA' in data, msg)
            else:
                self.assertFalse('ENDDATA' in data, msg)
            os.remove(out_filename)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:27,代码来源:test_read_write.py

示例9: test_deqatn_10

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_deqatn_10(self):
        """
        per nast/tpl/ptdmi1.dat
        """
        model = BDF(debug=None)
        model.cards_to_read.add('DEQATN')
        model.test_deqatn = True
        card = [
            'deqatn  2       f(x,y,z)= 1.;',
            '        L=x+y',
        ]
        model.add_card(card, 'DEQATN', is_list=False)
        model.cross_reference()

        s = StringIO()
        model.write_bdf(s, close=False)
        s.getvalue()
        s.close()
        eq = model.dequations[2]
        x = zeros(10., dtype='float32')
        y = zeros(11., dtype='float32')
        z = zeros(12., dtype='float32')
        #out = eq.func(x, y, z)
        out = eq.func(1.0, 2.0)
        print(out)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:27,代码来源:test_dequatn.py

示例10: test_include_04

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

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

        with codec_open('include4b.inc', 'w') as f:
            f.write('$ GRID comment\n')
            f.write('GRID,2,,2.0\n')

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

        os.remove('include4.out.bdf')
        os.remove('include4b.inc')
        #os.remove('include4.inc')
        # os.remove('c.bdf')
        # os.remove('executive_control.inc')
        # os.remove('case_control.inc')

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

示例11: test_deqatn_9

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_deqatn_9(self):
        """
        per nast/tpl/ptdmi1.dat
        """
        model = BDF(debug=None)
        model.cards_to_read.add('DEQATN')
        model.test_deqatn = True
        card = [
            'deqatn  2       f(x,y,z)= 1.;',
            '        L=1+2+3+',
            '        + 4/min(1,2);',
            '        b= 4.;',
            '        h= 2.;',
            '        t1= 200.;',
            '        t2= 300.;',
            '        t=t1*(L-x)/L+t2*x/L',
            '        +4'
        ]
        model.add_card(card, 'DEQATN', is_list=False)
        model.cross_reference()

        s = StringIO()
        model.write_bdf(s, close=False)
        s.getvalue()
        s.close()
开发者ID:saullocastro,项目名称:pyNastran,代码行数:27,代码来源:test_dequatn.py

示例12: test_enddata_1

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_enddata_1(self):
        """
        There is an ENDDATA is in the baseline BDF, so None -> ENDDATA
        """
        model = BDF(debug=False)
        full_path = os.path.join(test_path, 'include_dir')
        model2 = BDF(debug=False)

        bdf_filename = 'test_include.bdf'
        if not os.path.exists(bdf_filename):
            bdf_filename = os.path.join(test_path, bdf_filename)
        model2.read_bdf(bdf_filename, xref=True, punch=False)
        for out_filename, is_enddata, write_flag in [
            ('enddata1.bdf', True, None),
            ('enddata2.bdf', True, True),
            ('enddata3.bdf', False, False)]:
            out_filename = os.path.join(test_path, out_filename)
            model2.write_bdf(out_filename=out_filename+'.out', interspersed=True, size=8,
                             is_double=False, enddata=write_flag)

            with codec_open(out_filename + '.out', 'r') as f:
                data = f.read()

            if is_enddata:
                self.assertTrue('ENDDATA' in data)
            else:
                self.assertFalse('ENDDATA' in data)
            os.remove(out_filename + '.out')
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:30,代码来源:test_read_write.py

示例13: test_case_control_08

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_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: check_renumber

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
def check_renumber(bdf_filename, bdf_filename_renumber, bdf_filename_check):
    bdf_renumber(bdf_filename, bdf_filename_renumber)

    model = BDF(debug=False)
    model.read_bdf(bdf_filename)
    model.write_bdf(bdf_filename_check, interspersed=False)

    model = BDF(debug=False)
    model.read_bdf(bdf_filename_renumber)
开发者ID:hurlei,项目名称:pyNastran,代码行数:11,代码来源:test_renumber.py

示例15: test_case_control_02

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import write_bdf [as 别名]
    def test_case_control_02(self):
        bdf_filename = os.path.join(test_path, 'unit', 'case_control.dat')
        bdf_filename2 = os.path.join(test_path, 'unit', 'case_control_out.dat')

        mesh = BDF(debug=False, log=None)
        mesh.read_bdf(bdf_filename, xref=True)
        str(mesh.case_control_deck)

        mesh.case_control_deck.create_new_subcase(1)

        #with self.assertRaises(AssertionError):
        str(mesh.case_control_deck)
        subcase1 = mesh.case_control_deck.subcases[1]
        str(subcase1)

        mesh.case_control_deck.add_parameter_to_local_subcase(1, 'LOAD=1')
        str(mesh.case_control_deck)

        mesh.case_control_deck.create_new_subcase(2)
        mesh.case_control_deck.add_parameter_to_local_subcase(2, 'LOAD=2')
        mesh.write_bdf(bdf_filename2)
        #print("---cc 3---\n%s" % str(mesh.case_control_deck))

        f = open(bdf_filename2, 'r')
        lines = f.readlines()
        f.close()

        lines_expected = [
            '$pyNastran: version=msc',
            '$pyNastran: punch=False',
            '$pyNastran: encoding=ascii' if PY2 else '$pyNastran: encoding=utf-8',
            '$pyNastran: nnodes=1',
            '$pyNastran: nelements=0',
            '$EXECUTIVE CONTROL DECK',
            'SOL 101',
            'CEND',
            '$CASE CONTROL DECK',
            'TITLE = STATIC',
            'SUBCASE 1',
            '    LOAD = 1',
            'SUBCASE 2',
            '    LOAD = 2',
            'BEGIN BULK',
            '$PARAMS',
            'PARAM    AUTOSPC     YES',
            'PARAM     NOFISR       0',
            '$NODES',
            'GRID           1              0.      0.      0.',
            'ENDDATA',
        ]
        for line, line_expected in zip(lines, lines_expected):
            line = line.rstrip()
            msg = 'The lines are not the same...\n'
            msg += 'line     = %r\n' % line
            msg += 'expected = %r' % line_expected
            self.assertEqual(line, line_expected, msg)
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:58,代码来源:test_case_control_deck.py


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