File kernel/src/simulationTools/TimeDiscretisation.hpp

Go to the source code of this file

A time-discretisation scheme for a given interval.

Typedefs

typedef std::vector<double> TkVector
class TimeDiscretisation
#include <TimeDiscretisation.hpp>

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.

Parameters
  • newTk: a TkVector describing the discretisation

TimeDiscretisation(double t0, double h)

constructor with the size of the default time step and t0

Parameters
  • 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

Parameters
  • 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

Parameters
  • t0: initial time value
  • str: the time step in form of a string

TimeDiscretisation(const TimeDiscretisation &td)

Copy constructor.

Parameters

~TimeDiscretisation()
double currentTimeStep(const unsigned int k)

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

Return
the current time step
Parameters
  • k: the index of the timestep

const mpf_t *currentTimeStep() const

get the timestep in gmp format

Return
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

Return
a double
Parameters
  • indx: the step

const TkVector &getTkVector() const

get the TkVector _tkV

Return
a reference to the TkVector _tkV

bool hConst() const

determine whether the timestep is constant

Return
true if the timestep is constant

bool hGmp() const

determine whether the TimeDiscretisation is using GMP

Return
true if the TimeDiscretisation is using GMP

void setT0(double val)

change t0 before the simulation starts (useful for delays)

Parameters
  • val: the new value for t0

void setTkVector(const TkVector &newTk)

set the TkVector _tkV

Parameters
  • newTk: the new value for _tkV

Private Functions

TimeDiscretisation()

default constructor (private => no copy nor pass-by value)

ACCEPT_SERIALIZATION(TimeDiscretisation)

serialization hooks

double getT0() const

Get the origin of time t0.

Return
the origin of time

TimeDiscretisation &operator=(const TimeDiscretisation &td)

Assignment Operator (private => forbidden)

Return
TimeDiscretisation&
Parameters
  • td: unused

Private Members

double _h

Default value for the time step (tk+1 - tk)

mpf_t _hgmp

Timestep stored as mpf_t, for high precision computations.

double _t0

Origin of time.

mpf_t _t0gmp

Starting time, used to compute a good timestep.

mpf_t _tk

Time at t_{k+1}, in mpf_t, used to compute a good timestep.

mpf_t _tkp1

Time at t_{k+1}, in mpf_t, used to compute a good timestep.

TkVector _tkV

vector of time values at each step (=> size = n1+n2+1 - Default size = 2 - Max size= nSteps+1)