MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Clock.h
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2007 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #ifndef _CLOCK_H
11 #define _CLOCK_H
12 
25 class Clock
26 {
27  friend void testClock();
28  public:
29  Clock();
30  ~Clock();
31 
33  // Field assignment functions
35  void setDt( double v );
36  double getDt() const;
37  double getRunTime() const;
38  double getCurrentTime() const;
39  unsigned long getNsteps( ) const;
40  unsigned long getCurrentStep() const;
41  unsigned int getStride( ) const;
42 
43  void setTickStep( unsigned int i, unsigned int v );
44  unsigned int getTickStep( unsigned int i ) const;
45  void setTickDt( unsigned int i, double v );
46  double getTickDt( unsigned int i ) const;
47  unsigned int getDefaultTick( string className ) const;
48 
49  vector< double > getDts() const;
50 
52  // Dest functions
54 
58  void stop();
59 
61  void handleStart( const Eref& e, double runtime, bool notify );
62 
64  void handleStep( const Eref& e, unsigned long steps );
65 
67  void handleReinit( const Eref& e );
68 
70  // Stuff for new scheduling.
72  // Goes through the process loop.
73  void process();
74 
75 
77  unsigned int getNumTicks() const;
78 
82  bool isRunning() const;
86  bool isDoingReinit() const;
87 
91  static void reportClock();
92  void innerReportClock() const;
93 
94  // static void* threadStartFunc( void* threadInfo );
95  static const Cinfo* initCinfo();
96 
98  bool checkTickNum( const string& funcName, unsigned int i ) const;
99 
106  static unsigned int lookupDefaultTick( const string& className );
107 
109  static void buildDefaultTick();
110 
111  /*
112  * Does nasty message traversal to look up the clock tick that
113  * sends the Process/reinit message to the Dsolve (specified by e)
114  * and then figure out the dt used.
115  static double findDt( const Eref& e );
116  */
117 
121  static const unsigned int numTicks;
122 
123  private:
124  void buildTicks( const Eref& e );
125  double runTime_;
126  double currentTime_;
127  unsigned long nSteps_;
128  unsigned long currentStep_;
129  unsigned int stride_; // Increment to currentStep each cycle.
130  double dt_;
131 
136 
141 
146 
152  vector< unsigned int > ticks_;
153 
158  vector< unsigned int > activeTicks_;
163  vector< unsigned int > activeTicksMap_;
164 
169  static map< string, unsigned int > defaultTick_;
170 
171  static vector< double > defaultDt_;
172 
178  bool notify_;
179 };
180 
181 #endif // _CLOCK_H
void process()
bool isRunning_
The minimum dt. All ticks are a multiple of this.
Definition: Clock.h:135
void setDt(double v)
Definition: Clock.cpp:493
Clock()
Definition: Clock.cpp:458
static const unsigned int numTicks
Definition: Clock.h:121
void stop()
Definition: Clock.cpp:641
void handleReinit(const Eref &e)
dest function for message to trigger reinit.
Definition: Clock.cpp:808
Definition: Clock.h:25
double dt_
Definition: Clock.h:130
double getCurrentTime() const
Definition: Clock.cpp:512
bool notify_
When set to true, notify user about the status of simulation by emitting message whenever 10% of simu...
Definition: Clock.h:178
static const Cinfo * initCinfo()
Definition: Clock.cpp:133
unsigned int getStride() const
Definition: Clock.cpp:532
unsigned int getTickStep(unsigned int i) const
Definition: Clock.cpp:580
unsigned int getNumTicks() const
Definition: Clock.cpp:527
bool isDoingReinit() const
Definition: Clock.cpp:552
vector< double > getDts() const
Definition: Clock.cpp:537
friend void testClock()
double getTickDt(unsigned int i) const
Definition: Clock.cpp:621
~Clock()
Definition: Clock.cpp:478
void handleStart(const Eref &e, double runtime, bool notify)
dest function for message to run simulation for specified time
Definition: Clock.cpp:699
vector< unsigned int > activeTicksMap_
Definition: Clock.h:163
vector< unsigned int > activeTicks_
Definition: Clock.h:158
unsigned long currentStep_
Definition: Clock.h:128
bool checkTickNum(const string &funcName, unsigned int i) const
Utility func to range-check when Ticks are being changed.
Definition: Clock.cpp:557
double currentTime_
Definition: Clock.h:126
double getDt() const
Definition: Clock.cpp:503
ProcInfo info_
Definition: Clock.h:145
unsigned long getCurrentStep() const
Definition: Clock.cpp:522
void handleStep(const Eref &e, unsigned long steps)
dest function for message to run simulation for specified steps
Definition: Clock.cpp:711
bool isRunning() const
Definition: Clock.cpp:547
static vector< double > defaultDt_
Definition: Clock.h:171
double runTime_
Definition: Clock.h:125
void buildTicks(const Eref &e)
Definition: Clock.cpp:675
vector< unsigned int > ticks_
Definition: Clock.h:152
Definition: Eref.h:26
bool doingReinit_
Definition: Clock.h:140
static unsigned int lookupDefaultTick(const string &className)
Definition: Clock.cpp:1035
double getRunTime() const
Definition: Clock.cpp:507
void setTickStep(unsigned int i, unsigned int v)
Definition: Clock.cpp:575
void setTickDt(unsigned int i, double v)
Definition: Clock.cpp:591
static void buildDefaultTick()
Builds the default scheduling map of classes to ticks.
Definition: Clock.cpp:870
unsigned long nSteps_
Definition: Clock.h:127
static void reportClock()
Static function.
Definition: Clock.cpp:651
void innerReportClock() const
Definition: Clock.cpp:657
unsigned int getDefaultTick(string className) const
Definition: Clock.cpp:628
static map< string, unsigned int > defaultTick_
Definition: Clock.h:169
unsigned int stride_
Definition: Clock.h:129
Definition: Cinfo.h:18
unsigned long getNsteps() const
Definition: Clock.cpp:517