.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Member Functions | List of all members
MDSimulation::EventCalendar Class Reference

#include <EventCalendar.h>

Public Member Functions

 EventCalendar (const unsigned particleCount)
 Initialize the calendar for a given number of particles. More...
 
 ~EventCalendar ()
 Clean up the dynamically allocated memory. More...
 
void ScheduleEvent (const double time, const EventType type, const int idA=Constants::NULL_PARTICLE, const int idB=Constants::NULL_PARTICLE)
 Schedule an event with the calendar. More...
 
void NextEvent ()
 Advance the calendar one step and put the next event into the current event place holders.
 
bool HasMoreEvents ()
 Test whether the calendar has more events in it. More...
 
void ClearCalendar ()
 Empties all events from the event calendar and returns the allocated tree nodes to the free list. More...
 
double GetCurrentTime () const
 
int GetCurrentObjectA () const
 
int GetCurrentObjectB () const
 
double BalanceRatio () const
 Computes the ratio of the longest path to a leaf over the shortest path to a leaf. More...
 
EventType GetCurrentEventType () const
 

Detailed Description

Author
Spenser Bauman

Interface for the Event Calendar class.

A node in the event calendar. Each node represents one event in the tree. It is structured using a binary search tree ordered by time. Each event involves two objects in the system. For collisions between two particles, it is the integer IDs of the two particles. For cell crossing events, the first is the ID of the particle and the second is the ID of the cell wall being crossed.

Each node uses six pointers to allow for quick updating of the calendar. Left and Right track the children as a typical BST would. Parent is the node's parent in the tree (where NULL indicates we are at the root).

CircleAL/CircleAR are the left and right pointers in the circular list of events involving object A. CircleBL/CircleBR do the same for object B.

An important invariant of this code is the invariance of the Type field for each CalendarNode. Once the Type field is set, just after allocation, it is not changed until FreeNode is called. In effect, the Type field is const for the entire time each node is validly allocated.

Constructor & Destructor Documentation

MDSimulation::EventCalendar::EventCalendar ( const unsigned  particleCount)

Initialize the calendar for a given number of particles.

Parameters
particleCountThe number of particles in the system that the event calendar is tracking.
MDSimulation::EventCalendar::~EventCalendar ( )

Clean up the dynamically allocated memory.

Member Function Documentation

double MDSimulation::EventCalendar::BalanceRatio ( ) const

Computes the ratio of the longest path to a leaf over the shortest path to a leaf.

This is for useful diagnostics about tree balancing.

void MDSimulation::EventCalendar::ClearCalendar ( )

Empties all events from the event calendar and returns the allocated tree nodes to the free list.

The memory is kept, as it is expected that it will be used again.

EventType MDSimulation::EventCalendar::GetCurrentEventType ( ) const
Returns
The type of the current event in the simulation.
int MDSimulation::EventCalendar::GetCurrentObjectA ( ) const
Returns
The id of the first object in the simulation.
int MDSimulation::EventCalendar::GetCurrentObjectB ( ) const
Returns
The id of the second object in the simulation.
double MDSimulation::EventCalendar::GetCurrentTime ( ) const
Returns
The time of the current event in the simulation.
bool MDSimulation::EventCalendar::HasMoreEvents ( )

Test whether the calendar has more events in it.

Returns
True if there are more events in the calendar, otherwise false.
void MDSimulation::EventCalendar::ScheduleEvent ( const double  time,
const EventType  type,
const int  idA = Constants::NULL_PARTICLE,
const int  idB = Constants::NULL_PARTICLE 
)

Schedule an event with the calendar.

Schedule an event in the simulation.

Parameters
timeThe time the event will occur in simulation units.
typeThe type of the event.
idAThe id of the first object in the event. This refers to the the first particle unless this is an UpdateSystemEvent.
idBThe id of the second object in the event. This may correspond to other things (i.e. the cell wall being crossed) depending on the type of the event.

The documentation for this class was generated from the following files: