Class EventsManager¶
Defined in Program listing for file kernel/src/simulationTools/EventsManager.hpp
-
class EventsManager¶
Tools to handle a set of Events for the Simulation.
The EventsManager handles a set of events (from user time-discretisation, sensors, non-smooth …), and is supposed to provide to the simulation the values of “current” and “next” events to define the time-integration interval.
Events:
currentEvent: starting time for integration. Initialized with t0 of the simulation time-discretisation.
ETD: corresponds to the instant t[k+1] of the Simulation (user) TimeDiscretisation.
ENonSmooth: for EventDriven simulation only. Present only if one or more non-smooth events have been detected between currentEvent and the next event.
Sensor or Actuators Events. To each Sensor or Actuator declared in the ControlManager, corresponds an Event in the manager. When this event is processed, its time value is increased to next instant in the time-discretisation of the sensor/actuator.
Examples:
for a TimeStepping, with one Sensor, the EventsManager
looks like:
{currentEvent(tk), ESensor(tsensor), ETD(tk+1)}
for an EventDriven
, with one actuator, an non-smooth event detected at time tns:
{currentEvent(tk), EActuator(tact), ENonSmooth(tns), ETD(tk+1)}.
After each process, the time values of each event are updated and nextEvent points to the first event after currentEvent.
Main functions
initialize(): process all events which have the same time as currentEvent
processEvents(): process all events simultaneous to nextEvent, increment them to next step, update index sets, increment currentEvent.
Public Functions
-
EventsManager(SP::TimeDiscretisation td)¶
constructor
- Parameters
td – the TimeDiscretisation used in the Simulation
-
inline virtual ~EventsManager()¶
destructor
-
void initialize(double T)¶
Initialize: just set the final time.
- Parameters
T – the final time of the Simulation
-
inline void setGapLimitEvents(unsigned long int var)¶
Set the gap limit between two events.
- Parameters
var – the new _GapLimit2Events
-
inline unsigned long int getGapLimitEvents() const¶
Get the gap limit between two events.
- Returns
the gap limit
-
void noSaveInMemory(const Simulation &sim)¶
Change TimeDiscretisationEvent to TimeDiscretisationEventNoSaveInMemory.
Warning
use this at your own risk, many integrators needs previous values to integrate properly
- Parameters
sim – the Simulation that owns this EventsManager
-
inline EventsContainer &events()¶
return all the events
- Returns
a reference to the events set
-
inline bool hasNextEvent() const¶
check if there are some unprocessed events
- Returns
true if there are unprocessed events
-
double startingTime() const¶
get the time of current event, in double format
- Returns
the time of the last processed events
-
double nextTime() const¶
get the time of next event, in double format
- Returns
the time of the next events
-
bool needsIntegration() const¶
is an integration step required ? The current event and the next one may have the same time instant in which case no integration as to be performed
- Returns
true if the simulation needs to be integrate, no otherwise
-
void display() const¶
display EventsManager data
-
void scheduleNonSmoothEvent(Simulation &sim, double time, bool yes_update = true)¶
add a new Event in the allEvents list and update nextEvent value
- Parameters
sim – the simulation that owns this EventsManager
time – the time (double format) of occurence of the event
yes_update – indicator to update or not the next event (default value is true)
-
void processEvents(Simulation &sim)¶
Process the next event, update the indexSets if necessary.
- Parameters
sim – the simulation that owns this EventsManager
-
void preUpdate(Simulation &sim)¶
Function to be called once after initialization.
It is used to process NonSmoothEvents at the beginning of the Simulation, if there is any.
- Parameters
sim – the simulation that owns this EventsManager
-
Event &insertEvent(int type, double time)¶
insert an event of a certain type.
The event is created on the fly.
- Parameters
type – the type of the event
time – the time of the event
- Returns
a reference to the Event
-
Event &insertEvent(int type, SP::TimeDiscretisation td)¶
insert an event of a certain type.
The event is created on the fly, and the SP::TimeDiscretisation given in argument is stored inside
- Parameters
type – the type of the event
td – a TimeDiscretisation for the Event
- Returns
a reference to the Event
-
inline double getTkp1() const¶
get time instant k+1 of the time discretisation
- Returns
a double. If the simulation is near the end (t_{k+1} >= T), it returns NaN.
-
inline double getTkp2() const¶
get time instant k+2 of the time discretisation
- Returns
a double. If the simulation is near the end (t_{k+2} >= T), it returns NaN.
-
inline double getTkp3() const¶
get time instant k+3 of the time discretisation.
It is used when we have to reschedule a TD Event in scheduleNonSmoothEvent
- Returns
a double. If the simulation is near the end (t_{k+3} >= T), it returns NaN.
-
inline double currentTimeStep()¶
Get current timestep.
- Returns
the current timestep
-
inline const TimeDiscretisation &timeDiscretisation() const¶
-
- Returns
the TimeDiscretisation in use for the time integration
-
inline void updateT(double T)¶
update final time
- Parameters
T – the new final time