Module application

class pysph.solver.application.Application(fname=None, domain=None)[source]

Bases: object

Class used by any SPH application.

Constructor

Parameters:
  • fname (str) – file name to use for the output files.
  • domain (pysph.nnps.DomainManager) – A domain manager to use. This is used for periodic domains etc.
add_tool(tool)[source]

Add a Tool instance to the application.

add_user_options(group)[source]

Add any user-defined options to the given option group.

Note

This uses the argparse module.

configure_scheme()[source]

This is called after consume_user_options is called. One can configure the SPH scheme here as at this point all the command line options are known.

consume_user_options()[source]

This is called right after the command line arguments are parsed.

All the parsed options are available in self.options and can be used in this method.

This is meant to be overridden by users to setup any internal variables etc. that depend on the command line arguments passed. Note that this method is called well before the solver or particles are created.

create_domain()[source]

Create a pysph.nnps.DomainManager and return it if needed.

This is used for periodic domains etc. Note that if the domain is passed to __init__, then this method is not called.

create_equations()[source]

Create the equations to be used and return them.

create_inlet_outlet(particle_arrays)[source]

Create inlet and outlet objects and return them as a list.

The method is passed a dictionary of particle arrays keyed on the name of the particle array.

create_nnps()[source]

Create any NNPS if desired and return it, else a default NNPS will be created automatically.

create_particles()[source]

Create particle arrays and return a list of them.

create_scheme()[source]

Create a suitable SPH scheme and return it.

Note that this method is called after the arguments are all processed and after consume_user_options is called.

create_solver()[source]

Create the solver and return it.

create_tools()[source]

Create any tools and return a sequence of them. This method is called after particles/inlets etc. are all setup, configured etc.

dump_code(file)[source]

Dump the generated code to given file.

initialize()[source]

Called on the constructor, set constants etc. up here if needed.

post_process(info_fname_or_directory)[source]

Given an info filename or a directory containing the info file, read the information and do any post-processing of the results. Please overload the method to perform any processing.

The info file has a few useful attributes and can be read using the read_info method.

The output_files property should provide the output files generated.

post_stage(current_time, dt, stage)[source]

If overloaded, this is called automatically after each integrator stage, i.e. if the integrator is a two stage integrator it will be called after the first and second stages.

The method is passed (current_time, dt, stage). See the the Integrator.one_timestep methods for examples of how this is called.

post_step(solver)[source]

If overloaded, this is called automatically after each integrator step. The method is passed the solver instance.

pre_step(solver)[source]

If overloaded, this is called automatically before each integrator step. The method is passed the solver instance.

read_info(fname_or_dir)[source]

Read the information from the given info file (or directory containing the info file, the first found info file will be used).

run(argv=None)[source]

Run the application.

setup(solver, equations, nnps=None, inlet_outlet_factory=None, particle_factory=None, *args, **kwargs)[source]

Setup the application’s solver.

This will parse the command line arguments (if this is not called from within an IPython notebook or shell) and then using those parameters and any additional parameters and call the solver’s setup method.

Parameters:
  • solver (pysph.solver.solver.Solver) – The solver instance.
  • equations (list) – A list of Groups/Equations.
  • nnps (pysph.base.nnps.NNPS) – Optional NNPS instance. If None is given a default NNPS is created.
  • inlet_outlet_factory (callable or None) – The inlet_outlet_factory is passed a dictionary of the particle arrays. The factory should return a list of inlets and outlets.
  • particle_factory (callable or None) – If supplied, particles will be created for the solver using the particle arrays returned by the callable. Else particles for the solver need to be set before calling this method
  • args – extra positional arguments passed on to the particle_factory.
  • kwargs – extra keyword arguments passed to the particle_factory.

Examples

>>> def create_particles():
...    ...
...
>>> solver = Solver(...)
>>> equations = [...]
>>> app = Application()
>>> app.setup(solver=solver, equations=equations,
...           particle_factory=create_particles)
>>> app.run()
pysph.solver.application.is_overloaded_method(method)[source]

Returns True if the given method is overloaded from any of its bases.

pysph.solver.application.is_using_ipython()[source]

Return True if the code is being run from an IPython session or notebook.

pysph.solver.application.list_all_kernels()[source]

Return list of available kernels.