Class TimeDiscretisation

Defined in Program listing for file kernel/src/simulationTools/TimeDiscretisation.hpp

class TimeDiscretisation

A time discretisation scheme.

A TimeDiscretisation object is used to discretized a given time interval. TimeDiscretisation are used:

  • in the simulation, as a user-input to discretized [t0,T]

  • in Sensor and Actuator, to define the set of time instants where the sensor or actuator must operate.

A TimeDiscretisation is defined with a starting time (t0), a time step size (h, non necessarily constant), the number of the current time step (k).

The time instant values are saved in a vector tk. Depending on the way of construction of the

TimeDiscretisation, all or only current and next times are saved in tk. The difference is just a question of saving memory.

Note that the

TimeDiscretisation is not linked to the Model. It’s up to the user to check that the way he builds his time-discretisation fits with the t0 and T given in the model.

Public Functions

TimeDiscretisation(const TkVector &newTk)

constructor with tk vector of instant times values.

  • newTk: a TkVector describing the discretisation

TimeDiscretisation(double t0, double h)

constructor with the size of the default time step and t0

  • t0: initial time value

  • h: the time step

TimeDiscretisation(unsigned int nSteps, double t0, double T)

constructor with the number of steps, t0 and T

  • nSteps: the number of steps

  • t0: initial time value

  • T: the final time

TimeDiscretisation(double t0, const std::string &str)

Constructor with the size of the default timestep and t0.

It creates a TimeDiscretisation using GMP for all its computation

  • t0: initial time value

  • str: the time step in form of a string

TimeDiscretisation(const TimeDiscretisation &td)

Copy constructor.


double currentTimeStep(const unsigned int k)

get the timestep \(t_{k+1} - t_k\)


the current time step

  • k: the index of the timestep

const mpf_t *currentTimeStep() const

get the timestep in gmp format


a pointer to the timestep in mpf_t format

void display() const

print the discretisation data to the screen

double getTk(const unsigned int indx)

get the value of tk at step k


a double

  • indx: the step

const TkVector &getTkVector() const

get the TkVector _tkV


a reference to the TkVector _tkV

bool hConst() const

determine whether the timestep is constant


true if the timestep is constant

bool hGmp() const

determine whether the TimeDiscretisation is using GMP


true if the TimeDiscretisation is using GMP

void setT0(double val)

change t0 before the simulation starts (useful for delays)

  • val: the new value for t0

void setTkVector(const TkVector &newTk)

set the TkVector _tkV

  • newTk: the new value for _tkV