#include <SimulationTime.hpp>
Inherits SerializableSingleton< SimulationTime >.
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 | IsEndTimeAndNumberOfTimeStepsSetUp () const |
bool | IsFinished () const |
void | SetStartTime (double startTime) |
Static Public Member Functions | |
static SimulationTime * | Instance () |
static void | Destroy () |
Protected Member Functions | |
SimulationTime () | |
Private Member Functions | |
template<class Archive > | |
void | serialize (Archive &archive, const unsigned int version) |
Private Attributes | |
double | mStartTime |
Static Private Attributes | |
static SimulationTime * | mpInstance = NULL |
static boost::shared_ptr < TimeStepper > | mpTimeStepper |
Friends | |
class | boost::serialization::access |
Simulation time object stores the simulation time. It uses the singleton pattern to provide a globally consistent time.
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 48 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 50 of file SimulationTime.cpp.
References mpInstance.
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 Instance(), and AbstractCellBasedTestSuite::tearDown().
double SimulationTime::GetTime | ( | ) | const |
Get the simulation time (in hours), should not have rounding errors.
Definition at line 85 of file SimulationTime.cpp.
References DOUBLE_UNSET, mpTimeStepper, and mStartTime.
Referenced by AbstractCellCycleModel::GetAge(), NagaiHondaForce< DIM >::GetTargetAreaOfCell(), Cell::GetTimeUntilDeath(), CellBasedPdeHandler< DIM >::OpenResultsFiles(), CryptSimulation2d::PostSolve(), AbstractSimpleCellCycleModel::ResetForDivision(), CellBasedSimulationArchiver< DIM, SIM >::Save(), CryptSimulation2d::SetupSolve(), SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), AbstractCellBasedSimulation< DIM >::Solve(), CellBasedPdeHandler< DIM >::SolvePdeAndWriteResultsToFile(), Cell::StartApoptosis(), ContactInhibitionCellCycleModel::UpdateCellCyclePhase(), AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase(), OnLatticeSimulation< DIM >::UpdateCellLocationsAndTopology(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), OffLatticeSimulation< DIM >::UpdateNodePositions(), AbstractCellPopulation< DIM >::WriteCellIdDataToFile(), MeshBasedCellPopulation< DIM >::WriteCellPopulationVolumeResultsToFile(), VertexBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), PottsBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), NodeBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), MeshBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), CaBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), DiscreteSystemForceCalculator::WriteResultsToFile(), VertexBasedCellPopulation< DIM >::WriteResultsToFiles(), PottsBasedCellPopulation< DIM >::WriteResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteResultsToFiles(), AbstractCellPopulation< DIM >::WriteResultsToFiles(), AbstractCentreBasedCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), AbstractCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), and MeshBasedCellPopulation< DIM >::WriteVoronoiResultsToFile().
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 67 of file SimulationTime.cpp.
References mpTimeStepper.
Referenced by CryptProjectionForce::CalculateForceBetweenNodes(), GeneralisedLinearSpringForce< DIM >::CalculateForceBetweenNodes(), CellCycleModelOdeHandler::GetDt(), CryptSimulation2d::PostSolve(), CellBasedPdeHandler< DIM >::SolvePdeAndWriteResultsToFile(), SimpleOxygenBasedCellCycleModel::UpdateCellCyclePhase(), and ContactInhibitionCellCycleModel::UpdateCellCyclePhase().
unsigned SimulationTime::GetTimeStepsElapsed | ( | ) | const |
Get the number of time steps that have elapsed.
Definition at line 79 of file SimulationTime.cpp.
References mpTimeStepper.
Referenced by CryptSimulation2d::PostSolve(), AbstractCellBasedSimulation< DIM >::Solve(), CellBasedPdeHandler< DIM >::SolvePdeAndWriteResultsToFile(), OnLatticeSimulation< DIM >::UpdateCellLocationsAndTopology(), VertexBasedCellPopulation< DIM >::WriteVtkResultsToFile(), PottsBasedCellPopulation< DIM >::WriteVtkResultsToFile(), NodeBasedCellPopulation< DIM >::WriteVtkResultsToFile(), MeshBasedCellPopulationWithGhostNodes< DIM >::WriteVtkResultsToFile(), and MeshBasedCellPopulation< DIM >::WriteVtkResultsToFile().
void SimulationTime::IncrementTimeOneStep | ( | ) |
Increment the simulation time by one time step.
GetTime() will return an updated current time after this call.
Definition at line 73 of file SimulationTime.cpp.
References mpTimeStepper.
Referenced by AbstractCellBasedSimulation< DIM >::Solve().
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 39 of file SimulationTime.cpp.
References Destroy(), mpInstance, and mpTimeStepper.
Referenced by CryptProjectionForce::CalculateForceBetweenNodes(), GeneralisedLinearSpringForce< DIM >::CalculateForceBetweenNodes(), Cell::Cell(), CellBasedPdeHandler< DIM >::CloseResultsFiles(), AbstractCellCycleModel::GetAge(), CellCycleModelOdeHandler::GetDt(), NagaiHondaForce< DIM >::GetTargetAreaOfCell(), Cell::GetTimeUntilDeath(), Cell::IsDead(), CellBasedPdeHandler< DIM >::OpenResultsFiles(), CryptSimulation2d::PostSolve(), AbstractSimpleCellCycleModel::ResetForDivision(), CellBasedSimulationArchiver< DIM, SIM >::Save(), AbstractCellBasedSimulation< DIM >::serialize(), AbstractCellCycleModel::serialize(), AbstractCellBasedTestSuite::setUp(), CryptSimulation2d::SetupSolve(), SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), AbstractCellBasedSimulation< DIM >::Solve(), CellBasedPdeHandler< DIM >::SolvePdeAndWriteResultsToFile(), Cell::StartApoptosis(), RandomCellKiller< DIM >::TestAndLabelSingleCellForApoptosis(), SingleOdeWntCellCycleModel::UpdateCellCyclePhase(), AbstractWntOdeBasedCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateCellCyclePhase(), DeltaNotchCellCycleModel::UpdateCellCyclePhase(), ContactInhibitionCellCycleModel::UpdateCellCyclePhase(), AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase(), OnLatticeSimulation< DIM >::UpdateCellLocationsAndTopology(), OnLatticeSimulation< DIM >::UpdateCellPopulation(), DeltaNotchCellCycleModel::UpdateDeltaNotch(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), OffLatticeSimulation< DIM >::UpdateNodePositions(), AbstractCellPopulation< DIM >::WriteCellIdDataToFile(), MeshBasedCellPopulation< DIM >::WriteCellPopulationVolumeResultsToFile(), VertexBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), PottsBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), NodeBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), MeshBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), CaBasedCellPopulation< DIM >::WriteCellVolumeResultsToFile(), DiscreteSystemForceCalculator::WriteResultsToFile(), VertexBasedCellPopulation< DIM >::WriteResultsToFiles(), PottsBasedCellPopulation< DIM >::WriteResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteResultsToFiles(), AbstractCellPopulation< DIM >::WriteResultsToFiles(), AbstractCentreBasedCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), AbstractCellPopulation< DIM >::WriteTimeAndNodeResultsToFiles(), MeshBasedCellPopulation< DIM >::WriteVoronoiResultsToFile(), VertexBasedCellPopulation< DIM >::WriteVtkResultsToFile(), PottsBasedCellPopulation< DIM >::WriteVtkResultsToFile(), NodeBasedCellPopulation< DIM >::WriteVtkResultsToFile(), MeshBasedCellPopulationWithGhostNodes< DIM >::WriteVtkResultsToFile(), and MeshBasedCellPopulation< DIM >::WriteVtkResultsToFile().
bool SimulationTime::IsEndTimeAndNumberOfTimeStepsSetUp | ( | ) | const |
Allows lower classes to check whether the simulation time class has been set up before using it
Definition at line 133 of file SimulationTime.cpp.
References mpTimeStepper.
Referenced by AbstractCellBasedSimulation< DIM >::Solve().
bool SimulationTime::IsFinished | ( | ) | const |
Definition at line 145 of file SimulationTime.cpp.
References mpTimeStepper.
Referenced by AbstractCellBasedSimulation< DIM >::Solve().
bool SimulationTime::IsStartTimeSetUp | ( | ) | const |
Allows lower classes to check whether the simulation time class has been set up before using it
Definition at line 128 of file SimulationTime.cpp.
References DOUBLE_UNSET, and mStartTime.
Referenced by CellBasedSimulationArchiver< DIM, SIM >::Save().
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 114 of file SimulationTime.cpp.
References DOUBLE_UNSET, mpTimeStepper, and mStartTime.
Referenced by AbstractCellBasedSimulation< DIM >::Solve().
void SimulationTime::serialize | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Serialization of a SimulationTime object must be done with care. Do not serialize this singleton directly. Instead, serialize the object returned by GetSerializationWrapper.
archive | the archive | |
version | the current version of this class |
Definition at line 183 of file SimulationTime.hpp.
References mpTimeStepper, and mStartTime.
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 104 of file SimulationTime.cpp.
References DOUBLE_UNSET, mpTimeStepper, and mStartTime.
Referenced by AbstractCellBasedSimulation< DIM >::Solve().
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 98 of file SimulationTime.cpp.
References DOUBLE_UNSET, and mStartTime.
Referenced by AbstractCellBasedTestSuite::setUp().
friend class boost::serialization::access [friend] |
Needed for serialization.
Reimplemented from SerializableSingleton< SimulationTime >.
Definition at line 172 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 157 of file SimulationTime.hpp.
Referenced by Destroy(), Instance(), and SimulationTime().
boost::shared_ptr< TimeStepper > SimulationTime::mpTimeStepper [static, private] |
Delegate all time stepping to a TimeStepper class
Shared pointer to the delegated class
Definition at line 163 of file SimulationTime.hpp.
Referenced by GetTime(), GetTimeStep(), GetTimeStepsElapsed(), IncrementTimeOneStep(), Instance(), IsEndTimeAndNumberOfTimeStepsSetUp(), IsFinished(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), and SetEndTimeAndNumberOfTimeSteps().
double SimulationTime::mStartTime [private] |
Stores the time at which the simulation started
Definition at line 168 of file SimulationTime.hpp.
Referenced by GetTime(), IsStartTimeSetUp(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), SetEndTimeAndNumberOfTimeSteps(), and SetStartTime().