TissueSimulation< DIM > Class Template Reference

#include <TissueSimulation.hpp>

Collaboration diagram for TissueSimulation< DIM >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TissueSimulation (AbstractTissue< DIM > &rTissue, std::vector< AbstractForce< DIM > * > forceCollection, bool deleteTissueAndForceCollection=false, bool initialiseCells=true)
virtual ~TissueSimulation ()
std::vector< doubleGetNodeLocation (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 SetUpdateTissueRule (bool updateTissue)
void AddCellKiller (AbstractCellKiller< DIM > *pCellKiller)
void Solve ()
AbstractTissue< DIM > & rGetTissue ()
const AbstractTissue< DIM > & rGetTissue () const
const std::vector
< AbstractForce< DIM > * > 
rGetForceCollection () const

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 (TissueCell &rParentCell)
unsigned DoCellRemoval ()
virtual void UpdateNodePositions (const std::vector< c_vector< double, DIM > > &rNodeForces)
virtual void ApplyTissueBoundaryConditions (const std::vector< c_vector< double, DIM > > &rOldLocations)
virtual void PostSolve ()
virtual void SetupSolve ()
virtual void AfterSolve ()
virtual bool StoppingEventHasOccurred ()
void UpdateTissue ()

Protected Attributes

double mDt
double mEndTime
AbstractTissue< DIM > & mrTissue
bool mDeleteTissue
bool mAllocatedMemoryForForceCollection
bool mInitialiseCells
bool mNoBirth
bool mUpdateTissue
std::string mOutputDirectory
std::string mSimulationOutputDirectory
out_stream mpSetupFile
out_stream mpNodeVelocitiesFile
TissueConfigmpConfig
RandomNumberGeneratormpRandomGenerator
unsigned mNumBirths
unsigned mNumDeaths
unsigned mSamplingTimestepMultiple
std::vector
< AbstractCellKiller< DIM > * > 
mCellKillers
std::vector< AbstractForce
< DIM > * > 
mForceCollection

Friends

class TestCryptSimulation2d
class TestTissueSimulation3d
class boost::serialization::access

Detailed Description

template<unsigned DIM>
class TissueSimulation< DIM >

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

In cell-centre-based tissues, 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 tissues, each cell is represented by a polytope (corresponding to its membrane) with a variable number of vertices.

The TissueSimulation is constructed with a Tissue, which updates the correspondence between each TissueCell and its spatial representation and handles cell division (governed by the CellCycleModel associated with each cell); and one or more Force laws, which define the mechanical properties of the Tissue. It is also possible to add one or more CellKiller objects to the TissueSimulation, which specify the conditions under which a TissueCell dies.

Definition at line 60 of file TissueSimulation.hpp.


Constructor & Destructor Documentation

template<unsigned DIM>
TissueSimulation< DIM >::TissueSimulation ( AbstractTissue< DIM > &  rTissue,
std::vector< AbstractForce< DIM > * >  forceCollection,
bool  deleteTissueAndForceCollection = false,
bool  initialiseCells = true 
) [inline]

Constructor.

Parameters:
rTissue A tissue facade class (contains a mesh and cells)
forceCollection The mechanics to use in the simulation
deleteTissueAndForceCollection Whether to delete the tissue 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 40 of file TissueSimulation.cpp.

References RandomNumberGenerator::Instance(), TissueConfig::Instance(), TissueSimulation< DIM >::mDt, TissueSimulation< DIM >::mInitialiseCells, TissueSimulation< DIM >::mpConfig, TissueSimulation< DIM >::mpRandomGenerator, and TissueSimulation< DIM >::mrTissue.

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

Member Function Documentation

template<unsigned DIM>
void TissueSimulation< 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 403 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mCellKillers.

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

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

Reimplemented in CryptSimulation2d.

Definition at line 248 of file TissueSimulation.hpp.

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

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

Apply any tissue boundary conditions. Can be overridden in subclasses.

Parameters:
rOldLocations the node locations before any boundary conditions are applied

Definition at line 226 of file TissueSimulation.hpp.

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

template<unsigned DIM>
c_vector< double, DIM > TissueSimulation< DIM >::CalculateCellDivisionVector ( TissueCell rParentCell  )  [inline, protected, virtual]

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

For a cell-centre tissue, 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 tissue, the method returns the zero vector.

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

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

Reimplemented in CryptSimulation1d, and CryptSimulation2d.

Definition at line 172 of file TissueSimulation.cpp.

References TissueConfig::GetDivisionSeparation(), RandomNumberGenerator::Instance(), TissueConfig::Instance(), TissueSimulation< DIM >::mrTissue, and RandomNumberGenerator::ranf().

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

template<unsigned DIM>
unsigned TissueSimulation< 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 107 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::CalculateCellDivisionVector(), TissueSimulation< DIM >::mNoBirth, and TissueSimulation< DIM >::mrTissue.

Referenced by TissueSimulation< DIM >::UpdateTissue().

template<unsigned DIM>
unsigned TissueSimulation< 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 145 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mCellKillers, and TissueSimulation< DIM >::mrTissue.

Referenced by TissueSimulation< DIM >::UpdateTissue().

template<unsigned DIM>
double TissueSimulation< DIM >::GetDt (  )  [inline]
Returns:
the timestep of the simulation

Definition at line 324 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mDt.

template<unsigned DIM>
std::vector< double > TissueSimulation< 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 410 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mrTissue.

template<unsigned DIM>
unsigned TissueSimulation< DIM >::GetNumBirths (  )  [inline]
Returns:
the number of births that have occurred in the entire simulation (since t=0)

Definition at line 331 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mNumBirths.

template<unsigned DIM>
unsigned TissueSimulation< DIM >::GetNumDeaths (  )  [inline]
Returns:
the number of deaths that have occurred in the entire simulation (since t=0).

Definition at line 338 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mNumDeaths.

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

Get the output directory of the simulation.

Definition at line 361 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mOutputDirectory.

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

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

Reimplemented in CryptSimulation2d.

Definition at line 233 of file TissueSimulation.hpp.

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

template<unsigned DIM>
const std::vector< AbstractForce< DIM > * > TissueSimulation< DIM >::rGetForceCollection (  )  const [inline]
Returns:
const reference to mForceCollection (used in archiving).

Definition at line 165 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mForceCollection.

template<unsigned DIM>
const AbstractTissue< DIM > & TissueSimulation< DIM >::rGetTissue (  )  const [inline]
Returns:
const reference to the tissue (used in archiving).

Definition at line 382 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mrTissue.

template<unsigned DIM>
AbstractTissue< DIM > & TissueSimulation< DIM >::rGetTissue (  )  [inline]
Returns:
reference to the tissue.

Definition at line 375 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mrTissue.

template<unsigned DIM>
template<class Archive >
void TissueSimulation< 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 CryptSimulation1d, and CryptSimulation2d.

Definition at line 143 of file TissueSimulation.hpp.

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

Set the timestep of the simulation.

Parameters:
dt the timestep to use

Definition at line 316 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mDt.

template<unsigned DIM>
void TissueSimulation< 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 345 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mEndTime.

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

Set the simulation to run with no birth.

Parameters:
noBirth whether to run with no birth

Definition at line 396 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mNoBirth.

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

Set the output directory of the simulation.

Parameters:
outputDirectory the output directory to use

Definition at line 353 of file TissueSimulation.cpp.

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

template<unsigned DIM>
void TissueSimulation< 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 367 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mSamplingTimestepMultiple.

template<unsigned DIM>
void TissueSimulation< DIM >::SetUpdateTissueRule ( bool  updateTissue  )  [inline]

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

Parameters:
updateTissue whether to update the tissue each time step

Definition at line 389 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::mUpdateTissue.

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

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

Reimplemented in CryptSimulation2d.

Definition at line 240 of file TissueSimulation.hpp.

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

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

Main solve method.

This method sets up the simulation time, creates output files, and initialises the tissue. It then iterates through a time loop. At each time step, first any cell death or birth is implemented, then the tissue topology is updated, then the forces are recalculated and the tissue 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() Tissue::Update()

Definition at line 422 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::AfterSolve(), GenericEventHandler< 9, CellBasedEventHandler >::BeginEvent(), GenericEventHandler< 9, CellBasedEventHandler >::EndEvent(), SimulationTime::GetTime(), SimulationTime::GetTimeStepsElapsed(), SimulationTime::IncrementTimeOneStep(), TissueConfig::Instance(), SimulationTime::Instance(), TissueSimulation< DIM >::mDt, TissueSimulation< DIM >::mEndTime, TissueSimulation< DIM >::mForceCollection, TissueSimulation< DIM >::mOutputDirectory, TissueSimulation< DIM >::mpNodeVelocitiesFile, TissueSimulation< DIM >::mpSetupFile, TissueSimulation< DIM >::mrTissue, TissueSimulation< DIM >::mSamplingTimestepMultiple, TissueSimulation< DIM >::mSimulationOutputDirectory, OutputFileHandler::OpenOutputFile(), TissueSimulation< DIM >::PostSolve(), SimulationTime::ResetEndTimeAndNumberOfTimeSteps(), SimulationTime::SetEndTimeAndNumberOfTimeSteps(), TissueSimulation< DIM >::SetupSolve(), TissueSimulation< DIM >::StoppingEventHasOccurred(), TissueSimulation< DIM >::UpdateNodePositions(), TissueSimulation< DIM >::UpdateTissue(), and TissueSimulation< DIM >::WriteVisualizerSetupFile().

template<unsigned DIM>
bool TissueSimulation< 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 597 of file TissueSimulation.cpp.

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

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

Moves each node to a new position for this timestep by calling the tissue UpdateNodeLocations() method then applying any boundary conditions.

Parameters:
rNodeForces the forces on nodes

Definition at line 246 of file TissueSimulation.cpp.

References TissueSimulation< DIM >::ApplyTissueBoundaryConditions(), SimulationTime::GetTime(), SimulationTime::Instance(), TissueConfig::Instance(), TissueSimulation< DIM >::mDt, TissueSimulation< DIM >::mpNodeVelocitiesFile, TissueSimulation< DIM >::mrTissue, and TissueSimulation< DIM >::mSamplingTimestepMultiple.

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

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

Writes out special information about the mesh to the visualizer.

Reimplemented in CryptSimulation2d.

Definition at line 170 of file TissueSimulation.hpp.

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


Friends And Related Function Documentation

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

Needed for serialization.

Reimplemented in CryptSimulation1d, and CryptSimulation2d.

Definition at line 130 of file TissueSimulation.hpp.


Member Data Documentation

template<unsigned DIM>
bool TissueSimulation< DIM >::mAllocatedMemoryForForceCollection [protected]

Whether delete the collection of force laws in the destructor.

Definition at line 82 of file TissueSimulation.hpp.

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

template<unsigned DIM>
std::vector<AbstractCellKiller<DIM>*> TissueSimulation< DIM >::mCellKillers [protected]
template<unsigned DIM>
bool TissueSimulation< DIM >::mDeleteTissue [protected]

Whether to delete the tissue facade in the destructor.

Definition at line 79 of file TissueSimulation.hpp.

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

template<unsigned DIM>
double TissueSimulation< DIM >::mDt [protected]
template<unsigned DIM>
double TissueSimulation< DIM >::mEndTime [protected]
template<unsigned DIM>
std::vector<AbstractForce<DIM>*> TissueSimulation< DIM >::mForceCollection [protected]
template<unsigned DIM>
bool TissueSimulation< DIM >::mInitialiseCells [protected]

Whether to initialise the cells.

Definition at line 85 of file TissueSimulation.hpp.

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

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

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

Definition at line 88 of file TissueSimulation.hpp.

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

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

Counts the number of births during the simulation

Definition at line 112 of file TissueSimulation.hpp.

Referenced by TissueSimulation< DIM >::GetNumBirths(), TissueSimulation< 2 >::serialize(), and TissueSimulation< DIM >::UpdateTissue().

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

Counts the number of deaths during the simulation

Definition at line 115 of file TissueSimulation.hpp.

Referenced by TissueSimulation< DIM >::GetNumDeaths(), TissueSimulation< 2 >::serialize(), and TissueSimulation< DIM >::UpdateTissue().

template<unsigned DIM>
std::string TissueSimulation< DIM >::mOutputDirectory [protected]
template<unsigned DIM>
TissueConfig* TissueSimulation< DIM >::mpConfig [protected]

Pointer to TissueConfig singleton

Definition at line 106 of file TissueSimulation.hpp.

Referenced by TissueSimulation< 2 >::serialize(), and TissueSimulation< DIM >::TissueSimulation().

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

Results file node velocities

Definition at line 103 of file TissueSimulation.hpp.

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

template<unsigned DIM>
RandomNumberGenerator* TissueSimulation< DIM >::mpRandomGenerator [protected]
template<unsigned DIM>
out_stream TissueSimulation< DIM >::mpSetupFile [protected]

Visualiser setup file

Definition at line 100 of file TissueSimulation.hpp.

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

template<unsigned DIM>
AbstractTissue<DIM>& TissueSimulation< DIM >::mrTissue [protected]
template<unsigned DIM>
unsigned TissueSimulation< DIM >::mSamplingTimestepMultiple [protected]

The ratio of the number of actual timesteps to the number of timesteps at which results are written to file

Definition at line 121 of file TissueSimulation.hpp.

Referenced by TissueSimulation< 2 >::serialize(), TissueSimulation< DIM >::SetSamplingTimestepMultiple(), TissueSimulation< DIM >::Solve(), and TissueSimulation< DIM >::UpdateNodePositions().

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

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

Definition at line 97 of file TissueSimulation.hpp.

Referenced by TissueSimulation< DIM >::SetOutputDirectory(), and TissueSimulation< DIM >::Solve().

template<unsigned DIM>
bool TissueSimulation< DIM >::mUpdateTissue [protected]

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

Definition at line 91 of file TissueSimulation.hpp.

Referenced by TissueSimulation< 2 >::serialize(), TissueSimulation< DIM >::SetUpdateTissueRule(), and TissueSimulation< DIM >::UpdateTissue().


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

Generated by  doxygen 1.6.2