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
00030
00031
00032
00033
00034
00035
00036 #include "CryptSimulation1d.hpp"
00037 #include "WntConcentration.hpp"
00038 #include "SmartPointers.hpp"
00039
00040 CryptSimulation1d::CryptSimulation1d(AbstractCellPopulation<1>& rCellPopulation,
00041 bool deleteCellPopulationInDestructor,
00042 bool initialiseCells)
00043 : OffLatticeSimulation<1>(rCellPopulation,
00044 deleteCellPopulationInDestructor,
00045 initialiseCells)
00046 {
00047 mpStaticCastCellPopulation = static_cast<MeshBasedCellPopulation<1>*>(&mrCellPopulation);
00048
00049 if (!mDeleteCellPopulationInDestructor)
00050 {
00051
00052 MAKE_PTR_ARGS(CryptSimulationBoundaryCondition<1>, p_bc, (&rCellPopulation));
00053 AddCellPopulationBoundaryCondition(p_bc);
00054 }
00055 }
00056
00057 CryptSimulation1d::~CryptSimulation1d()
00058 {
00059 }
00060
00061 c_vector<double, 1> CryptSimulation1d::CalculateCellDivisionVector(CellPtr pParentCell)
00062 {
00063
00064 c_vector<double, 1> parent_coords = mpStaticCastCellPopulation->GetLocationOfCellCentre(pParentCell);
00065 c_vector<double, 1> daughter_coords;
00066
00067
00068 double separation = mpStaticCastCellPopulation->GetMeinekeDivisionSeparation();
00069
00070
00071 c_vector<double, 1> random_vector;
00072
00073
00074
00075
00076
00077
00078
00079 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00080 random_vector(0) = 0.5*separation*random_direction;
00081 c_vector<double, 1> proposed_new_parent_coords = parent_coords - random_vector;
00082 c_vector<double, 1> proposed_new_daughter_coords = parent_coords + random_vector;
00083
00084 if ( (proposed_new_parent_coords(0) >= 0.0)
00085 && (proposed_new_daughter_coords(0) >= 0.0))
00086 {
00087
00088 parent_coords = proposed_new_parent_coords;
00089 daughter_coords = proposed_new_daughter_coords;
00090 }
00091 else
00092 {
00093 proposed_new_daughter_coords = parent_coords + 2.0*random_vector;
00094 while (proposed_new_daughter_coords(0) < 0.0)
00095 {
00096 double fresh_random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00097 random_vector(0) = 0.5*separation*fresh_random_direction;
00098 proposed_new_daughter_coords = parent_coords + random_vector;
00099 }
00100 daughter_coords = proposed_new_daughter_coords;
00101 }
00102
00103 assert(daughter_coords(0) >= 0.0);
00104 assert(parent_coords(0) >= 0.0);
00105
00106
00107 ChastePoint<1> parent_coords_point(parent_coords);
00108
00109 unsigned node_index = mpStaticCastCellPopulation->GetLocationIndexUsingCell(pParentCell);
00110 mrCellPopulation.SetNode(node_index, parent_coords_point);
00111
00112 return daughter_coords;
00113 }
00114
00115 void CryptSimulation1d::OutputSimulationParameters(out_stream& rParamsFile)
00116 {
00117
00118
00119
00120 OffLatticeSimulation<1>::OutputSimulationParameters(rParamsFile);
00121 }
00122
00123
00124 #include "SerializationExportWrapperForCpp.hpp"
00125 CHASTE_CLASS_EXPORT(CryptSimulation1d)