def test_aero_02(self): """checks 0012_flutter.bdf""" bdf_filename = os.path.join(MODEL_PATH, 'aero', '2_mode_flutter', '0012_flutter.bdf') #log = get_logger(log=None, level='error', encoding='utf-8') argv = ['test_bdf', bdf_filename, '-q'] test_bdf(argv=argv)
def save_load_deck(model, xref='standard', punch=True, run_remove_unused=True, run_convert=True, run_renumber=True, run_mirror=True, run_save_load=True, run_quality=True, write_saves=True, run_save_load_hdf5=True, run_mass_properties=True, run_loads=True, run_test_bdf=True, run_op2_writer=True, run_op2_reader=True, op2_log_level: str = 'warning'): """writes, re-reads, saves an obj, loads an obj, and returns the deck""" if os.path.exists('junk.bdf'): os.remove('junk.bdf') model.set_error_storage(nparse_errors=0, stop_on_parsing_error=True, nxref_errors=0, stop_on_xref_error=True) model.validate() model.pop_parse_errors() model.pop_xref_errors() bdf_file = StringIO() model.write_bdf(bdf_file, size=8, close=False) bdf_file.seek(0) model.write_bdf(bdf_file, size=16, close=False) bdf_file.seek(0) model.write_bdf(bdf_file, size=16, is_double=True, close=False) bdf_file.seek(0) if write_saves and model.save_file_structure: bdf_filenames = { 0: 'junk.bdf', } model.write_bdfs(bdf_filenames) os.remove('junk.bdf') if run_convert: units_to = ['m', 'kg', 's'] units = ['ft', 'lbm', 's'] convert(model, units_to, units) model2 = BDF(log=model.log) #print(bdf_file.getvalue()) model2.read_bdf(bdf_file, punch=punch, xref=False) _cross_reference(model2, xref) model2.pop_parse_errors() model2.get_bdf_stats() model2.write_bdf('model2.bdf') if run_test_bdf: folder = '' log_error = get_logger(log=None, level='error', encoding='utf-8') test_bdf(folder, 'model2.bdf', stop_on_failure=True, punch=punch, quiet=True, log=log_error) os.remove('model2.test_bdf.bdf') nelements = len(model2.elements) + len(model2.masses) nnodes = len(model2.nodes) + len(model2.spoints) + len(model2.epoints) _run_mass_properties(model2, nnodes, nelements, run_mass_properties=run_mass_properties) _run_loads(model2, nelements, run_loads=run_loads) if run_save_load: model2.save(obj_filename='model.obj', unxref=True) model3 = BDF(debug=False, log=model.log, mode='msc') model3.load(obj_filename='model.obj') os.remove('model.obj') else: model2.uncross_reference() model3 = model2 _run_hdf5(model2, model.log, run_save_load_hdf5=run_save_load_hdf5) cross_reference(model3, xref) if run_renumber: renumber('model2.bdf', model.log) if run_mirror: # we put this under renumber to prevent modifying an # existing model to prevent breaking tests # # shouldn't have any effect model2.bdf model_mirrored = bdf_mirror('model2.bdf', plane='xz', log=model.log)[0] model_mirrored.write_bdf('mirrored2.bdf') read_bdf('mirrored2.bdf', log=model.log) os.remove('mirrored2.bdf') os.remove('model2.bdf') if model.elements and run_quality: element_quality(model) if run_op2_writer: op2_geom_model = attach_op2_results_to_bdf(model, op2_model=None) from pyNastran.op2.op2_geom import read_op2_geom table_name = 'OUGV1' node_gridtype = np.zeros((10, 2), dtype='int32') node_gridtype[:, 0] = np.arange(1, 11) data = np.zeros((1, 10, 6), dtype='float32') isubcase = 1 disp = RealDisplacementArray.add_static_case(table_name, node_gridtype, data, isubcase, is_sort1=True) op2_geom_model.displacements[isubcase] = disp op2_filename = 'spike.op2' bkp_log = op2_geom_model.log op2_geom_model.log = get_logger(log=None, level=op2_log_level, encoding='utf-8') op2_geom_model.write_op2(op2_filename, post=-1, endian=b'<', skips=None, nastran_format='nx') if run_op2_reader: unused_op2_geom = read_op2_geom(op2_filename, log=op2_geom_model.log, xref=False) else: frame = inspect.currentframe() call_frame = inspect.getouterframes(frame, 2) op2_geom_model.log.warning('skipping op2 reader for %s' % call_frame[1][3]) op2_geom_model.log = bkp_log os.remove(op2_filename) if run_remove_unused: remove_unused(model) return model3