def test_nastran_to_ugrid_01(self): bdf_filename = os.path.join(model_path, "solid_bending", "solid_bending.bdf") size = 8 debug = True model = read_bdf(bdf_filename, log=None, debug=debug) log = model.log # model.skin_solid_elements() skin_bdf_filename = os.path.join(model_path, "solid_bending", "solid_skin.bdf") model.write_skin_solid_faces( skin_bdf_filename, write_solids=True, write_shells=True, size=size, is_double=False, encoding=None ) bdf_model = read_bdf(skin_bdf_filename, log=log, debug=debug) ugrid_filename_out = os.path.join(model_path, "solid_bending", "solid_skin.b8.ugrid") nastran_to_ugrid(bdf_model, ugrid_filename_out, properties=None, check_shells=True, check_solids=True) ugrid = read_ugrid(ugrid_filename_out, encoding=None, log=log, debug=debug) skin_bdf_filename2 = os.path.join(model_path, "solid_bending", "solid_skin2.bdf") ugrid.write_bdf( skin_bdf_filename2, include_shells=True, include_solids=True, convert_pyram_to_penta=True, encoding=None, size=size, is_double=False, ) model2 = read_bdf(skin_bdf_filename2, log=log, debug=debug) os.remove(ugrid_filename_out) os.remove(skin_bdf_filename) os.remove(skin_bdf_filename2)
def test_ugrid_01(self): """tests solid_bending.bdf""" nastran_filename1 = os.path.join(nastran_path, 'solid_bending', 'solid_bending.bdf') ugrid_filename = os.path.join(nastran_path, 'solid_bending', 'solid_bending.b8.ugrid') nastran_to_ugrid(nastran_filename1, ugrid_filename_out=ugrid_filename, properties=None, check_shells=False, check_solids=True) assert os.path.exists(ugrid_filename), ugrid_filename nastran_filename2 = os.path.join(nastran_path, 'solid_bending', 'solid_bending2.bdf') model = ugrid3d_to_nastran(ugrid_filename, nastran_filename2, include_shells=True, include_solids=True, convert_pyram_to_penta=False, encoding=None, size=16, is_double=False) assert os.path.exists(nastran_filename2), nastran_filename2 #tecplot_filename1 = os.path.join(nastran_path, 'solid_bending', 'solid_bending.plt') #ugrid3d_to_tecplot_filename(model, tecplot_filename1) #assert os.path.exists(tecplot_filename1), tecplot_filename1 tecplot_filename2 = os.path.join(nastran_path, 'solid_bending', 'solid_bending2.plt') tecplot = ugrid_to_tecplot(model) tecplot.write_tecplot(tecplot_filename2, res_types=None, is_points=True, adjust_nids=True) assert os.path.exists(tecplot_filename2), tecplot_filename2
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)
def test_ugrid_gui_02(self): """tests solid_bending.bdf""" nastran_filename1 = os.path.join(nastran_path, 'solid_bending', 'solid_bending.bdf') from pyNastran.bdf.mesh_utils.extract_free_faces import write_skin_solid_faces skin_filename = os.path.join(nastran_path, 'solid_bending', 'solid_bending_skin.bdf') write_skin_solid_faces(nastran_filename1, skin_filename, write_solids=True, write_shells=True, size=8, is_double=False, encoding=None, punch=False) ugrid_filename = os.path.join(nastran_path, 'solid_bending', 'solid_bending.b8.ugrid') nastran_to_ugrid(skin_filename, ugrid_filename_out=ugrid_filename, properties=None, check_shells=True, check_solids=True) assert os.path.exists(ugrid_filename), ugrid_filename test = UGRID_GUI() dirname = None test.load_ugrid_geometry(ugrid_filename, dirname, name='main', plot=True)
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 test_nastran_to_ugrid_01(self): bdf_filename = os.path.join(MODEL_PATH, 'solid_bending', 'solid_bending.bdf') size = 8 debug = False log = SimpleLogger(level='warning', encoding='utf-8') model = read_bdf(bdf_filename, log=log, debug=debug) #log = model.log #model.get_element_faces() skin_bdf_filename = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin.bdf') write_skin_solid_faces(model, skin_bdf_filename, write_solids=True, write_shells=True, size=size, is_double=False, encoding=None) bdf_model = read_bdf(skin_bdf_filename, log=log, debug=debug) ugrid_filename_out = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin.b8.ugrid') ugrid_filename_out2 = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin2.b8.ugrid') nastran_to_ugrid(bdf_model, ugrid_filename_out, properties=None, check_shells=True, check_solids=True) ugrid = read_ugrid(ugrid_filename_out, encoding=None, log=log, debug=debug) skin_bdf_filename2 = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin2.bdf') skin_cart3d_filename = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin2.tri') skin_cart3d_filename3 = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin3.tri') skin_stl_filename3 = os.path.join(MODEL_PATH, 'solid_bending', 'solid_skin3.stl') #msg += " format_converter nastran <INPUT> <format2> <OUTPUT> [-o <OP2>] --no_xref\n" #msg += " format_converter <format1> <INPUT> tecplot <OUTPUT> [-r RESTYPE...] [-b] [--block] [-x <X>] [-y <Y>] [-z <Z>] [--scale SCALE]\n" #msg += " format_converter <format1> <INPUT> stl <OUTPUT> [-b] [--scale SCALE]\n" #msg += " format_converter cart3d <INPUT> <format2> <OUTPUT> [-b] [--scale SCALE]\n" #msg += " format_converter <format1> <INPUT> <format2> <OUTPUT> [--scale SCALE]\n" argv = [ 'format_converter', 'nastran', bdf_filename, 'ugrid', ugrid_filename_out2 ] with self.assertRaises(RuntimeError): cmd_line_format_converter(argv=argv, quiet=True) #argv = ['format_converter', 'nastran', bdf_filename, 'cart3d', skin_cart3d_filename3] #cmd_line_format_converter(argv=argv) #argv = ['format_converter', 'nastran', bdf_filename, 'stl', skin_stl_filename3] #cmd_line_format_converter(argv=argv) ugrid.write_bdf(skin_bdf_filename2, include_shells=True, include_solids=True, convert_pyram_to_penta=True, encoding=None, size=size, is_double=False) read_bdf(skin_bdf_filename2, log=log, debug=debug) with self.assertRaises(AssertionError): nastran_to_cart3d_filename(skin_bdf_filename2, skin_cart3d_filename) ugrid.write_bdf(skin_bdf_filename2, include_shells=True, include_solids=False, convert_pyram_to_penta=True, encoding=None, size=size, is_double=False) nastran_to_cart3d_filename(skin_bdf_filename2, skin_cart3d_filename) read_cart3d(skin_cart3d_filename, log=log) os.remove(ugrid_filename_out) os.remove(skin_bdf_filename) os.remove(skin_bdf_filename2) os.remove(skin_cart3d_filename)
def test_ugrid_01(self): """tests solid_bending.bdf""" nastran_filename1 = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending.bdf') ugrid_filename = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending.b8.ugrid') log = get_logger(level='warning') unused_ugrid_model = nastran_to_ugrid( nastran_filename1, ugrid_filename_out=ugrid_filename, properties=None, check_shells=False, check_solids=True, log=log) assert os.path.exists(ugrid_filename), ugrid_filename nastran_filename2 = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending2.bdf') ugrid_model = ugrid3d_to_nastran(ugrid_filename, nastran_filename2, include_shells=True, include_solids=True, convert_pyram_to_penta=False, encoding=None, size=16, is_double=False, log=log) nastran_filename3 = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending3.bdf') tris, quads = ugrid_model.skin_solids() ugrid_model.tris = tris ugrid_model.quads = quads ugrid_model.pids = np.ones(len(tris) + len(quads)) ugrid_model.write_bdf(nastran_filename3) bdf_model = read_bdf(nastran_filename3) #print(bdf_model.get_bdf_stats()) assert os.path.exists(nastran_filename3), nastran_filename3 #tecplot_filename1 = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending.plt') #ugrid3d_to_tecplot_filename(model, tecplot_filename1) #assert os.path.exists(tecplot_filename1), tecplot_filename1 tecplot_filename2 = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending2.plt') tecplot = ugrid_to_tecplot(ugrid_model) tecplot.write_tecplot(tecplot_filename2, res_types=None, adjust_nids=True) assert os.path.exists(tecplot_filename2), tecplot_filename2 ugrid_filename_out = os.path.join(NASTRAN_PATH, 'solid_bending', 'solid_bending.b8.ugrid_out') pshell_pids_to_remove = [] merge_ugrid3d_and_bdf_to_ugrid3d_filename(ugrid_filename, nastran_filename3, ugrid_filename_out, pshell_pids_to_remove, update_equivalence=True, tol=0.01) assert os.path.exists(ugrid_filename_out), ugrid_filename_out