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
00032
00033 CryptSimulation1d::CryptSimulation1d(AbstractCellPopulation<1>& rCellPopulation,
00034 bool deleteCellPopulationAndForceCollection,
00035 bool initialiseCells)
00036 : CellBasedSimulation<1>(rCellPopulation,
00037 deleteCellPopulationAndForceCollection,
00038 initialiseCells)
00039 {
00040 mpStaticCastCellPopulation = static_cast<MeshBasedCellPopulation<1>*>(&mrCellPopulation);
00041 }
00042
00043
00044 c_vector<double, 1> CryptSimulation1d::CalculateCellDivisionVector(CellPtr pParentCell)
00045 {
00046
00047 c_vector<double, 1> parent_coords = mpStaticCastCellPopulation->GetLocationOfCellCentre(pParentCell);
00048 c_vector<double, 1> daughter_coords;
00049
00050
00051 double separation = mpStaticCastCellPopulation->GetMeinekeDivisionSeparation();
00052
00053
00054 c_vector<double, 1> random_vector;
00055
00056
00057
00058
00059
00060
00061
00062 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00063 random_vector(0) = 0.5*separation*random_direction;
00064 c_vector<double, 1> proposed_new_parent_coords = parent_coords - random_vector;
00065 c_vector<double, 1> proposed_new_daughter_coords = parent_coords + random_vector;
00066
00067 if ( (proposed_new_parent_coords(0) >= 0.0)
00068 && (proposed_new_daughter_coords(0) >= 0.0))
00069 {
00070
00071 parent_coords = proposed_new_parent_coords;
00072 daughter_coords = proposed_new_daughter_coords;
00073 }
00074 else
00075 {
00076 proposed_new_daughter_coords = parent_coords + 2.0*random_vector;
00077 while (proposed_new_daughter_coords(0) < 0.0)
00078 {
00079 double random_direction = -1.0 + 2.0*(RandomNumberGenerator::Instance()->ranf() < 0.5);
00080 random_vector(0) = 0.5*separation*random_direction;
00081 proposed_new_daughter_coords = parent_coords + random_vector;
00082 }
00083 daughter_coords = proposed_new_daughter_coords;
00084 }
00085
00086 assert(daughter_coords(0) >= 0.0);
00087 assert(parent_coords(0) >= 0.0);
00088
00089
00090 ChastePoint<1> parent_coords_point(parent_coords);
00091
00092 unsigned node_index = mpStaticCastCellPopulation->GetLocationIndexUsingCell(pParentCell);
00093 mrCellPopulation.SetNode(node_index, parent_coords_point);
00094
00095 return daughter_coords;
00096 }
00097
00098
00099 void CryptSimulation1d::ApplyCellPopulationBoundaryConditions(const std::vector< c_vector<double, 1> >& rOldLocations)
00100 {
00101 bool is_wnt_included = WntConcentration<1>::Instance()->IsWntSetUp();
00102 if (!is_wnt_included)
00103 {
00104 WntConcentration<1>::Destroy();
00105 }
00106
00107
00108
00109 for (AbstractCellPopulation<1>::Iterator cell_iter = mrCellPopulation.Begin();
00110 cell_iter != mrCellPopulation.End();
00111 ++cell_iter)
00112 {
00113
00114 unsigned node_index = mpStaticCastCellPopulation->GetLocationIndexUsingCell(*cell_iter);
00115
00116
00117 Node<1>* p_node = mpStaticCastCellPopulation->GetNodeCorrespondingToCell(*cell_iter);
00118
00119 if (!is_wnt_included)
00120 {
00125 if (cell_iter->GetCellCycleModel()->GetCellProliferativeType()==STEM)
00126 {
00127
00128 c_vector<double, 1> old_node_location = rOldLocations[node_index];
00129
00130
00131 p_node->rGetModifiableLocation()[0] = old_node_location[0];
00132 }
00133 }
00134
00135
00136 if (p_node->rGetLocation()[0] < 0.0)
00137 {
00138 p_node->rGetModifiableLocation()[0] = 0.0;
00139 }
00140 assert(p_node->rGetLocation()[0] >= 0.0);
00141 }
00142 }
00143
00144 void CryptSimulation1d::OutputSimulationParameters(out_stream& rParamsFile)
00145 {
00146
00147
00148
00149 CellBasedSimulation<1>::OutputSimulationParameters(rParamsFile);
00150 }
00151
00152
00153 #include "SerializationExportWrapperForCpp.hpp"
00154 CHASTE_CLASS_EXPORT(CryptSimulation1d)