Beispiel #1
0
    def test_nastran_to_tecplot(self):
        """tests a large number of elements and results in SOL 101"""
        bdf_filename = os.path.join(MODEL_PATH, 'elements', 'static_elements.bdf')
        tecplot_filename = os.path.join(MODEL_PATH, 'elements', 'static_elements.plt')
        tecplot_filename2 = os.path.join(MODEL_PATH, 'elements', 'static_elements2.plt')
        log = get_logger(log=None, level='warning', encoding='utf-8')
        model = read_bdf(bdf_filename, log=log)
        with self.assertRaises(RuntimeError):
            nastran_to_tecplot(model)
        nastran_to_tecplot_filename(bdf_filename, tecplot_filename, log=log)

        argv = ['format_converter', 'nastran', bdf_filename, 'tecplot', tecplot_filename2]
        with self.assertRaises(RuntimeError):
            cmd_line_format_converter(argv=argv, quiet=True)
Beispiel #2
0
    def test_tecplot_02(self):
        """CTETRA10 elements"""
        log = SimpleLogger(level='warning')
        nastran_filename1 = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                         'solid_bending.bdf')
        nastran_filename2 = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                         'solid_bending2.bdf')
        tecplot_filename = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                        'solid_bending.plt')
        tecplot_filename2 = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                         'solid_bending2.plt')
        unused_tecplot = nastran_to_tecplot_filename(nastran_filename1,
                                                     tecplot_filename,
                                                     log=log)
        #tecplot.write_tecplot(tecplot_filename)
        tecplot_to_nastran_filename(tecplot_filename,
                                    nastran_filename2,
                                    log=log)
        #os.remove(nastran_filename2)
        #os.remove(tecplot_filename)

        bdf_model = read_bdf(nastran_filename1, log=log)
        unused_tecplot = nastran_to_tecplot(bdf_model)

        argv = [
            'format_converter', 'tecplot', tecplot_filename, 'tecplot',
            tecplot_filename2
        ]
        cmd_line_format_converter(argv=argv, quiet=True)
Beispiel #3
0
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)
Beispiel #4
0
    def test_tecplot_03(self):
        log = SimpleLogger(level='warning')
        nastran_filename = os.path.join(NASTRAN_MODEL_PATH, 'elements',
                                        'static_elements.bdf')
        tecplot_filename = os.path.join(NASTRAN_MODEL_PATH, 'elements',
                                        'static_elements.plt')
        unused_tecplot = nastran_to_tecplot_filename(nastran_filename,
                                                     tecplot_filename,
                                                     log=log)
        #tecplot2 = read_tecplot(tecplot_filename)

        bdf_model = read_bdf(nastran_filename, log=log)
        with self.assertRaises(RuntimeError):
            unused_tecplot = nastran_to_tecplot(bdf_model)
Beispiel #5
0
def process_nastran(bdf_filename,
                    fmt2,
                    fname2,
                    log,
                    data=None,
                    debug=True,
                    quiet=False):
    """
    Converts Nastran to STL/Cart3d/Tecplot/UGRID3d
    """
    assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid', 'nastran',
                    'abaqus'], 'format2=%s' % fmt2
    from pyNastran.bdf.bdf import BDF
    xref = True
    if fmt2 == 'ugrid':
        xref = False
    model = BDF(log=log, debug=debug)
    model.read_bdf(bdf_filename, validate=False, xref=xref)

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

    if fmt2 == 'stl':
        from pyNastran.converters.nastran.nastran_to_stl import nastran_to_stl
        nastran_to_stl(model, fname2, is_binary=data['--binary'])
    elif fmt2 == 'cart3d':
        from pyNastran.converters.nastran.nastran_to_cart3d import nastran_to_cart3d
        cart3d = nastran_to_cart3d(model)
        cart3d.write_cart3d(fname2)
    elif fmt2 == 'tecplot':
        from pyNastran.converters.nastran.nastran_to_tecplot import nastran_to_tecplot
        tecplot = nastran_to_tecplot(model)
        tecplot_filename = fname2
        tecplot.write_tecplot(tecplot_filename, adjust_nids=False)
    elif fmt2 == 'ugrid':
        from pyNastran.converters.nastran.nastran_to_ugrid import nastran_to_ugrid
        nastran_to_ugrid(model, fname2)
    elif fmt2 == 'abaqus':
        from pyNastran.converters.nastran.nastran_to_abaqus import nastran_to_abaqus
        nastran_to_abaqus(model, fname2)
    elif fmt2 == 'nastran':
        model.write_bdf(fname2, size=16)
    else:
        raise NotImplementedError(
            'fmt2=%s is not supported by process_nastran' % fmt2)
Beispiel #6
0
    def test_tecplot_02(self):
        log = get_logger(level='warning')
        nastran_filename1 = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                         'solid_bending.bdf')
        nastran_filename2 = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                         'solid_bending2.bdf')
        tecplot_filename = os.path.join(NASTRAN_MODEL_PATH, 'solid_bending',
                                        'solid_bending.plt')
        tecplot = nastran_to_tecplot_filename(nastran_filename1,
                                              tecplot_filename,
                                              log=log)
        #tecplot.write_tecplot(tecplot_filename)
        tecplot_to_nastran_filename(tecplot_filename,
                                    nastran_filename2,
                                    log=log)
        #os.remove(nastran_filename2)
        #os.remove(tecplot_filename)

        bdf_model = read_bdf(nastran_filename1, log=log)
        unused_tecplot = nastran_to_tecplot(bdf_model)
Beispiel #7
0
def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True):
    """
    Converts Nastran to STL/Cart3d/Tecplot
    """
    assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid'], 'format2=%s' % fmt2
    xref = True
    if fmt2 == 'ugrid':
        xref = False
    model = BDF(debug=debug)
    model.read_bdf(bdf_filename, xref=xref)

    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)
    else:
        raise NotImplementedError(fmt2)
Beispiel #8
0
def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True):
    """
    Converts Nastran to STL/Cart3d/Tecplot/UGRID3d
    """
    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':
        nastran_to_ugrid(model, fname2)
    elif fmt2 == 'nastran':
        model.write_bdf(fname2, size=16)
    else:
        raise NotImplementedError(fmt2)