#include <Module.h>
|
void | stopSimulation (bool b=true) |
|
void | addIntegrator (double &x, double &xd, const double tolerance=-1.0) |
|
template<typename T > |
void | addIntegrator (T &x, T &xd, const double tolerance=-1.0) |
|
virtual void | init () |
|
virtual void | update () |
|
virtual void | postcalc () |
|
virtual void | check () |
|
virtual void | report () |
|
virtual void | reset () |
|
template<typename T > |
T & | define (const std::string &id, T &x, bool infinite=false) |
|
void | steps (const std::string &id, size_t steps) |
|
void | steps (const std::string &id, bool infinite=true) |
|
bool | sample () const |
|
bool | sample (double sdt) |
|
bool | event (double t_event) |
|
void | addStopper (Module &module) |
|
template<typename T > |
void | addStopper (Link< T > &module) |
|
template<typename T , typename... Trest> |
void | addStopper (Link< T > &first, Trest &...rest) |
|
|
template<typename T > |
class | Link |
|
class | Simulator |
|
class | Stopper |
|
template<typename E > |
class | HistoryVector |
|
template<typename T > |
void | integrator (size_t sim) |
|
void | integrationTolerance (size_t sim, const double tolerance) |
|
Provides the core functionality of the Ascent architecture. A module in Ascent should always inherit from the Module class.
void asc::Module::addIntegrator |
( |
double & |
x, |
|
|
double & |
xd, |
|
|
const double |
tolerance = -1.0 |
|
) |
| |
|
protected |
Add a state and its derivative to be integrated.
- Parameters
-
x | State. |
xd | State derivative. |
tolerance | The integration tolerance for this state. Only applicable when using an adaptively stepping integration method. The default negative tolerance means that this state will not be considered for adaptive stepping, even if an adaptive solver is used. |
template<typename T >
void asc::Module::addIntegrator |
( |
T & |
x, |
|
|
T & |
xd, |
|
|
const double |
tolerance = -1.0 |
|
) |
| |
|
inlineprotected |
Add a std::vector, std::deque, Eigen::Vector3d, etc. to be integrated.
- Parameters
-
x | State vector. |
xd | State derivatives vector. |
tolerance | The integration tolerance for these states. Only applicable when using an adaptively stepping integration method. The default negative tolerance means that this state will not be considered for adaptive stepping, even if an adaptive solver is used. |
template<typename T , typename... Types>
asc::Link<T> asc::Module::addManipulator |
( |
Types &&... |
args | ) |
|
|
inline |
Generate a manipulator module whose memory is owned by this module as long as the manipulator isn't also stored elsewhere (if Link<T> isn't saved). Manipulators should usually only mess with parameters from this module. Manipulators are ordered via the runBefore method, so they always run before the module they are manipulating.
void asc::Module::addStopper |
( |
Module & |
module | ) |
|
|
inlineprotected |
Add an uncontained module as a stopper. Uncontained modules must be added one at a time.
template<typename T >
void asc::Module::addStopper |
( |
Link< T > & |
module | ) |
|
|
inlineprotected |
Add a Link contained module as a stopper.
template<typename T , typename... Trest>
void asc::Module::addStopper |
( |
Link< T > & |
first, |
|
|
Trest &... |
rest |
|
) |
| |
|
inlineprotected |
Add a collection of Link contained module as a cummulative stopper.
virtual void asc::Module::check |
( |
| ) |
|
|
inlineprotectedvirtual |
Called at the end of every full time step before report() in order to check whether the simulation should be stopped (set stoppers here).
template<typename T >
T& asc::Module::define |
( |
const std::string & |
id, |
|
|
T & |
x, |
|
|
bool |
infinite = false |
|
) |
| |
|
inlineprotected |
Enables a variable in this Module to be tracked and/or externally accessed and set.
- Parameters
-
id | The string identification used to access the variable. |
x | Variable to be tracked via a pointer. Hence the variable's memory should be owned by this class. |
infinite | Set infinite to true in order to record history of the variable indefinitely. |
void asc::Module::directory |
( |
const std::string & |
directory | ) |
|
|
inline |
Sets a new default directory for output files.
void asc::Module::dtChange |
( |
double |
new_dt | ) |
|
|
inline |
Change the time step of this module's simulator.
- Parameters
-
new_dt | New time step size. |
bool asc::Module::error |
( |
const std::string & |
description | ) |
|
|
inline |
Puts this module's simulator in an error state, which will shut down the simulator as soon as possible.
- Parameters
-
description | Describe the error. Collected errors are retrieved via the getError() method. |
- Returns
- Always returns false.
std::pair<bool, std::vector<std::string> > asc::Module::error |
( |
| ) |
|
|
inline |
Check if the simulator is in an error state and get a vector of recorded error descriptions.
- Returns
- Returns a pair whose first value is true if the simulator is in an error state. The second value is a vector of error descriptions.
bool asc::Module::event |
( |
double |
t_event | ) |
|
|
inlineprotected |
Discrete run time event.
- Parameters
-
t_event | The time of the desired event. |
- Returns
- Returns true if at the first pass of the integration method and at the specified event time (t_event).
template<typename T >
std::deque<T> asc::Module::history |
( |
const std::string & |
id | ) |
|
|
inline |
Obtain time history of a tracked variable.
- Parameters
-
id | The string identification of the variable. |
- Returns
- Returns a pair of time history matched with the variable's state history.
virtual void asc::Module::init |
( |
| ) |
|
|
inlineprotectedvirtual |
For initialization computations.
void asc::Module::integrationTolerance |
( |
double |
tolerance | ) |
|
|
inline |
Set relative error integration tolerance for this module's states.
- Parameters
-
tolerance | The integration tolerance for this module's states. A negative value turns off step resizing for this module's states. |
template<typename T >
Link<T> asc::Module::linkFromThis |
( |
| ) |
|
|
inline |
Generate a Link<T> container from this class; similar to std::shared_from_this().
std::string asc::Module::name |
( |
| ) |
const |
Access this module's name, which is printed with output data.
template<typename T >
bool asc::Module::name |
( |
const std::string & |
name | ) |
|
|
inline |
Define this module for external access.
- Parameters
-
name | Used in output files if this module is used for tracking. |
void asc::Module::outputTrack |
( |
| ) |
|
Create output file for this Module's tracked parameters.
virtual void asc::Module::postcalc |
( |
| ) |
|
|
inlineprotectedvirtual |
Runs once per full integration step and after propagate states for computations based on updated states, runs before check() and report().
void asc::Module::printErrors |
( |
bool |
b | ) |
|
|
inline |
Set whether or not error messages should be printed to the console.
virtual void asc::Module::report |
( |
| ) |
|
|
inlineprotectedvirtual |
End of full time step report (for a 4th order Runge Kutta, report() is called once after four update() calls).
virtual void asc::Module::reset |
( |
| ) |
|
|
inlineprotectedvirtual |
Used to reset Module parameters after update() and report() have been called (runs for internal kpass steps as well).
bool asc::Module::run |
( |
const double |
dt, |
|
|
const double |
tend |
|
) |
| |
|
inline |
Runs this module's associated simulator.
- Parameters
-
dt | The time step of for the simulator. |
tend | The end time to run the simulator until. |
bool asc::Module::run |
( |
| ) |
|
|
inline |
Runs this module's associated simulator at currently set dt and tend values.
template<typename T >
void asc::Module::runBefore |
( |
Link< T > & |
link | ) |
|
|
inline |
Specifies that the module within the link container must run before this module. The runBefore method applies to the update() and postcalc() simulation phases.
- Parameters
-
link | A Link contained module. |
template<typename T , typename... Trest>
void asc::Module::runBefore |
( |
Link< T > & |
link, |
|
|
Trest &... |
rest |
|
) |
| |
|
inline |
A variadic implementation of runBefore(Link<T>& link).
- Parameters
-
link | The first module that must run before this module. |
rest | Any number of modules that must be run before this module. Example: Within the update() and postcalc() phases, this Module will run before the spring0, damper1, and spring4 update() and postcalc() methods. |
void asc::Module::runBefore |
( |
Module & |
module | ) |
|
|
inline |
Specifies that the module within the link container must run before this module. The runBefore method applies to the update() and postcalc() simulation phases.
template<typename... Trest>
void asc::Module::runBefore |
( |
Module & |
module, |
|
|
Trest &... |
rest |
|
) |
| |
|
inline |
A variadic implementation of runBefore(Module& module).
- Parameters
-
module | The first module that must run before this module. |
rest | Any number of modules that must be run before this module. |
bool asc::Module::sample |
( |
| ) |
const |
|
inlineprotected |
Discrete sampling per time step.
- Returns
- Returns true if at the first pass of the integration method.
bool asc::Module::sample |
( |
double |
sdt | ) |
|
|
inlineprotected |
Discrete sampling with a specified sampling rate. The simulator will be stepped to exact multiples of the sampling rate.
- Parameters
-
sdt | The sampling rate. This number doesn't need to be fixed and is allowed to be changed during the simulation. |
- Returns
- Returns true if at the first pass of the integration method at the specified sampling time.
void asc::Module::steps |
( |
const std::string & |
id, |
|
|
size_t |
steps |
|
) |
| |
|
inlineprotected |
Set the number of time steps to keep track of for a tracked variable.
- Parameters
-
id | The string identification of the variable. |
steps | The number of steps to keep track of. |
void asc::Module::steps |
( |
const std::string & |
id, |
|
|
bool |
infinite = true |
|
) |
| |
|
inlineprotected |
Set a variable to be tracked indefinitely; in other words, to have an infinite number of steps recorded.
- Parameters
-
id | The string identification of the variable. |
infinite | Whether or not to have an infinite number of steps tracked. |
void asc::Module::stopSimulation |
( |
bool |
b = true | ) |
|
|
inlineprotected |
Stops this Module's simulator at the end the current integration step.
- Parameters
-
b | Allows the command to stop the simulation to be turned on and off, so module's can compete and ordering can decide ending the simulation. |
const std::vector<double>& asc::Module::timeHistory |
( |
| ) |
const |
|
inline |
Retrieve a vector of the time history, with the time at each full step recorded.
void asc::Module::track |
( |
const std::string & |
var_name | ) |
|
Specify a variable to be tracked.
- Parameters
-
var_name | Associated variable name. |
void asc::Module::track |
( |
Module & |
module, |
|
|
const std::string & |
var_name |
|
) |
| |
Specify a variable to be tracked.
- Parameters
-
module | An uncontained Module. |
var_name | Associated variable name. |
template<typename T >
void asc::Module::track |
( |
Link< T > & |
link, |
|
|
const std::string & |
var_name |
|
) |
| |
|
inline |
Specify a variable in a Link contained Module to be tracked.
- Parameters
-
link | Link contained Module. |
var_name | Associated variable name. |
bool asc::Module::trackable |
( |
const std::string & |
var_name | ) |
|
|
inline |
Check if a variable in a module is setup for tracking.
- Parameters
-
module_id | Module ID for the module that contains the variable of interest. |
var_name | Associated variable name. |
- Returns
- Returns true if the variable was setup for tracking.
void asc::Module::txtFiles |
( |
| ) |
|
|
inline |
Change output file type to .txt instead of .csv
virtual void asc::Module::update |
( |
| ) |
|
|
inlineprotectedvirtual |
Called for every kpass internal step (for example: called four times for a 4th order Runge Kutta integrator).
void integrationTolerance |
( |
size_t |
sim, |
|
|
const double |
tolerance |
|
) |
| |
|
friend |
Set the relative error integration tolerance for the entire simulator associated with this module.
- Parameters
-
sim | The simulator number. |
tolerance | The integration tolerance. If negative, it will turn off step resizing for all states in this module's simulator. |
template<typename T >
void integrator |
( |
size_t |
sim | ) |
|
|
friend |
Set the integrator for the simulator whose number is input.
- Parameters
-
ChaiScript interface, unique to the simulator that this module belongs to.
const double& asc::Module::dt |
The simulator's current time step size.
const bool& asc::Module::first_report = simulator.tickfirst |
True if at the first report of the current simulation run.
const bool& asc::Module::first_update = simulator.tickfirst |
True if at the first update of the current simulation run. True only for the first pass on update() for the current run() call.
bool asc::Module::freeze_integration = false |
Specifies whether the integration (state propagation) should be frozen for this module.
bool asc::Module::frozen = false |
const bool& asc::Module::last_report = simulator.ticklast |
True if at the final report for the current simulation run.
const size_t asc::Module::module_id |
This Module's unique identification across all simulators.
const size_t asc::Module::sim |
This Module's simulator identification.
bool asc::Module::stop = false |
Whether this module wants to stop the simulation, used for building stoppers.
const double& asc::Module::t |
The simulator's current time.
const bool& asc::Module::time_advanced = simulator.time_advanced |
If time advanced in the last simulation pass
The documentation for this class was generated from the following file:
- C:/Users/sberry/Desktop/Ascent/ascent/ascent/Module.h