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 "CryptSimulation2d.hpp"
00030 #include "WntConcentration.hpp"
00031 #include "IngeWntSwatCellCycleModel.hpp"
00032
00033 c_vector<double, 2> CryptSimulation2d::CalculateDividingCellCentreLocations(TissueCell* pParentCell)
00034 {
00035 double separation = CancerParameters::Instance()->GetDivisionSeparation();
00036 c_vector<double, 2> parent_coords = mpStaticCastTissue->GetLocationOfCellCentre(pParentCell);
00037 c_vector<double, 2> daughter_coords;
00038
00039
00040
00041
00042
00043
00044 c_vector<double, 2> random_vector;
00045
00046 double random_angle = RandomNumberGenerator::Instance()->ranf();
00047 random_angle *= 2.0*M_PI;
00048
00049 random_vector(0) = 0.5*separation*cos(random_angle);
00050 random_vector(1) = 0.5*separation*sin(random_angle);
00051
00052 c_vector<double, 2> proposed_new_parent_coords = parent_coords - random_vector;
00053 c_vector<double, 2> proposed_new_daughter_coords = parent_coords + random_vector;
00054
00055 if ( (proposed_new_parent_coords(1) >= 0.0)
00056 && (proposed_new_daughter_coords(1) >= 0.0))
00057 {
00058
00059
00060 parent_coords = proposed_new_parent_coords;
00061 daughter_coords = proposed_new_daughter_coords;
00062 }
00063 else
00064 {
00065 proposed_new_daughter_coords = parent_coords+2.0*random_vector;
00066 while (proposed_new_daughter_coords(1) < 0.0)
00067 {
00068 random_angle = RandomNumberGenerator::Instance()->ranf();
00069 random_angle *= 2.0*M_PI;
00070
00071 random_vector(0) = separation*cos(random_angle);
00072 random_vector(1) = separation*sin(random_angle);
00073 proposed_new_daughter_coords = parent_coords+random_vector;
00074 }
00075 daughter_coords = proposed_new_daughter_coords;
00076 }
00077
00078 assert(daughter_coords(1)>=0.0);
00079 assert(parent_coords(1)>=0.0);
00080
00081
00082 ChastePoint<2> parent_coords_point(parent_coords);
00083
00084 unsigned node_index = mpStaticCastTissue->GetLocationIndexUsingCell(pParentCell);
00085 mrTissue.SetNode(node_index, parent_coords_point);
00086
00087 return daughter_coords;
00088 }
00089
00090
00091 void CryptSimulation2d::WriteVisualizerSetupFile()
00092 {
00093 *mpSetupFile << "MeshWidth\t" << mpStaticCastTissue->rGetMesh().GetWidth(0u) << "\n";
00094 }
00095
00096
00097 void CryptSimulation2d::SetupWriteBetaCatenin()
00098 {
00099 OutputFileHandler output_file_handler(this->mSimulationOutputDirectory + "/", false);
00100 mBetaCatResultsFile = output_file_handler.OpenOutputFile("results.vizbetacatenin");
00101 *mpSetupFile << "BetaCatenin\n";
00102 }
00103
00104
00105 void CryptSimulation2d::WriteBetaCatenin(double time)
00106 {
00107 *mBetaCatResultsFile << time << "\t";
00108
00109 unsigned global_index;
00110 double x;
00111 double y;
00112 double b_cat_membrane;
00113 double b_cat_cytoplasm;
00114 double b_cat_nuclear;
00115
00116 for (AbstractTissue<2>::Iterator cell_iter = mrTissue.Begin();
00117 cell_iter != mrTissue.End();
00118 ++cell_iter)
00119 {
00120 global_index = mpStaticCastTissue->GetLocationIndexUsingCell(&(*cell_iter));
00121 x = mpStaticCastTissue->GetLocationOfCellCentre(&(*cell_iter))[0];
00122 y = mpStaticCastTissue->GetLocationOfCellCentre(&(*cell_iter))[1];
00123
00124
00125 IngeWntSwatCellCycleModel* p_model = static_cast<IngeWntSwatCellCycleModel*>(cell_iter->GetCellCycleModel());
00126
00127 b_cat_membrane = p_model->GetMembraneBoundBetaCateninLevel();
00128 b_cat_cytoplasm = p_model->GetCytoplasmicBetaCateninLevel();
00129 b_cat_nuclear = p_model->GetNuclearBetaCateninLevel();
00130
00131 *mBetaCatResultsFile << global_index << " " << x << " " << y << " " << b_cat_membrane << " " << b_cat_cytoplasm << " " << b_cat_nuclear << " ";
00132 }
00133
00134 *mBetaCatResultsFile << "\n";
00135 }
00136
00137
00138 void CryptSimulation2d::SetupSolve()
00139 {
00140 if ( (mrTissue.Begin() != mrTissue.End())
00141 && (dynamic_cast<IngeWntSwatCellCycleModel*>(mrTissue.Begin()->GetCellCycleModel())) )
00142 {
00143 SetupWriteBetaCatenin();
00144 double current_time = SimulationTime::Instance()->GetTime();
00145 WriteBetaCatenin(current_time);
00146 }
00147 }
00148
00149
00150 void CryptSimulation2d::PostSolve()
00151 {
00152 SimulationTime *p_time = SimulationTime::Instance();
00153
00154 if ((p_time->GetTimeStepsElapsed()+1)%mSamplingTimestepMultiple==0)
00155 {
00156 if ( (mrTissue.Begin() != mrTissue.End())
00157 && (dynamic_cast<IngeWntSwatCellCycleModel*>(mrTissue.Begin()->GetCellCycleModel())) )
00158 {
00159 double time_next_step = p_time->GetTime() + p_time->GetTimeStep();
00160 WriteBetaCatenin(time_next_step);
00161 }
00162 }
00163 }
00164
00165
00166 void CryptSimulation2d::AfterSolve()
00167 {
00168 if ( (mrTissue.Begin() != mrTissue.End())
00169 && (dynamic_cast<IngeWntSwatCellCycleModel*>(mrTissue.Begin()->GetCellCycleModel())) )
00170 {
00171 mBetaCatResultsFile->close();
00172 }
00173
00174 TissueSimulation<2>::AfterSolve();
00175 }
00176
00177
00178 CryptSimulation2d::CryptSimulation2d(AbstractTissue<2>& rTissue,
00179 std::vector<AbstractForce<2>*> forceCollection,
00180 bool deleteTissueAndForceCollection,
00181 bool initialiseCells)
00182 : TissueSimulation<2>(rTissue,
00183 forceCollection,
00184 deleteTissueAndForceCollection,
00185 initialiseCells),
00186 mUseJiggledBottomCells(false)
00187 {
00188 mpStaticCastTissue = static_cast<MeshBasedTissueWithGhostNodes<2>*>(&mrTissue);
00189 }
00190
00191
00192 void CryptSimulation2d::UseJiggledBottomCells()
00193 {
00194 mUseJiggledBottomCells = true;
00195 }
00196
00197 void CryptSimulation2d::ApplyTissueBoundaryConditions(const std::vector< c_vector<double, 2> >& rOldLocations)
00198 {
00199 bool is_wnt_included = WntConcentration::Instance()->IsWntSetUp();
00200 if (!is_wnt_included)
00201 {
00202 WntConcentration::Destroy();
00203 }
00204
00205
00206
00207 for (AbstractTissue<2>::Iterator cell_iter = mrTissue.Begin();
00208 cell_iter != mrTissue.End();
00209 ++cell_iter)
00210 {
00211
00212 unsigned node_index = mpStaticCastTissue->GetLocationIndexUsingCell(&(*cell_iter));
00213
00214
00215 Node<2>* p_node = mpStaticCastTissue->GetNodeCorrespondingToCell(&(*cell_iter));
00216
00217 if (!is_wnt_included)
00218 {
00223 if (cell_iter->GetCellType()==STEM)
00224 {
00225
00226 c_vector<double, 2> old_node_location = rOldLocations[node_index];
00227
00228
00229 p_node->rGetModifiableLocation()[0] = old_node_location[0];
00230 p_node->rGetModifiableLocation()[1] = old_node_location[1];
00231 }
00232 }
00233
00234
00235 if (p_node->rGetLocation()[1] < 0.0)
00236 {
00237 p_node->rGetModifiableLocation()[1] = 0.0;
00238 if (mUseJiggledBottomCells)
00239 {
00240
00241
00242
00243
00244
00245
00246
00247
00248 p_node->rGetModifiableLocation()[1] = 0.05*mpRandomGenerator->ranf();
00249 }
00250 }
00251 assert(p_node->rGetLocation()[1] >= 0.0);
00252 }
00253 }