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.
Main functions:
setCurrentTimeStep(), to set current h. This value will be used for all future time steps, until next change.
increment(), shift to next time step (increment k, and shift t[k] and t[k+1])
currentTime(), return t[k]
Construction
input = the complete vector tk. This defines t0, T, number of time steps and time step size (which is not necessarily constant). In this case, the whole vector is saved in the memory.
inputs = number of time steps, t0 and T. size h is computed with t0,T and nSteps. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
inputs = h and t0. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
inputs = t0 and h. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
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:
td – the TimeDiscretisation to copy
-
~TimeDiscretisation()#
-
double currentTimeStep(const unsigned int k)
get the timestep \( t_{k+1} - t_k \)
- Parameters:
k – the index of the timestep
- Returns:
the current time step
-
inline const mpf_t *currentTimeStep() const
get the timestep in gmp format
- Returns:
a pointer to the timestep in mpf_t format
-
inline bool hConst() const
determine whether the timestep is constant
- Returns:
true if the timestep is constant
-
inline bool hGmp() const
determine whether the TimeDiscretisation is using GMP
- Returns:
true if the TimeDiscretisation is using GMP
-
double getTk(const unsigned int indx)
get the value of tk at step k
- Parameters:
indx – the step
- Returns:
a double
-
inline const TkVector &getTkVector() const
get the TkVector _tkV
- Returns:
a reference to the TkVector _tkV
-
void setTkVector(const TkVector &newTk)
set the TkVector _tkV
- Parameters:
newTk – the new value for _tkV
-
void setT0(double val)
change t0 before the simulation starts (useful for delays)
- Parameters:
val – the new value for t0
-
void display() const
print the discretisation data to the screen
Private Functions
-
ACCEPT_SERIALIZATION(TimeDiscretisation)#
-
TimeDiscretisation()#
default constructor (private => no copy nor pass-by value)
-
TimeDiscretisation &operator=(const TimeDiscretisation &td)#
Assignment Operator (private => forbidden)
- Parameters:
td – unused
- Returns:
-
inline double getT0() const#
Get the origin of time t0.
- Returns:
the origin of time
Private Members
-
double _h#
Default value for the time step (tk+1 - tk)
-
TkVector _tkV#
vector of time values at each step (=> size = n1+n2+1 - Default size = 2 - Max size= nSteps+1)
-
double _t0#
Origin of time.
-
mpf_t _hgmp#
Timestep stored as mpf_t, for high precision computations.
-
mpf_t _tkp1#
Time at t_{k+1}, in mpf_t, 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 _t0gmp#
Starting time, used to compute a good timestep.