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