MOOSE - Multiscale Object Oriented Simulation Environment
|
#include <Clock.h>
Public Member Functions | |
bool | checkTickNum (const string &funcName, unsigned int i) const |
Utility func to range-check when Ticks are being changed. More... | |
Clock () | |
unsigned long | getCurrentStep () const |
double | getCurrentTime () const |
unsigned int | getDefaultTick (string className) const |
double | getDt () const |
vector< double > | getDts () const |
unsigned long | getNsteps () const |
unsigned int | getNumTicks () const |
double | getRunTime () const |
unsigned int | getStride () const |
double | getTickDt (unsigned int i) const |
unsigned int | getTickStep (unsigned int i) const |
void | handleReinit (const Eref &e) |
dest function for message to trigger reinit. More... | |
void | handleStart (const Eref &e, double runtime, bool notify) |
dest function for message to run simulation for specified time More... | |
void | handleStep (const Eref &e, unsigned long steps) |
dest function for message to run simulation for specified steps More... | |
void | innerReportClock () const |
bool | isDoingReinit () const |
bool | isRunning () const |
void | process () |
void | setDt (double v) |
void | setTickDt (unsigned int i, double v) |
void | setTickStep (unsigned int i, unsigned int v) |
void | stop () |
~Clock () | |
Static Public Member Functions | |
static void | buildDefaultTick () |
Builds the default scheduling map of classes to ticks. More... | |
static const Cinfo * | initCinfo () |
static unsigned int | lookupDefaultTick (const string &className) |
static void | reportClock () |
Static function. More... | |
Static Public Attributes | |
static const unsigned int | numTicks = 32 |
Private Member Functions | |
void | buildTicks (const Eref &e) |
Private Attributes | |
vector< unsigned int > | activeTicks_ |
vector< unsigned int > | activeTicksMap_ |
unsigned long | currentStep_ |
double | currentTime_ |
bool | doingReinit_ |
double | dt_ |
ProcInfo | info_ |
bool | isRunning_ |
The minimum dt. All ticks are a multiple of this. More... | |
bool | notify_ |
When set to true, notify user about the status of simulation by emitting message whenever 10% of simultion is over. More... | |
unsigned long | nSteps_ |
double | runTime_ |
unsigned int | stride_ |
vector< unsigned int > | ticks_ |
Static Private Attributes | |
static vector< double > | defaultDt_ |
static map< string, unsigned int > | defaultTick_ |
Friends | |
void | testClock () |
Clock now uses integral scheduling. The Clock has an array of child Ticks, each of which controls the process and reinit calls of its targets. The Clock has a minimum dt. All ticks operate with (positive) integral multiples of this, from 1 to anything. If multiple Ticks are due to go off in a given cycle, the order is from lowest to highest. Within a Tick the order of execution of target objects is undefined.
The Reinit call goes through all Ticks in order.
Clock::Clock | ( | ) |
Definition at line 458 of file Clock.cpp.
References buildDefaultTick(), defaultDt_, dt_, numTicks, and ticks_.
Clock::~Clock | ( | ) |
Definition at line 478 of file Clock.cpp.
References Msg::isLastTrump(), numTicks, processVec(), reinitVec(), and sharedProcVec().
|
static |
Builds the default scheduling map of classes to ticks.
This is the authoritative database of default tick assignments for each class. This is here because one needs to see relative locations of all assignments in order to do this. This assumes that in cases where there are two ticks (such as init and process) for a single class, then they are sequential. Base classes are also represented here. They are checked as a fallback if the more specific class lookup fails. Certain classes, such as Zombies, explicitly do not get scheduled even though they may inherit process messages. These are given the tick ~0U.
Definition at line 870 of file Clock.cpp.
References defaultDt_, defaultTick_, and numTicks.
Referenced by Clock().
|
private |
Definition at line 675 of file Clock.cpp.
References activeTicks_, activeTicksMap_, Eref::element(), Element::hasMsgs(), processVec(), stride_, and ticks_.
Referenced by handleReinit(), handleStep(), and testClock().
bool Clock::checkTickNum | ( | const string & | funcName, |
unsigned int | i | ||
) | const |
Utility func to range-check when Ticks are being changed.
Definition at line 557 of file Clock.cpp.
References doingReinit_, isRunning_, and numTicks.
Referenced by setTickDt(), and setTickStep().
unsigned long Clock::getCurrentStep | ( | ) | const |
Definition at line 522 of file Clock.cpp.
References currentStep_.
Referenced by initCinfo().
double Clock::getCurrentTime | ( | ) | const |
Definition at line 512 of file Clock.cpp.
References currentTime_.
Referenced by initCinfo(), and testClock().
unsigned int Clock::getDefaultTick | ( | string | className | ) | const |
Definition at line 628 of file Clock.cpp.
References lookupDefaultTick().
Referenced by initCinfo().
double Clock::getDt | ( | void | ) | const |
Definition at line 503 of file Clock.cpp.
References dt_.
Referenced by initCinfo().
vector< double > Clock::getDts | ( | ) | const |
Definition at line 537 of file Clock.cpp.
Referenced by initCinfo().
unsigned long Clock::getNsteps | ( | ) | const |
Definition at line 517 of file Clock.cpp.
References nSteps_.
Referenced by initCinfo().
unsigned int Clock::getNumTicks | ( | ) | const |
Definition at line 527 of file Clock.cpp.
References numTicks.
Referenced by initCinfo().
double Clock::getRunTime | ( | ) | const |
Definition at line 507 of file Clock.cpp.
References runTime_.
Referenced by initCinfo().
unsigned int Clock::getStride | ( | ) | const |
Definition at line 532 of file Clock.cpp.
References stride_.
Referenced by initCinfo().
double Clock::getTickDt | ( | unsigned int | i | ) | const |
Definition at line 621 of file Clock.cpp.
References dt_, numTicks, and ticks_.
Referenced by initCinfo(), Table::reinit(), and Streamer::reinit().
unsigned int Clock::getTickStep | ( | unsigned int | i | ) | const |
Definition at line 580 of file Clock.cpp.
References numTicks, and ticks_.
Referenced by initCinfo().
void Clock::handleReinit | ( | const Eref & | e | ) |
dest function for message to trigger reinit.
This is the dest function that sets off the reinit.
Definition at line 808 of file Clock.cpp.
References activeTicks_, activeTicksMap_, buildTicks(), currentStep_, currentTime_, ProcInfo::currTime, doingReinit_, ProcInfo::dt, dt_, info_, isRunning_, nSteps_, and reinitVec().
Referenced by initCinfo(), and testClock().
void Clock::handleStart | ( | const Eref & | e, |
double | runtime, | ||
bool | notify | ||
) |
dest function for message to run simulation for specified time
Start has to happen gracefully: If the simulation was stopped for any reason, it has to pick up where it left off. The "runtime" argument is the additional time to run the simulation.
Definition at line 699 of file Clock.cpp.
References dt_, handleStep(), notify_, and stride_.
Referenced by initCinfo(), and testClock().
void Clock::handleStep | ( | const Eref & | e, |
unsigned long | steps | ||
) |
dest function for message to run simulation for specified steps
Definition at line 711 of file Clock.cpp.
References activeTicks_, activeTicksMap_, buildTicks(), currentStep_, currentTime_, ProcInfo::currTime, doingReinit_, ProcInfo::dt, dt_, finished(), info_, isRunning_, notify_, nSteps_, processVec(), runTime_, SrcFinfo0::send(), and stride_.
Referenced by handleStart(), and initCinfo().
|
static |
Definition at line 133 of file Clock.cpp.
References clockCinfo, finished(), getCurrentStep(), getCurrentTime(), getDefaultTick(), getDt(), getDts(), getNsteps(), getNumTicks(), getRunTime(), getStride(), getTickDt(), getTickStep(), handleReinit(), handleStart(), handleStep(), Neutral::initCinfo(), isRunning(), numTicks, setDt(), setTickDt(), setTickStep(), sharedProcVec(), and stop().
Referenced by init(), testFibonacci(), and testShellAddMsg().
void Clock::innerReportClock | ( | ) | const |
Definition at line 657 of file Clock.cpp.
References currentTime_, dt_, isRunning_, runTime_, and ticks_.
Referenced by reportClock().
bool Clock::isDoingReinit | ( | ) | const |
Flag: True when the simulation is busy with reinit
Definition at line 552 of file Clock.cpp.
References doingReinit_.
bool Clock::isRunning | ( | ) | const |
Flag: True when the simulation is still running.
Definition at line 547 of file Clock.cpp.
References isRunning_.
Referenced by initCinfo().
|
static |
Look up the default Tick number for the specified class. Note that for objects having an 'init' action as well as process, the assigned tick is for 'init' and the next number will be used for 'process'.
Definition at line 1035 of file Clock.cpp.
References defaultTick_.
Referenced by getDefaultTick(), innerCopyElements(), Shell::innerCreate(), Stoich::unZombifyModel(), and Element::zombieSwap().
void Clock::process | ( | ) |
|
static |
Static function.
Utility function to tell us about the scheduling
Definition at line 651 of file Clock.cpp.
References Eref::data(), Id::eref(), and innerReportClock().
void Clock::setDt | ( | double | v | ) |
Definition at line 493 of file Clock.cpp.
References dt_, and isRunning_.
Referenced by initCinfo().
void Clock::setTickDt | ( | unsigned int | i, |
double | v | ||
) |
A little nasty because we want to ensure that the main clock dt is set intelligently from the assignment here.
Definition at line 591 of file Clock.cpp.
References checkTickNum(), dt_, minimumDt, numTicks, and ticks_.
Referenced by initCinfo().
void Clock::setTickStep | ( | unsigned int | i, |
unsigned int | v | ||
) |
Definition at line 575 of file Clock.cpp.
References checkTickNum(), and ticks_.
Referenced by initCinfo().
void Clock::stop | ( | ) |
Halts running simulation gracefully, letting it restart wherever it left off from.
Does a graceful stop of the simulation, leaving so it can continue cleanly with another step or start command.
Definition at line 641 of file Clock.cpp.
References isRunning_.
Referenced by initCinfo().
|
friend |
Check that clock scheduling works.
Definition at line 80 of file testScheduling.cpp.
|
private |
Array of active ticks. Drops out ticks lacking targets or with a zero step. Sorted in increasing order of tick index.
Definition at line 158 of file Clock.h.
Referenced by buildTicks(), handleReinit(), handleStep(), and testClock().
|
private |
Maps the activeTicks_ array to the ticks index so we can trigger the appropriate message.
Definition at line 163 of file Clock.h.
Referenced by buildTicks(), handleReinit(), and handleStep().
|
private |
Definition at line 128 of file Clock.h.
Referenced by getCurrentStep(), handleReinit(), and handleStep().
|
private |
Definition at line 126 of file Clock.h.
Referenced by getCurrentTime(), handleReinit(), handleStep(), and innerReportClock().
|
staticprivate |
Definition at line 171 of file Clock.h.
Referenced by buildDefaultTick(), and Clock().
|
staticprivate |
This is the database of default scheduling. Assigns classes to ticks. Filled in at Clock creation time.
Definition at line 169 of file Clock.h.
Referenced by buildDefaultTick(), and lookupDefaultTick().
|
private |
True while the system is doing a reinit
Definition at line 140 of file Clock.h.
Referenced by checkTickNum(), handleReinit(), handleStep(), and isDoingReinit().
|
private |
Definition at line 130 of file Clock.h.
Referenced by Clock(), getDt(), getDts(), getTickDt(), handleReinit(), handleStart(), handleStep(), innerReportClock(), setDt(), and setTickDt().
|
private |
Maintains Process info
Definition at line 145 of file Clock.h.
Referenced by handleReinit(), and handleStep().
|
private |
The minimum dt. All ticks are a multiple of this.
True while a process job is running
Definition at line 135 of file Clock.h.
Referenced by checkTickNum(), handleReinit(), handleStep(), innerReportClock(), isRunning(), setDt(), and stop().
|
private |
When set to true, notify user about the status of simulation by emitting message whenever 10% of simultion is over.
Definition at line 178 of file Clock.h.
Referenced by handleStart(), and handleStep().
|
private |
Definition at line 127 of file Clock.h.
Referenced by getNsteps(), handleReinit(), and handleStep().
|
static |
number of Ticks.
The Clock manages simulation scheduling, in a close collaboration with the Tick. This version does this using an array of child Ticks, which it manages directly.
Simulation scheduling requires that certain functions of groups of objects be called in a strict sequence according to a range of timesteps, dt. For example, the numerical integration function of a compartment may be called every 10 microseconds. Furthermore, there may be ion channels in the simulation which also have to be called every 10 microseconds, but always after all the compartments have been called. Finally, the graphical update function to plot the compartment voltage may be called every 1 millisecond of simulation time. The whole sequence has to be repeated till the runtime of the simulation is complete.
This scheduler uses integral multiples of the base timestep dt_.
The system works like this:
Definition at line 121 of file Clock.h.
Referenced by buildDefaultTick(), buildProcessVec(), checkTickNum(), Clock(), getNumTicks(), getTickDt(), getTickStep(), initCinfo(), setTickDt(), sharedProcVec(), testClock(), and ~Clock().
|
private |
Definition at line 125 of file Clock.h.
Referenced by getRunTime(), handleStep(), and innerReportClock().
|
private |
Definition at line 129 of file Clock.h.
Referenced by buildTicks(), getStride(), handleStart(), and handleStep().
|
private |
Ticks are sub-elements and send messages to sets of target Elements that handle calculations in which update order does not matter.
Definition at line 152 of file Clock.h.
Referenced by buildTicks(), Clock(), getDts(), getTickDt(), getTickStep(), innerReportClock(), setTickDt(), setTickStep(), and testClock().