def test_ugrid3d_gui_box(self): """simple UGRID3D box model""" ugrid_filename = os.path.join(UGRID_PATH, 'box.b8.ugrid') log = get_logger(level='warning') tecplot_filename2 = os.path.join(UGRID_PATH, 'box.plt') ugrid_model = read_ugrid(ugrid_filename, log=log) tecplot = ugrid3d_to_tecplot_filename(ugrid_filename, tecplot_filename2) tecplot = ugrid_to_tecplot(ugrid_filename) tecplot = ugrid_to_tecplot(ugrid_model) tecplot.write_tecplot(tecplot_filename2, res_types=None, is_points=True, adjust_nids=True) assert os.path.exists(tecplot_filename2), tecplot_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') 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) argv = ['format_converter', 'ugrid', ugrid_filename, 'nastran', 'shell_solid_bending.bdf'] cmd_line_format_converter(argv=argv, quiet=True) 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) unused_bdf_model = read_bdf(nastran_filename3, log=log) #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, unused_zone = ugrid_to_tecplot(ugrid_model, log=log) 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, log=log) assert os.path.exists(ugrid_filename_out), ugrid_filename_out os.remove(nastran_filename2) os.remove(nastran_filename3) os.remove(tecplot_filename2) os.remove(ugrid_filename) os.remove(ugrid_filename_out) os.remove('shell_solid_bending.bdf')
def test_ugrid3d_gui_box(self): """simple UGRID3D box model""" ugrid_filename = os.path.join(UGRID_PATH, 'box.b8.ugrid') log = get_logger(level='warning') tecplot_filename2 = os.path.join(UGRID_PATH, 'box.plt') tecplot_filename3 = os.path.join(UGRID_PATH, 'slice.plt') ugrid_model = read_ugrid(ugrid_filename, log=log) tecplot = ugrid3d_to_tecplot_filename(ugrid_filename, tecplot_filename2, log=log) tecplot, unused_zone = ugrid_to_tecplot(ugrid_filename, log=log) tecplot, unused_zone = ugrid_to_tecplot(ugrid_model, log=log) tecplot.write_tecplot(tecplot_filename2, res_types=None, adjust_nids=True) assert os.path.exists(tecplot_filename2), tecplot_filename2 argv = ['format_converter', 'ugrid', ugrid_filename, 'tecplot', tecplot_filename3, '-z 0.0'] cmd_line_format_converter(argv=argv, quiet=True) os.remove(tecplot_filename2) os.remove(tecplot_filename3)
def process_ugrid(ugrid_filename, fmt2, fname2, log, data=None, quiet=False): """ Converts UGRID to Nastran/Cart3d/STL/Tecplot """ assert fmt2 in ['stl', 'nastran', 'cart3d', 'tecplot'], 'format2=%s' % fmt2 read_shells = True read_solids = True if fmt2 in ['stl', 'cart3d']: read_shells = True read_solids = False from pyNastran.converters.aflr.ugrid.ugrid_reader import UGRID model = UGRID(read_shells=read_shells, read_solids=read_solids, log=log) model.read_ugrid(ugrid_filename) if fmt2 == 'nastran': # ugrid_to_nastran(model, fname2 include_shells = True include_solids = True bdf_filename = fname2 model.write_bdf(bdf_filename, include_shells=include_shells, include_solids=include_solids) elif fmt2 == 'cart3d': include_shells = True include_solids = False bdf_filename = fname2 + '.bdf' model.write_bdf(bdf_filename, include_shells=include_shells, include_solids=include_solids) # ugrid_to_cart3d(model, fname2) process_nastran(bdf_filename, 'cart3d', fname2, data=None) elif fmt2 == 'stl': include_shells = True include_solids = False bdf_filename = fname2 + '.bdf' model.write_bdf(bdf_filename, include_shells=include_shells, include_solids=include_solids) process_nastran(bdf_filename, 'cart3d', fname2, data=None) # ugrid_to_stl(model, fname2) elif fmt2 == 'tecplot': from pyNastran.converters.aflr.ugrid.ugrid3d_to_tecplot import ugrid_to_tecplot # ugrid_to_tecplot(model, fname2) tecplot, unused_zone = ugrid_to_tecplot(model) element_slice(tecplot, data) tecplot_filename = fname2 tecplot.write_tecplot(tecplot_filename) else: raise NotImplementedError('fmt2=%s is not supported by process_ugrid' % fmt2)
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') 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') 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) model.skin_solids() 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