#include <SimulationTime.hpp>
Public Member Functions | |
void | SetEndTimeAndNumberOfTimeSteps (double endTime, unsigned totalTimeStepsInSimulation) |
void | ResetEndTimeAndNumberOfTimeSteps (const double &rEndTime, const unsigned &rNumberOfTimeStepsInThisRun) |
double | GetTimeStep () const |
void | IncrementTimeOneStep () |
unsigned | GetTimeStepsElapsed () const |
double | GetTime () const |
bool | IsStartTimeSetUp () const |
bool | IsFinished () const |
unsigned | GetTotalNumberOfTimeSteps () const |
void | SetStartTime (double startTime) |
Static Public Member Functions | |
static SimulationTime * | Instance () |
static void | Destroy () |
Protected Member Functions | |
SimulationTime () | |
SimulationTime (const SimulationTime &) | |
SimulationTime & | operator= (const SimulationTime &) |
Private Member Functions | |
template<class Archive> | |
void | serialize (Archive &archive, const unsigned int version) |
Private Attributes | |
double | mDurationOfSimulation |
unsigned | mTotalTimeStepsInSimulation |
unsigned | mTimeStepsElapsed |
bool | mEndTimeAndNumberOfTimeStepsSet |
double | mCurrentTime |
double | mEndTime |
double | mStartTime |
bool | mStartTimeSet |
Static Private Attributes | |
static SimulationTime * | mpInstance = NULL |
Friends | |
class | boost::serialization::access |
Note that the start time, end time and number of time steps must be set before time can be incremented and returned.
You should generally use the calls IncrementTimeOneStep() and GetTime() when using this class.
Definition at line 45 of file SimulationTime.hpp.
SimulationTime::SimulationTime | ( | ) | [protected] |
Default simulation time constructor
Sets up time, you must set the start time, end time and number of time steps before using the object.
Definition at line 46 of file SimulationTime.cpp.
References mpInstance.
SimulationTime::SimulationTime | ( | const SimulationTime & | ) | [protected] |
Copy constructor.
SimulationTime * SimulationTime::Instance | ( | ) | [static] |
Return a pointer to the simulation time object. The first time this is called the simulation time object is created.
Definition at line 36 of file SimulationTime.cpp.
References mpInstance.
Referenced by CellBasedSimulationWithPdes< DIM >::AfterSolve(), CryptProjectionForce::CalculateForceBetweenNodes(), GeneralisedLinearSpringForce< DIM >::CalculateForceBetweenNodes(), Cell::Cell(), AbstractCellCycleModel::GetAge(), CellCycleModelOdeHandler::GetDt(), NagaiHondaForce< DIM >::GetTargetAreaOfCell(), Cell::GetTimeUntilDeath(), Cell::IsDead(), CryptSimulationArchiver< DIM, SIM >::Load(), CellBasedSimulationArchiver< DIM, SIM >::Load(), VertexCryptSimulation2d::PostSolve(), CryptSimulation2d::PostSolve(), CellBasedSimulationWithPdes< DIM >::PostSolve(), AbstractSimpleCellCycleModel::ResetForDivision(), CryptSimulationArchiver< DIM, SIM >::Save(), CellBasedSimulationArchiver< DIM, SIM >::Save(), AbstractCellCycleModel::serialize(), AbstractCellBasedTestSuite::setUp(), VertexCryptSimulation2d::SetupSolve(), CryptSimulation2d::SetupSolve(), CellBasedSimulationWithPdes< DIM >::SetupSolve(), SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), CellBasedSimulation< DIM >::Solve(), Cell::StartApoptosis(), RandomCellKiller< DIM >::TestAndLabelSingleCellForApoptosis(), SingleOdeWntCellCycleModel::UpdateCellCyclePhase(), AbstractWntOdeBasedCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateCellCyclePhase(), AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), CellBasedSimulation< DIM >::UpdateNodePositions(), AbstractCellPopulation< DIM >::WriteCellIdDataToFile(), MeshBasedCellPopulation< DIM >::WriteCellPopulationVolumeResultsToFile(), MeshBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), DiscreteSystemForceCalculator::WriteResultsToFile(), VertexBasedCellPopulation< DIM >::WriteResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteResultsToFiles(), AbstractCellPopulation< DIM >::WriteResultsToFiles(), AbstractCentreBasedCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), AbstractCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteVoronoiResultsToFile(), MeshBasedCellPopulationWithGhostNodes< DIM >::WriteVtkResultsToFile(), and MeshBasedCellPopulation< DIM >::WriteVtkResultsToFile().
void SimulationTime::SetEndTimeAndNumberOfTimeSteps | ( | double | endTime, | |
unsigned | totalTimeStepsInSimulation | |||
) |
Sets the end time and the number of time steps. This must be called after SetStartTime() but before using any other methods.
endTime | time at which to end this run of the simulation | |
totalTimeStepsInSimulation | the number of time steps into which the above will be divided |
Definition at line 115 of file SimulationTime.cpp.
References mCurrentTime, mDurationOfSimulation, mEndTime, mEndTimeAndNumberOfTimeStepsSet, mStartTimeSet, and mTotalTimeStepsInSimulation.
Referenced by CellBasedSimulation< DIM >::Solve().
void SimulationTime::ResetEndTimeAndNumberOfTimeSteps | ( | const double & | rEndTime, | |
const unsigned & | rNumberOfTimeStepsInThisRun | |||
) |
Reset method for the end time and the number of time steps, to run the simulation further after a first initial run.
rEndTime | the new end time for this simulation (the simulation will run from the current time to this new end time, NOT from 0 to this end time) | |
rNumberOfTimeStepsInThisRun | the number of time steps into which the next run is split |
Definition at line 131 of file SimulationTime.cpp.
References mCurrentTime, mDurationOfSimulation, mEndTime, mEndTimeAndNumberOfTimeStepsSet, mStartTime, mStartTimeSet, mTimeStepsElapsed, and mTotalTimeStepsInSimulation.
Referenced by CellBasedSimulation< DIM >::Solve().
double SimulationTime::GetTimeStep | ( | ) | const |
Get the simulation time step, set in earlier calls.
Warning: Use of this method may result in round errors; generally use GetTime() instead.
Definition at line 77 of file SimulationTime.cpp.
References mDurationOfSimulation, mEndTimeAndNumberOfTimeStepsSet, mStartTimeSet, and mTotalTimeStepsInSimulation.
Referenced by CryptProjectionForce::CalculateForceBetweenNodes(), GeneralisedLinearSpringForce< DIM >::CalculateForceBetweenNodes(), CellCycleModelOdeHandler::GetDt(), VertexCryptSimulation2d::PostSolve(), CryptSimulation2d::PostSolve(), CellBasedSimulationWithPdes< DIM >::PostSolve(), and SimpleOxygenBasedCellCycleModel::UpdateCellCyclePhase().
void SimulationTime::IncrementTimeOneStep | ( | ) |
Increment the simulation time by one time step.
GetTime() will return an updated current time after this call.
Definition at line 85 of file SimulationTime.cpp.
References mCurrentTime, mDurationOfSimulation, mEndTimeAndNumberOfTimeStepsSet, mStartTime, mStartTimeSet, mTimeStepsElapsed, and mTotalTimeStepsInSimulation.
Referenced by CellBasedSimulation< DIM >::Solve().
unsigned SimulationTime::GetTimeStepsElapsed | ( | ) | const |
Get the number of time steps that have elapsed.
Definition at line 96 of file SimulationTime.cpp.
References mEndTimeAndNumberOfTimeStepsSet, and mTimeStepsElapsed.
Referenced by VertexCryptSimulation2d::PostSolve(), CryptSimulation2d::PostSolve(), CellBasedSimulationWithPdes< DIM >::PostSolve(), CellBasedSimulation< DIM >::Solve(), VertexBasedCellPopulation< DIM >::WriteResultsToFiles(), MeshBasedCellPopulationWithGhostNodes< DIM >::WriteVtkResultsToFile(), and MeshBasedCellPopulation< DIM >::WriteVtkResultsToFile().
double SimulationTime::GetTime | ( | ) | const |
Get the simulation time (in hours), should not have rounding errors.
Definition at line 103 of file SimulationTime.cpp.
References mCurrentTime, and mStartTimeSet.
Referenced by AbstractCellCycleModel::GetAge(), NagaiHondaForce< DIM >::GetTargetAreaOfCell(), Cell::GetTimeUntilDeath(), VertexCryptSimulation2d::PostSolve(), CryptSimulation2d::PostSolve(), CellBasedSimulationWithPdes< DIM >::PostSolve(), AbstractSimpleCellCycleModel::ResetForDivision(), CryptSimulationArchiver< DIM, SIM >::Save(), CellBasedSimulationArchiver< DIM, SIM >::Save(), VertexCryptSimulation2d::SetupSolve(), CryptSimulation2d::SetupSolve(), CellBasedSimulationWithPdes< DIM >::SetupSolve(), SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), CellBasedSimulation< DIM >::Solve(), Cell::StartApoptosis(), AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), CellBasedSimulation< DIM >::UpdateNodePositions(), AbstractCellPopulation< DIM >::WriteCellIdDataToFile(), MeshBasedCellPopulation< DIM >::WriteCellPopulationVolumeResultsToFile(), MeshBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), DiscreteSystemForceCalculator::WriteResultsToFile(), VertexBasedCellPopulation< DIM >::WriteResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteResultsToFiles(), AbstractCellPopulation< DIM >::WriteResultsToFiles(), AbstractCentreBasedCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), AbstractCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), and MeshBasedCellPopulation< DIM >::WriteVoronoiResultsToFile().
void SimulationTime::Destroy | ( | ) | [static] |
Destroy the current SimulationTime instance. The next call to Instance will create a new instance, on which SetEndTimeAndNumberOfTimeSteps must be called again to reset time.
This method *must* be called before program exit, to avoid a memory leak.
Definition at line 58 of file SimulationTime.cpp.
References mpInstance.
Referenced by AbstractCellBasedTestSuite::tearDown().
bool SimulationTime::IsStartTimeSetUp | ( | ) | const |
Allows lower classes to check whether the simulation time class has been set up before using it
Definition at line 151 of file SimulationTime.cpp.
References mStartTimeSet.
Referenced by CryptSimulationArchiver< DIM, SIM >::Load(), CellBasedSimulationArchiver< DIM, SIM >::Load(), CryptSimulationArchiver< DIM, SIM >::Save(), and CellBasedSimulationArchiver< DIM, SIM >::Save().
bool SimulationTime::IsFinished | ( | ) | const |
Definition at line 157 of file SimulationTime.cpp.
References mCurrentTime, and mEndTime.
unsigned SimulationTime::GetTotalNumberOfTimeSteps | ( | ) | const |
Definition at line 163 of file SimulationTime.cpp.
References mTotalTimeStepsInSimulation.
void SimulationTime::SetStartTime | ( | double | startTime | ) |
Set the start time of the simulation
startTime | the time at which the simulation begins (usually 0.0 hours) |
Definition at line 68 of file SimulationTime.cpp.
References mCurrentTime, mStartTime, and mStartTimeSet.
Referenced by AbstractCellBasedTestSuite::setUp().
SimulationTime& SimulationTime::operator= | ( | const SimulationTime & | ) | [protected] |
Overloaded assignment operator.
void SimulationTime::serialize | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Serialization of a SimulationTime object must be done with care. Before the object is serialized via a pointer, it *MUST* be serialized directly, or an assertion will trip when a second instance of the class is created on de-serialization.
archive | the archive | |
version | the current version of this class |
Definition at line 219 of file SimulationTime.hpp.
References mCurrentTime, mDurationOfSimulation, mEndTime, mEndTimeAndNumberOfTimeStepsSet, mStartTime, mStartTimeSet, mTimeStepsElapsed, and mTotalTimeStepsInSimulation.
friend class boost::serialization::access [friend] |
Needed for serialization.
Definition at line 208 of file SimulationTime.hpp.
SimulationTime * SimulationTime::mpInstance = NULL [static, private] |
A pointer to the singleton instance of this class.
Pointer to the single instance
Definition at line 163 of file SimulationTime.hpp.
Referenced by Destroy(), Instance(), and SimulationTime().
double SimulationTime::mDurationOfSimulation [private] |
The duration of the simulation (time is measured in units of hours).
Definition at line 168 of file SimulationTime.hpp.
Referenced by GetTimeStep(), IncrementTimeOneStep(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetEndTimeAndNumberOfTimeSteps().
unsigned SimulationTime::mTotalTimeStepsInSimulation [private] |
The total number of steps for this simulation.
Definition at line 173 of file SimulationTime.hpp.
Referenced by GetTimeStep(), GetTotalNumberOfTimeSteps(), IncrementTimeOneStep(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetEndTimeAndNumberOfTimeSteps().
unsigned SimulationTime::mTimeStepsElapsed [private] |
The number of time steps which have been taken to date.
Definition at line 178 of file SimulationTime.hpp.
Referenced by GetTimeStepsElapsed(), IncrementTimeOneStep(), ResetEndTimeAndNumberOfTimeSteps(), and serialize().
bool SimulationTime::mEndTimeAndNumberOfTimeStepsSet [private] |
A flag allowing us to determine whether the simulation time is ready to be used.
Definition at line 184 of file SimulationTime.hpp.
Referenced by GetTimeStep(), GetTimeStepsElapsed(), IncrementTimeOneStep(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetEndTimeAndNumberOfTimeSteps().
double SimulationTime::mCurrentTime [private] |
The current time (in hours)
Definition at line 189 of file SimulationTime.hpp.
Referenced by GetTime(), IncrementTimeOneStep(), IsFinished(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), SetEndTimeAndNumberOfTimeSteps(), and SetStartTime().
double SimulationTime::mEndTime [private] |
The time at which the simulation should stop
Definition at line 194 of file SimulationTime.hpp.
Referenced by IsFinished(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetEndTimeAndNumberOfTimeSteps().
double SimulationTime::mStartTime [private] |
Stores the time at which the simulation started
Definition at line 199 of file SimulationTime.hpp.
Referenced by IncrementTimeOneStep(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetStartTime().
bool SimulationTime::mStartTimeSet [private] |
A flag allowing us to determine whether the start time of the simulation has been set.
Definition at line 205 of file SimulationTime.hpp.
Referenced by GetTime(), GetTimeStep(), IncrementTimeOneStep(), IsStartTimeSetUp(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), SetEndTimeAndNumberOfTimeSteps(), and SetStartTime().