Module controller¶
Implement infrastructure for the solver to add various interfaces
-
class
pysph.solver.controller.
CommandManager
(solver, comm=None)[source]¶ Bases:
object
Class to manage and synchronize commands from various Controllers
-
add_function
(callable, interval=1)[source]¶ add a function to to be called every interval iterations
-
add_interface
(*args, **kwds)[source]¶ Add a callable interface to the controller
The callable must accept an Controller instance argument. The callable is called in a new thread of its own and it can do various actions with methods defined on the Controller instance passed to it The new created thread is set to daemon mode and returned
-
get_particle_array_combined
(idx, procs=None)[source]¶ get a single particle array with combined data from all procs
specifying processes is currently not implemented
-
-
class
pysph.solver.controller.
Controller
(command_manager, block=True)[source]¶ Bases:
object
Controller class acts a a proxy to control the solver
This is passed as an argument to the interface
Methods available:
- get – get the value of a solver parameter
- set – set the value of a solver parameter
- get_result – return result of a queued command
- pause_on_next – pause solver thread on next iteration
- wait – wait (block) calling thread till solver is paused (call after pause_on_next)
- cont – continue solver thread (call after pause_on_next)
Various other methods are also available as listed in
CommandManager.dispatch_dict
which perform different functions.- The methods in CommandManager.active_methods do their operation and return the result (if any) immediately
- The methods in CommandManager.lazy_methods do their later when solver thread is available and return a task-id. The result of the task can be obtained later using the blocking call get_result() which waits till result is available and returns the result. The availability of the result can be checked using the lock returned by get_task_lock() method
FIXME: wait/cont currently do not work in parallel
-
cont
()[source]¶ continue solver thread after it has been paused by pause_on_next
call this only after calling the pause_on_next method
-
set_blocking
(block)[source]¶ set the blocking mode to True/False
In blocking mode (block=True) all methods other than getting of solver properties block until the command is executed by the solver and return the results. The blocking time can vary depending on the time taken by solver per iteration and the command_interval In non-blocking mode, these methods queue the command for later and return a string corresponding to the task_id of the operation. The result can be later obtained by a (blocking) call to get_result with the task_id as argument
-
class
pysph.solver.controller.
DummyComm
[source]¶ Bases:
object
A dummy MPI.Comm implementation as placeholder for for serial runs