Chaste Commit::f2ff7ee04e70ac9d06c57344df8d017dbb12b97b
SimulationTime Class Reference

#include <SimulationTime.hpp>

+ Inheritance diagram for SimulationTime:
+ Collaboration diagram for 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)
 
- Public Member Functions inherited from SerializableSingleton< SimulationTime >
SerializableSingleton< SimulationTime > * GetSerializationWrapper () const
 

Static Public Member Functions

static SimulationTimeInstance ()
 
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 SimulationTimempInstance = nullptr
 
static boost::shared_ptr< TimeSteppermpTimeStepper
 

Friends

class boost::serialization::access
 

Detailed Description

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 55 of file SimulationTime.hpp.

Constructor & Destructor Documentation

◆ SimulationTime()

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 57 of file SimulationTime.cpp.

References mpInstance.

Referenced by Instance().

Member Function Documentation

◆ Destroy()

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 65 of file SimulationTime.cpp.

References mpInstance.

Referenced by Instance(), and AbstractCellBasedTestSuite::tearDown().

◆ GetTime()

double SimulationTime::GetTime ( ) const

Get the simulation time (in hours), should not have rounding errors.

Returns
simulation time

Definition at line 92 of file SimulationTime.cpp.

References DOUBLE_UNSET, mpTimeStepper, and mStartTime.

Referenced by SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), T2SwapCellKiller< DIM >::CheckAndLabelCellsForApoptosisOrDeath(), AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::DoCellBirth(), AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::GenerateRemovalInformation(), AbstractCellCycleModel::GetAge(), AbstractCellBasedSimulation< ELEMENT_DIM, ELEMENT_DIM >::GetOutputCellVelocities(), Cell::GetTimeUntilDeath(), AbstractOdeBasedCellCycleModel::ReadyToDivide(), AbstractCellCycleModel::ResetForDivision(), CellBasedSimulationArchiver< ELEMENT_DIM, SIM, SPACE_DIM >::Save(), AbstractOdeSrnModel::SimulateToCurrentTime(), NullSrnModel::SimulateToCurrentTime(), Cell::StartApoptosis(), AbstractPdeModifier< DIM >::UpdateAtEndOfOutputTimeStep(), ParabolicBoxDomainPdeModifier< DIM >::UpdateAtEndOfTimeStep(), ParabolicGrowingDomainPdeModifier< DIM >::UpdateAtEndOfTimeStep(), AbstractOdeBasedPhaseBasedCellCycleModel::UpdateCellCyclePhase(), ContactInhibitionCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), NormallyDistributedTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), SimpleTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), TargetAreaLinearGrowthModifier< DIM >::UpdateTargetAreaOfCell(), DiscreteSystemForceCalculator::WriteResultsToFile(), and AbstractCellBasedWriter< ELEMENT_DIM, SPACE_DIM >::WriteTimeStamp().

◆ GetTimeStep()

◆ GetTimeStepsElapsed()

◆ IncrementTimeOneStep()

void SimulationTime::IncrementTimeOneStep ( )

Increment the simulation time by one time step.

GetTime() will return an updated current time after this call.

Definition at line 80 of file SimulationTime.cpp.

References mpTimeStepper.

◆ Instance()

SimulationTime * SimulationTime::Instance ( )
static
Returns
a pointer to the simulation time object. The first time this is called the simulation time object is created.

Definition at line 46 of file SimulationTime.cpp.

References SimulationTime(), Destroy(), mpInstance, and mpTimeStepper.

Referenced by Cell::Cell(), SimpleOxygenBasedCellCycleModel::SimpleOxygenBasedCellCycleModel(), DiffusionForce< DIM >::AddForceContribution(), ImmersedBoundarySimulationModifier< DIM >::AddNormalNoise(), CryptProjectionForce::CalculateForceBetweenNodes(), ImmersedBoundaryKinematicFeedbackForce< DIM >::CalculateRelativeVelocityComponent(), T2SwapCellKiller< DIM >::CheckAndLabelCellsForApoptosisOrDeath(), RandomCellKiller< DIM >::CheckAndLabelSingleCellForApoptosis(), AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::DoCellBirth(), AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::GenerateRemovalInformation(), AbstractCellCycleModel::GetAge(), VertexBasedCellPopulation< DIM >::GetDampingConstant(), CellCycleModelOdeHandler::GetDt(), Cell::GetTimeUntilDeath(), Cell::IsDead(), AbstractOdeBasedCellCycleModel::ReadyToDivide(), BernoulliTrialCellCycleModel::ReadyToDivide(), BiasedBernoulliTrialCellCycleModel::ReadyToDivide(), LabelDependentBernoulliTrialCellCycleModel::ReadyToDivide(), AbstractCellCycleModel::ResetForDivision(), AbstractSrnModel::ResetForDivision(), CellSrnModel::ResetForDivision(), MeshBasedCellPopulation< DIM >::rGetMesh(), CellBasedSimulationArchiver< ELEMENT_DIM, SIM, SPACE_DIM >::Save(), AbstractCellCycleModel::serialize(), AbstractSrnModel::serialize(), AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::serialize(), AbstractCellBasedTestSuite::setUp(), ImmersedBoundarySimulationModifier< DIM >::SetupConstantMemberVariables(), AbstractOdeSrnModel::SimulateToCurrentTime(), NullSrnModel::SimulateToCurrentTime(), ImmersedBoundarySimulationModifier< DIM >::SolveNavierStokesSpectral(), Cell::StartApoptosis(), NodeBasedCellPopulation< DIM >::Update(), AbstractPdeModifier< DIM >::UpdateAtEndOfOutputTimeStep(), ParabolicBoxDomainPdeModifier< DIM >::UpdateAtEndOfTimeStep(), ParabolicGrowingDomainPdeModifier< DIM >::UpdateAtEndOfTimeStep(), ExtrinsicPullModifier< DIM >::UpdateAtEndOfTimeStep(), ImmersedBoundarySimulationModifier< DIM >::UpdateAtEndOfTimeStep(), ImmersedBoundarySvgWriter< DIM >::UpdateAtEndOfTimeStep(), AbstractOdeBasedPhaseBasedCellCycleModel::UpdateCellCyclePhase(), ContactInhibitionCellCycleModel::UpdateCellCyclePhase(), SimpleOxygenBasedCellCycleModel::UpdateCellCyclePhase(), AbstractWntOdeBasedCellCycleModel::UpdateCellCyclePhase(), SingleOdeWntCellCycleModel::UpdateCellCyclePhase(), AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::UpdateCellPopulation(), OnLatticeSimulation< DIM >::UpdateCellPopulation(), SimpleOxygenBasedCellCycleModel::UpdateHypoxicDuration(), ImmersedBoundaryCellPopulation< DIM >::UpdateNodeLocations(), NormallyDistributedTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), SimpleTargetAreaModifier< DIM >::UpdateTargetAreaOfCell(), TargetAreaLinearGrowthModifier< DIM >::UpdateTargetAreaOfCell(), ImmersedBoundaryCellPopulation< DIM >::Validate(), NodeBasedCellPopulation< DIM >::Validate(), PottsBasedCellPopulation< DIM >::Validate(), VertexBasedCellPopulation< DIM >::Validate(), NodeVelocityWriter< ELEMENT_DIM, SPACE_DIM >::Visit(), NodeVelocityWriter< ELEMENT_DIM, SPACE_DIM >::Visit(), NodeVelocityWriter< ELEMENT_DIM, SPACE_DIM >::Visit(), VertexBasedCellPopulation< DIM >::WriteCellEdgeVtkResultsToFile(), VertexBasedCellPopulation< DIM >::WriteCellVtkResultsToFile(), DiscreteSystemForceCalculator::WriteResultsToFile(), MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM >::WriteResultsToFiles(), AbstractCellBasedWriter< ELEMENT_DIM, SPACE_DIM >::WriteTimeStamp(), CaBasedCellPopulation< DIM >::WriteVtkResultsToFile(), ImmersedBoundaryCellPopulation< DIM >::WriteVtkResultsToFile(), MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM >::WriteVtkResultsToFile(), MeshBasedCellPopulationWithGhostNodes< DIM >::WriteVtkResultsToFile(), NodeBasedCellPopulation< DIM >::WriteVtkResultsToFile(), NodeBasedCellPopulationWithParticles< DIM >::WriteVtkResultsToFile(), and PottsBasedCellPopulation< DIM >::WriteVtkResultsToFile().

◆ IsEndTimeAndNumberOfTimeStepsSetUp()

bool SimulationTime::IsEndTimeAndNumberOfTimeStepsSetUp ( ) const

Allows lower classes to check whether the simulation time class has been set up before using it

Returns
whether the end time of the simulation and the number of timesteps has been set.

Definition at line 141 of file SimulationTime.cpp.

References mpTimeStepper.

◆ IsFinished()

bool SimulationTime::IsFinished ( ) const
Returns
whether the simulation has finished.

Definition at line 153 of file SimulationTime.cpp.

References mpTimeStepper.

◆ IsStartTimeSetUp()

bool SimulationTime::IsStartTimeSetUp ( ) const

Allows lower classes to check whether the simulation time class has been set up before using it

Returns
whether the start time of the simulation has been set.

Definition at line 136 of file SimulationTime.cpp.

References DOUBLE_UNSET, and mStartTime.

Referenced by CellBasedSimulationArchiver< ELEMENT_DIM, SIM, SPACE_DIM >::Save().

◆ ResetEndTimeAndNumberOfTimeSteps()

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.

Parameters
rEndTimethe 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)
rNumberOfTimeStepsInThisRunthe number of time steps into which the next run is split

Definition at line 122 of file SimulationTime.cpp.

References DOUBLE_UNSET, mpTimeStepper, and mStartTime.

Referenced by AbstractCellBasedSimulation< ELEMENT_DIM, ELEMENT_DIM >::SetEndTime().

◆ serialize()

template<class Archive >
void SimulationTime::serialize ( Archive &  archive,
const unsigned int  version 
)
inlineprivate

Serialization of a SimulationTime object must be done with care. Do not serialize this singleton directly. Instead, serialize the object returned by GetSerializationWrapper.

Parameters
archivethe archive
versionthe current version of this class

Definition at line 187 of file SimulationTime.hpp.

References mpTimeStepper, and mStartTime.

◆ SetEndTimeAndNumberOfTimeSteps()

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.

Parameters
endTimetime at which to end this run of the simulation
totalTimeStepsInSimulationthe number of time steps into which the above will be divided

Definition at line 111 of file SimulationTime.cpp.

References DOUBLE_UNSET, mpTimeStepper, and mStartTime.

Referenced by AbstractCellBasedSimulation< ELEMENT_DIM, ELEMENT_DIM >::SetSamplingTimestepMultiple().

◆ SetStartTime()

void SimulationTime::SetStartTime ( double  startTime)

Set the start time of the simulation

Parameters
startTimethe time at which the simulation begins (usually 0.0 hours)

Definition at line 105 of file SimulationTime.cpp.

References DOUBLE_UNSET, and mStartTime.

Referenced by AbstractCellBasedTestSuite::setUp().

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Needed for serialization.

Definition at line 176 of file SimulationTime.hpp.

Member Data Documentation

◆ mpInstance

SimulationTime * SimulationTime::mpInstance = nullptr
staticprivate

A pointer to the singleton instance of this class.

Pointer to the single instance

Definition at line 163 of file SimulationTime.hpp.

Referenced by SimulationTime(), Destroy(), and Instance().

◆ mpTimeStepper

boost::shared_ptr< TimeStepper > SimulationTime::mpTimeStepper
staticprivate

◆ mStartTime

double SimulationTime::mStartTime
private

Stores the time at which the simulation started

Definition at line 173 of file SimulationTime.hpp.

Referenced by GetTime(), IsStartTimeSetUp(), ResetEndTimeAndNumberOfTimeSteps(), serialize(), SetEndTimeAndNumberOfTimeSteps(), and SetStartTime().


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