-
Notifications
You must be signed in to change notification settings - Fork 15
Modular Simulation Loop (Virtual Functions)
Ascent has a built in asc::Module
class, which provides virtual function calls for building complex, modular simulations.
Modular simulations are easy to compose, connect and disconnect during a simulation.
Understanding the purpose of the virtual functions is critical to building a robust and efficient simulation engine.
Ascent does not provide a modular simulator class, but rather provides the structure to build custom simulation engines.
Module
has the following virtual functions for building simulation loops:
link()
init()
operator()()
apply()
propagate(Propagator<double>& propagator, const double dt)
postprop()
postcalc()
By default these functions do nothing (except for propagate) and therefore not all must be implemented to build a working simulation engine.
The link
function is meant to connect various modules together (link them). Often pointers are used, and valid pointers to other modules may be needed prior to initialization.
link
should be called once per module
The init
function is meant for initialization code once the modules to be run are linked.
init
should be called once per module
The function operator is used for derivative accumulations. For example, computing and accumulating forces on a mass. For most systems the bulk of the computational code will exist within this function.
operator()
will be called one or more times per numerical integration step. For example a Runge Kutta 4th order solver will call this four times.
The apply
function is used to apply accumulated derivative computations (such as forces) prior to numerical integration (or propagation).
apply
is called afteroperator()
one or more times per numerical integration step.
Note: Some simply systems can apply within
operator()
, however generically handling multiple accumulating modules on another module requires the proper use ofapply
.