CellBasedSimulation< DIM > Class Template Reference

#include <CellBasedSimulation.hpp>

Inheritance diagram for CellBasedSimulation< DIM >:

Inheritance graph
[legend]
Collaboration diagram for CellBasedSimulation< DIM >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CellBasedSimulation (AbstractCellPopulation< DIM > &rCellPopulation, bool deleteCellPopulationAndForceCollection=false, bool initialiseCells=true)
virtual ~CellBasedSimulation ()
std::vector< double > GetNodeLocation (const unsigned &rNodeIndex)
double GetDt ()
unsigned GetNumBirths ()
unsigned GetNumDeaths ()
std::string GetOutputDirectory ()
void SetDt (double dt)
void SetEndTime (double endTime)
void SetOutputDirectory (std::string outputDirectory)
void SetSamplingTimestepMultiple (unsigned samplingTimestepMultiple)
void SetNoBirth (bool noBirth)
void SetUpdateCellPopulationRule (bool updateCellPopulation)
void AddCellKiller (AbstractCellKiller< DIM > *pCellKiller)
void AddForce (AbstractForce< DIM > *pForce)
void AddCellPopulationBoundaryCondition (AbstractCellPopulationBoundaryCondition< DIM > *pBoundaryCondition)
void Solve ()
AbstractCellPopulation< DIM > & rGetCellPopulation ()
const AbstractCellPopulation
< DIM > & 
rGetCellPopulation () const
bool GetOutputNodeVelocities ()
void SetOutputNodeVelocities (bool outputNodeVelocities)
virtual void OutputSimulationParameters (out_stream &rParamsFile)

Protected Member Functions

template<class Archive>
void serialize (Archive &archive, const unsigned int version)
virtual void WriteVisualizerSetupFile ()
virtual unsigned DoCellBirth ()
virtual c_vector< double, DIM > CalculateCellDivisionVector (CellPtr pParentCell)
unsigned DoCellRemoval ()
virtual void UpdateNodePositions (const std::vector< c_vector< double, DIM > > &rNodeForces)
virtual void ApplyCellPopulationBoundaryConditions (const std::vector< c_vector< double, DIM > > &rOldLocations)
virtual void PostSolve ()
virtual void SetupSolve ()
virtual void AfterSolve ()
virtual bool StoppingEventHasOccurred ()
void UpdateCellPopulation ()
void OutputSimulationSetup ()

Protected Attributes

double mDt
double mEndTime
AbstractCellPopulation< DIM > & mrCellPopulation
bool mDeleteCellPopulationAndForcesAndBCsInDestructor
bool mInitialiseCells
bool mNoBirth
bool mUpdateCellPopulation
std::string mOutputDirectory
std::string mSimulationOutputDirectory
out_stream mpVizSetupFile
out_stream mpNodeVelocitiesFile
RandomNumberGeneratormpRandomGenerator
unsigned mNumBirths
unsigned mNumDeaths
unsigned mSamplingTimestepMultiple
std::vector
< AbstractCellKiller< DIM > * > 
mCellKillers
std::vector< AbstractForce
< DIM > * > 
mForceCollection
std::vector
< AbstractCellPopulationBoundaryCondition
< DIM > * > 
mBoundaryConditions
bool mOutputNodeVelocities

Friends

class TestCryptSimulation2d
class TestCellBasedSimulation3d
class TestCellBasedSimulation
class boost::serialization::access


Detailed Description

template<unsigned DIM>
class CellBasedSimulation< DIM >

Run an off-lattice 2D or 3D cell-based simulation using a cell-centre- or vertex-based cell population.

In cell-centre-based cell populations, each cell is represented by a single node (corresponding to its centre), and connectivity is defined either by a Delaunay triangulation or a radius of influence. In vertex- based cell populations, each cell is represented by a polytope (corresponding to its membrane) with a variable number of vertices.

The CellBasedSimulation is constructed with a CellPopulation, which updates the correspondence between each Cell and its spatial representation and handles cell division (governed by the CellCycleModel associated with each cell). Once constructed, one or more Force laws may be passed to the CellBasedSimulation object, to define the mechanical properties of the CellPopulation. Similarly, one or more CellKillers may be passed to the CellBasedSimulation object to specify conditions in which Cells may die, and one or more CellPopulationBoundaryConditions to specify regions in space beyond which Cells may not move.

Definition at line 65 of file CellBasedSimulation.hpp.


Constructor & Destructor Documentation

template<unsigned DIM>
CellBasedSimulation< DIM >::CellBasedSimulation ( AbstractCellPopulation< DIM > &  rCellPopulation,
bool  deleteCellPopulationAndForceCollection = false,
bool  initialiseCells = true 
) [inline]

Constructor.

Parameters:
rCellPopulation A cell population object
deleteCellPopulationAndForceCollection Whether to delete the cell population and force collection on destruction to free up memory
initialiseCells Whether to initialise cells (set to false when loading from an archive)

Definition at line 45 of file CellBasedSimulation.cpp.

References RandomNumberGenerator::Instance(), CellBasedSimulation< DIM >::mDt, CellBasedSimulation< DIM >::mInitialiseCells, CellBasedSimulation< DIM >::mpRandomGenerator, and CellBasedSimulation< DIM >::mrCellPopulation.

template<unsigned DIM>
CellBasedSimulation< DIM >::~CellBasedSimulation (  )  [inline, virtual]


Member Function Documentation

template<unsigned DIM>
template<class Archive>
void CellBasedSimulation< DIM >::serialize ( Archive &  archive,
const unsigned int  version 
) [inline, protected]

Archive the member variables.

Serialization of singleton objects 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.

Parameters:
archive the archive
version the current version of this class

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation1d, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 149 of file CellBasedSimulation.hpp.

template<unsigned DIM>
virtual void CellBasedSimulation< DIM >::WriteVisualizerSetupFile (  )  [inline, protected, virtual]

Writes out special information about the mesh to the visualizer.

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 174 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::DoCellBirth (  )  [inline, protected, virtual]

During a simulation time step, process any cell divisions that need to occur. If the simulation includes cell birth, causes (almost) all cells that are ready to divide to produce daughter cells.

Returns:
the number of births that occurred.

Definition at line 113 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::CalculateCellDivisionVector(), CellBasedSimulation< DIM >::mNoBirth, and CellBasedSimulation< DIM >::mrCellPopulation.

Referenced by CellBasedSimulation< DIM >::UpdateCellPopulation().

template<unsigned DIM>
c_vector< double, DIM > CellBasedSimulation< DIM >::CalculateCellDivisionVector ( CellPtr  pParentCell  )  [inline, protected, virtual]

Method for determining how cell division occurs. This method returns a vector which is then passed into the CellPopulation method AddCell(). This method may be overridden by subclasses.

For a centre-based cell population, this method calculates the new locations of the cell centres of a dividing cell, moves the parent cell and returns the location of the daughter cell. The new locations are found by picking a random direction and placing the parent and daughter in opposing directions along this axis.

For a vertex-based cell population, the method returns the zero vector.

Parameters:
pParentCell the parent cell
Returns:
a vector containing information on cell division.

Todo:
Could remove this dynamic_cast by moving the code block below into AbstractCentreBasedCellPopulation::AddCell(), allowing it to be overruled by this method when overridden in subclasses. See also comment on #1093.

Reimplemented in CryptSimulation1d, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 171 of file CellBasedSimulation.cpp.

References RandomNumberGenerator::Instance(), CellBasedSimulation< DIM >::mrCellPopulation, NEVER_REACHED, and RandomNumberGenerator::ranf().

Referenced by CellBasedSimulation< DIM >::DoCellBirth().

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::DoCellRemoval (  )  [inline, protected]

During a simulation time step, process any cell sloughing or death

This uses the cell killers to remove cells and associated nodes from the facade class.

Returns:
the number of deaths that occurred.

Definition at line 151 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mCellKillers, and CellBasedSimulation< DIM >::mrCellPopulation.

Referenced by CellBasedSimulation< DIM >::UpdateCellPopulation().

template<unsigned DIM>
void CellBasedSimulation< DIM >::UpdateNodePositions ( const std::vector< c_vector< double, DIM > > &  rNodeForces  )  [inline, protected, virtual]

template<unsigned DIM>
virtual void CellBasedSimulation< DIM >::ApplyCellPopulationBoundaryConditions ( const std::vector< c_vector< double, DIM > > &  rOldLocations  )  [inline, protected, virtual]

Apply any cell population boundary conditions. Can be overridden in subclasses.

Todo:
#1589 this should be removed
Parameters:
rOldLocations the node locations before any boundary conditions are applied

Definition at line 231 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::UpdateNodePositions().

template<unsigned DIM>
virtual void CellBasedSimulation< DIM >::PostSolve (  )  [inline, protected, virtual]

A method for subclasses to do something at the end of each timestep

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 238 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
virtual void CellBasedSimulation< DIM >::SetupSolve (  )  [inline, protected, virtual]

A method for subclasses to do something at before the start of the time loop.

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 245 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
virtual void CellBasedSimulation< DIM >::AfterSolve (  )  [inline, protected, virtual]

This method may be overridden in subclasses to do something at the end of each time loop.

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 253 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
bool CellBasedSimulation< DIM >::StoppingEventHasOccurred (  )  [inline, protected, virtual]

A child class can overload this if they want the simulation to stop based on certain conditions before the specified end time (for example, run until a crypt becomes monoclonal).

Definition at line 633 of file CellBasedSimulation.cpp.

Referenced by CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
void CellBasedSimulation< DIM >::UpdateCellPopulation (  )  [inline, protected]

template<unsigned DIM>
void CellBasedSimulation< DIM >::OutputSimulationSetup (  )  [inline, protected]

template<unsigned DIM>
std::vector< double > CellBasedSimulation< DIM >::GetNodeLocation ( const unsigned &  rNodeIndex  )  [inline]

Get a node's location (ONLY FOR TESTING).

Parameters:
rNodeIndex the node index
Returns:
the co-ordinates of this node.

Definition at line 443 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mrCellPopulation.

template<unsigned DIM>
double CellBasedSimulation< DIM >::GetDt (  )  [inline]

Returns:
the timestep of the simulation

Definition at line 345 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mDt.

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::GetNumBirths (  )  [inline]

Returns:
the number of births that have occurred in the entire simulation (since t=0)

Definition at line 352 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mNumBirths.

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::GetNumDeaths (  )  [inline]

Returns:
the number of deaths that have occurred in the entire simulation (since t=0).

Definition at line 359 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mNumDeaths.

template<unsigned DIM>
std::string CellBasedSimulation< DIM >::GetOutputDirectory (  )  [inline]

Get the output directory of the simulation.

Definition at line 382 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mOutputDirectory.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetDt ( double  dt  )  [inline]

Set the timestep of the simulation.

Parameters:
dt the timestep to use

Definition at line 337 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mDt.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetEndTime ( double  endTime  )  [inline]

Set the end time and resets the timestep to be endtime/100.

Parameters:
endTime the end time to use

Definition at line 366 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mEndTime.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetOutputDirectory ( std::string  outputDirectory  )  [inline]

Set the output directory of the simulation.

Parameters:
outputDirectory the output directory to use

Definition at line 374 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mOutputDirectory, and CellBasedSimulation< DIM >::mSimulationOutputDirectory.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetSamplingTimestepMultiple ( unsigned  samplingTimestepMultiple  )  [inline]

Set the ratio of the number of actual timesteps to the number of timesteps at which results are written to file. Default value is set to 1 by the constructor.

Parameters:
samplingTimestepMultiple the ratio to use

Definition at line 388 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mSamplingTimestepMultiple.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetNoBirth ( bool  noBirth  )  [inline]

Set the simulation to run with no birth.

Parameters:
noBirth whether to run with no birth

Definition at line 417 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mNoBirth.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetUpdateCellPopulationRule ( bool  updateCellPopulation  )  [inline]

Set whether to update the topology of the cell population at each time step.

Parameters:
updateCellPopulation whether to update the cell population each time step

Definition at line 410 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mUpdateCellPopulation.

template<unsigned DIM>
void CellBasedSimulation< DIM >::AddCellKiller ( AbstractCellKiller< DIM > *  pCellKiller  )  [inline]

Add a cell killer to be used in this simulation.

Parameters:
pCellKiller pointer to a cell killer

Definition at line 424 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mCellKillers.

template<unsigned DIM>
void CellBasedSimulation< DIM >::AddForce ( AbstractForce< DIM > *  pForce  )  [inline]

Add a force to be used in this simulation (use this to set the mechanics system).

Parameters:
pForce pointer to a force law

Definition at line 430 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mForceCollection.

template<unsigned DIM>
void CellBasedSimulation< DIM >::AddCellPopulationBoundaryCondition ( AbstractCellPopulationBoundaryCondition< DIM > *  pBoundaryCondition  )  [inline]

Add a cell population boundary condition to be used in this simulation.

Parameters:
pBoundaryCondition pointer to a boundary condition

Definition at line 436 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mBoundaryConditions.

template<unsigned DIM>
void CellBasedSimulation< DIM >::Solve (  )  [inline]

Main solve method.

This method sets up the simulation time, creates output files, and initialises the cell population. It then iterates through a time loop. At each time step, first any cell death or birth is implemented, then the cell population topology is updated, then the forces are recalculated and the cell population evolved according to whatever force laws are present in the simulation, and finally the results for that time step are output to file. At the end of the time loop, the method closes any output files.

This function calls: DoCellRemoval() DoCellBirth() CellPopulation::Update()

Definition at line 455 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::AfterSolve(), GenericEventHandler< 9, CellBasedEventHandler >::BeginEvent(), GenericEventHandler< 9, CellBasedEventHandler >::EndEvent(), EXCEPTION, SimulationTime::GetTime(), SimulationTime::GetTimeStepsElapsed(), SimulationTime::IncrementTimeOneStep(), SimulationTime::Instance(), CellBasedSimulation< DIM >::mDt, CellBasedSimulation< DIM >::mEndTime, CellBasedSimulation< DIM >::mForceCollection, CellBasedSimulation< DIM >::mOutputDirectory, CellBasedSimulation< DIM >::mOutputNodeVelocities, CellBasedSimulation< DIM >::mpNodeVelocitiesFile, CellBasedSimulation< DIM >::mpVizSetupFile, CellBasedSimulation< DIM >::mrCellPopulation, CellBasedSimulation< DIM >::mSamplingTimestepMultiple, CellBasedSimulation< DIM >::mSimulationOutputDirectory, OutputFileHandler::OpenOutputFile(), CellBasedSimulation< DIM >::OutputSimulationSetup(), CellBasedSimulation< DIM >::PostSolve(), SimulationTime::ResetEndTimeAndNumberOfTimeSteps(), SimulationTime::SetEndTimeAndNumberOfTimeSteps(), CellBasedSimulation< DIM >::SetupSolve(), CellBasedSimulation< DIM >::StoppingEventHasOccurred(), CellBasedSimulation< DIM >::UpdateCellPopulation(), CellBasedSimulation< DIM >::UpdateNodePositions(), and CellBasedSimulation< DIM >::WriteVisualizerSetupFile().

template<unsigned DIM>
AbstractCellPopulation< DIM > & CellBasedSimulation< DIM >::rGetCellPopulation (  )  [inline]

Returns:
reference to the cell population.

Definition at line 396 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mrCellPopulation.

template<unsigned DIM>
const AbstractCellPopulation< DIM > & CellBasedSimulation< DIM >::rGetCellPopulation (  )  const [inline]

Returns:
const reference to the cell population (used in archiving).

Definition at line 403 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mrCellPopulation.

template<unsigned DIM>
bool CellBasedSimulation< DIM >::GetOutputNodeVelocities (  )  [inline]

Returns:
mOutputNodeVelocities

Definition at line 746 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mOutputNodeVelocities.

template<unsigned DIM>
void CellBasedSimulation< DIM >::SetOutputNodeVelocities ( bool  outputNodeVelocities  )  [inline]

Set mOutputNodeVelocities.

Parameters:
outputNodeVelocities the new value of mOutputNodeVelocities

Definition at line 752 of file CellBasedSimulation.cpp.

References CellBasedSimulation< DIM >::mOutputNodeVelocities.

template<unsigned DIM>
void CellBasedSimulation< DIM >::OutputSimulationParameters ( out_stream &  rParamsFile  )  [inline, virtual]


Friends And Related Function Documentation

template<unsigned DIM>
friend class boost::serialization::access [friend]

Needed for serialization.

Reimplemented in CellBasedSimulationWithPdes< DIM >, CryptSimulation1d, CryptSimulation2d, and VertexCryptSimulation2d.

Definition at line 136 of file CellBasedSimulation.hpp.


Member Data Documentation

template<unsigned DIM>
double CellBasedSimulation< DIM >::mDt [protected]

template<unsigned DIM>
double CellBasedSimulation< DIM >::mEndTime [protected]

template<unsigned DIM>
AbstractCellPopulation<DIM>& CellBasedSimulation< DIM >::mrCellPopulation [protected]

template<unsigned DIM>
bool CellBasedSimulation< DIM >::mDeleteCellPopulationAndForcesAndBCsInDestructor [protected]

Whether to delete the cell population, force laws and boundary conditions in the destructor.

Definition at line 85 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::~CellBasedSimulation().

template<unsigned DIM>
bool CellBasedSimulation< DIM >::mInitialiseCells [protected]

Whether to initialise the cells.

Definition at line 88 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::CellBasedSimulation().

template<unsigned DIM>
bool CellBasedSimulation< DIM >::mNoBirth [protected]

Whether to run the simulation with no birth (defaults to false).

Definition at line 91 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::DoCellBirth(), CellBasedSimulation< 2 >::serialize(), and CellBasedSimulation< DIM >::SetNoBirth().

template<unsigned DIM>
bool CellBasedSimulation< DIM >::mUpdateCellPopulation [protected]

Whether to update the topology of the cell population at each time step (defaults to true).

Definition at line 94 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< 2 >::serialize(), CellBasedSimulation< DIM >::SetUpdateCellPopulationRule(), and CellBasedSimulation< DIM >::UpdateCellPopulation().

template<unsigned DIM>
std::string CellBasedSimulation< DIM >::mOutputDirectory [protected]

template<unsigned DIM>
std::string CellBasedSimulation< DIM >::mSimulationOutputDirectory [protected]

Simulation Output directory either the same as mOutputDirectory or includes mOutputDirectory/results_from_time_[TIME].

Definition at line 100 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::OutputSimulationSetup(), CellBasedSimulation< DIM >::SetOutputDirectory(), CellBasedSimulationWithPdes< DIM >::SetupWritePdeSolution(), and CellBasedSimulation< DIM >::Solve().

template<unsigned DIM>
out_stream CellBasedSimulation< DIM >::mpVizSetupFile [protected]

template<unsigned DIM>
out_stream CellBasedSimulation< DIM >::mpNodeVelocitiesFile [protected]

Results file node velocities.

Definition at line 106 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::Solve(), and CellBasedSimulation< DIM >::UpdateNodePositions().

template<unsigned DIM>
RandomNumberGenerator* CellBasedSimulation< DIM >::mpRandomGenerator [protected]

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::mNumBirths [protected]

Counts the number of births during the simulation.

Definition at line 112 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::GetNumBirths(), CellBasedSimulation< 2 >::serialize(), and CellBasedSimulation< DIM >::UpdateCellPopulation().

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::mNumDeaths [protected]

Counts the number of deaths during the simulation.

Definition at line 115 of file CellBasedSimulation.hpp.

Referenced by CellBasedSimulation< DIM >::GetNumDeaths(), CellBasedSimulation< 2 >::serialize(), and CellBasedSimulation< DIM >::UpdateCellPopulation().

template<unsigned DIM>
unsigned CellBasedSimulation< DIM >::mSamplingTimestepMultiple [protected]

template<unsigned DIM>
std::vector<AbstractCellKiller<DIM>*> CellBasedSimulation< DIM >::mCellKillers [protected]

template<unsigned DIM>
std::vector<AbstractForce<DIM>*> CellBasedSimulation< DIM >::mForceCollection [protected]

template<unsigned DIM>
std::vector<AbstractCellPopulationBoundaryCondition<DIM>*> CellBasedSimulation< DIM >::mBoundaryConditions [protected]

template<unsigned DIM>
bool CellBasedSimulation< DIM >::mOutputNodeVelocities [protected]


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

Generated on Mon Apr 18 11:36:39 2011 for Chaste by  doxygen 1.5.5