示例#1
0
    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
            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
    out.write("Time passed: %.3f\n"%time_passed)
    funcstats = yappi.get_func_stats()
    funcstats.sort(sort_type='tsub', sort_order="desc")
    funcstats.print_all(out=out,columns={0:("name",36), 1:("ncall", 8), 2:("tsub", 8), 3:("ttot", 8), 4:("tavg",8)})
    yappi.get_thread_stats().print_all(out=out)
    if args.file:
        out.close()
    exit()
# yappi.start()
# foo()