def set_solver(self, solver): """Set the application's solver. This will call the solver's `setup_integrator` method. The following solver options are set: dt -- the time step for the solver tf -- the final time for the simulationl fname -- the file name for output file printing freq -- the output print frequency level -- the output detail level dir -- the output directory hks -- Hernquist and Katz kernel correction eps -- the xsph correction factor with_cl -- OpenCL related initializations """ self._solver = solver dt = self.options.time_step if dt is not None: solver.set_time_step(dt) tf = self.options.final_time if tf is not None: solver.set_final_time(tf) #setup the solver output file name fname = self.options.output if HAS_MPI: comm = self.comm rank = self.rank if not self.num_procs == 0: fname += '_' + str(rank) # output file name solver.set_output_fname(fname) # output print frequency solver.set_print_freq(self.options.freq) # output printing level (default is not detailed) solver.set_output_printing_level(self.options.detailed_output) # output directory solver.set_output_directory(self.options.output_dir) # Hernquist and Katz kernel correction solver.set_kernel_correction(self.options.kernel_correction) # XSPH operation if self.options.eps: solver.set_xsph(self.options.eps) # OpenCL setup for the solver solver.set_cl(self.options.with_cl) solver.setup_integrator(self.particles) # add solver interfaces self.command_manager = CommandManager(solver, self.comm) solver.set_command_handler(self.command_manager.execute_commands) if comm.Get_rank() == 0: # commandline interface if self.options.cmd_line: from pysph.solver.solver_interfaces import CommandlineInterface self.command_manager.add_interface(CommandlineInterface().start) # XML-RPC interface if self.options.xml_rpc: from pysph.solver.solver_interfaces import XMLRPCInterface addr = self.options.xml_rpc idx = addr.find(':') host = "0.0.0.0" if idx == -1 else addr[:idx] port = int(addr[idx+1:]) self.command_manager.add_interface(XMLRPCInterface((host,port)).start) # python MultiProcessing interface if self.options.multiproc: from pysph.solver.solver_interfaces import MultiprocessingInterface addr = self.options.multiproc idx = addr.find('@') authkey = "pysph" if idx == -1 else addr[:idx] addr = addr[idx+1:] idx = addr.find(':') host = "0.0.0.0" if idx == -1 else addr[:idx] port = int(addr[idx+1:]) self.command_manager.add_interface(MultiprocessingInterface( (host,port), authkey=authkey).start)