CryptSimulation1d.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "CryptSimulation1d.hpp"
00030 #include "WntConcentration.hpp"
00031 #include "SmartPointers.hpp"
00032
00033 CryptSimulation1d::CryptSimulation1d(AbstractCellPopulation<1>& rCellPopulation,
00034 bool deleteCellPopulationInDestructor,
00035 bool initialiseCells)
00036 : OffLatticeSimulation<1>(rCellPopulation,
00037 deleteCellPopulationInDestructor,
00038 initialiseCells)
00039 {
00040 mpStaticCastCellPopulation = static_cast<MeshBasedCellPopulation<1>*>(&mrCellPopulation);
00041
00042 if (!mDeleteCellPopulationInDestructor)
00043 {
00044
00045 MAKE_PTR_ARGS(CryptSimulationBoundaryCondition<1>, p_bc, (&rCellPopulation));
00046 AddCellPopulationBoundaryCondition(p_bc);
00047 }
00048 }
00049
00050 CryptSimulation1d::~CryptSimulation1d()
00051 {
00052 }
00053
00054 c_vector<double, 1> CryptSimulation1d::CalculateCellDivisionVector(CellPtr pParentCell)
00055 {
00056
00057 c_vector<double, 1> parent_coords = mpStaticCastCellPopulation->GetLocationOfCellCentre(pParentCell);
00058 c_vector<double, 1> daughter_coords;
00059
00060
00061 double separation = mpStaticCastCellPopulation->GetMeinekeDivisionSeparation();
00062
00063
00064 c_vector<double, 1> random_vector;
00065
00066
00067
00068
00069
00070
00071
00072 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00073 random_vector(0) = 0.5*separation*random_direction;
00074 c_vector<double, 1> proposed_new_parent_coords = parent_coords - random_vector;
00075 c_vector<double, 1> proposed_new_daughter_coords = parent_coords + random_vector;
00076
00077 if ( (proposed_new_parent_coords(0) >= 0.0)
00078 && (proposed_new_daughter_coords(0) >= 0.0))
00079 {
00080
00081 parent_coords = proposed_new_parent_coords;
00082 daughter_coords = proposed_new_daughter_coords;
00083 }
00084 else
00085 {
00086 proposed_new_daughter_coords = parent_coords + 2.0*random_vector;
00087 while (proposed_new_daughter_coords(0) < 0.0)
00088 {
00089 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00090 random_vector(0) = 0.5*separation*random_direction;
00091 proposed_new_daughter_coords = parent_coords + random_vector;
00092 }
00093 daughter_coords = proposed_new_daughter_coords;
00094 }
00095
00096 assert(daughter_coords(0) >= 0.0);
00097 assert(parent_coords(0) >= 0.0);
00098
00099
00100 ChastePoint<1> parent_coords_point(parent_coords);
00101
00102 unsigned node_index = mpStaticCastCellPopulation->GetLocationIndexUsingCell(pParentCell);
00103 mrCellPopulation.SetNode(node_index, parent_coords_point);
00104
00105 return daughter_coords;
00106 }
00107
00108 void CryptSimulation1d::OutputSimulationParameters(out_stream& rParamsFile)
00109 {
00110
00111
00112
00113 OffLatticeSimulation<1>::OutputSimulationParameters(rParamsFile);
00114 }
00115
00116
00117 #include "SerializationExportWrapperForCpp.hpp"
00118 CHASTE_CLASS_EXPORT(CryptSimulation1d)