def process(self, r): scene_desc = copy.deepcopy(r.model.SceneDesc) scene_desc['plotdir'] = os.path.join(r.model.get_calculation_directory(), scene_desc['plotdir']) print("Output directory: " + scene_desc['plotdir']) r.model.Simulation.simulation_scene_desc = scene_desc r.model.Simulation.simulation_result_path = scene_desc['plotdir'] result = False def status_messages(status): nonlocal result nonlocal self self.change_status_text(status['message']) if status['status'] == 'error': result = False raise Simulate.PstdException(status) elif status['status'] == 'starting': self.pstd_meshdata = status['pstd_desc'] r.model.Simulation.simulation_result_pstd_mesh = status['pstd_desc'] elif status['status'] == 'running': r.model.Simulation.update_frame_info() elif status['status'] == 'success': result = True try: pstd = PSTD(False, self.create_plots, self.create_array, scene_desc, status_messages) pstd.run() except Simulate.PstdException as e: pass return result
# Use binary mode IO in Python 3+ if not stand_alone: if hasattr(sys.stdin, 'detach'): sys.stdin = sys.stdin.detach() if hasattr(sys.stdout, 'detach'): sys.stdout = sys.stdout.detach() if stand_alone: if args.scene_file: f = open(args.scene_file, 'r') scene_desc = json.load(f) f.close() else: output_error("Specify scene file", output_function) exit(1) else: scene_desc = pickle.load(sys.stdin) pstd = PSTD(args.multi_threaded, args.write_plot, args.write_array, scene_desc, output_function) out = sys.__stdout__ if args.file: print("Writing to %s"%args.file) out = open(args.file,'w') out.write("openPSTD --- %s\n"%datetime.now().strftime('%d-%m-%y %H:%M')) out.write("Profile output\n" "Scene file %s\n" "Parallel: %s\n" "Plotting: %s\n" "Writing arrays: %s\n\n"%(args.scene_file,args.multi_threaded,args.write_plot,args.write_array)) time_start = time.time() yappi.start() pstd.run() yappi.stop() time_passed = time.time() - time_start