def test_nastran_to_cart3d_03(self): log = get_logger(level='warning', encoding='utf-8') lines = ('SOL 101\n' 'CEND\n' 'BEGIN BULK\n' 'GRID,1,,1.0,0.,0.\n' 'GRID,52,, 0., 0., 0.\n' 'GRID,2 ,, 1., 0., 0.\n' 'GRID,19,, 1., 1., 0.\n' 'GRID,20,, 1., 0., 0.\n' 'CTRIA3,10,100,1,2,19\n' 'CQUAD4,11,100,52,2,19,20\n' 'PSHELL,100,1000,0.1\n' 'MAT1,1000,3.0e7,,0.3\n' 'ENDDATA\n') bdf_filename = os.path.join(model_path, 'test03.bdf') cart3d_filename = os.path.join(model_path, 'test03.tri') #cart3d_filename_out = os.path.join(model_path, 'test03_out.tri') with open(bdf_filename, 'w') as bdf_file: bdf_file.write(lines) bdf = BDF(log=log, debug=False) bdf.read_bdf(bdf_filename) cart3d = nastran_to_cart3d(bdf, log=log) cart3d.write_cart3d(cart3d_filename) #model = Cart3D() #model.read_cart3d(cart3d_filename) #model.write_cart3d(cart3d_filename_out) #test = Cart3dGUI() #test.load_cart3d_geometry(cart3d_filename) os.remove(bdf_filename) os.remove(cart3d_filename)
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)
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)
def test_nastran_to_cart3d_02(self): lines = ('SOL 101\n' 'CEND\n' 'BEGIN BULK\n' 'GRID,52,,1.0,0.,0.\n' 'GRID,2,,1.0,1.,0.\n' 'GRID,19,,0.0,1.,0.\n' 'CTRIA3,10,100,52,2,19\n' 'PSHELL,100,1000,0.1\n' 'MAT1,1000,3.0e7,,0.3\n' 'ENDDATA\n') bdf_filename = os.path.join(model_path, 'test03.bdf') cart3d_filename = os.path.join(model_path, 'test03.tri') cart3d_filename_out = os.path.join(model_path, 'test03_out.tri') with open(bdf_filename, 'w') as f: f.write(lines) bdf = BDF(debug=False) bdf.read_bdf(bdf_filename) cart3d = nastran_to_cart3d(bdf) cart3d.write_cart3d(cart3d_filename)
def test_nastran_to_cart3d_02(self): lines = ( 'SOL 101\n' 'CEND\n' 'BEGIN BULK\n' 'GRID,52,,1.0,0.,0.\n' 'GRID,2,,1.0,1.,0.\n' 'GRID,19,,0.0,1.,0.\n' 'CTRIA3,10,100,52,2,19\n' 'PSHELL,100,1000,0.1\n' 'MAT1,1000,3.0e7,,0.3\n' 'ENDDATA\n' ) bdf_filename = os.path.join(model_path, 'test03.bdf') cart3d_filename = os.path.join(model_path, 'test03.tri') cart3d_filename_out = os.path.join(model_path, 'test03_out.tri') with open(bdf_filename, 'w') as f: f.write(lines) bdf = BDF(debug=False) bdf.read_bdf(bdf_filename) cart3d = nastran_to_cart3d(bdf) cart3d.write_cart3d(cart3d_filename)
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)
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)