AbstractCellCentreBasedTissue.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 "AbstractCellCentreBasedTissue.hpp"
00030
00031 template<unsigned DIM>
00032 AbstractCellCentreBasedTissue<DIM>::AbstractCellCentreBasedTissue(std::vector<TissueCell>& rCells,
00033 const std::vector<unsigned> locationIndices)
00034 : AbstractTissue<DIM>(rCells, locationIndices)
00035 {
00036 }
00037
00038
00039 template<unsigned DIM>
00040 AbstractCellCentreBasedTissue<DIM>::AbstractCellCentreBasedTissue()
00041 : AbstractTissue<DIM>()
00042 {
00043 }
00044
00045
00046 template<unsigned DIM>
00047 c_vector<double, DIM> AbstractCellCentreBasedTissue<DIM>::GetLocationOfCellCentre(TissueCell& rCell)
00048 {
00049 return GetNodeCorrespondingToCell(rCell)->rGetLocation();
00050 }
00051
00052
00053 template<unsigned DIM>
00054 Node<DIM>* AbstractCellCentreBasedTissue<DIM>::GetNodeCorrespondingToCell(TissueCell& rCell)
00055 {
00056 return this->GetNode(this->mCellLocationMap[&rCell]);
00057 }
00058
00059
00060 template<unsigned DIM>
00061 TissueCell* AbstractCellCentreBasedTissue<DIM>::AddCell(TissueCell& rNewCell, const c_vector<double,DIM>& rCellDivisionVector, TissueCell* pParentCell)
00062 {
00063
00064 Node<DIM>* p_new_node = new Node<DIM>(this->GetNumNodes(), rCellDivisionVector, false);
00065 unsigned new_node_index = AddNode(p_new_node);
00066
00067
00068 this->mCells.push_back(rNewCell);
00069
00070
00071 TissueCell* p_created_cell = &(this->mCells.back());
00072 this->mLocationCellMap[new_node_index] = p_created_cell;
00073 this->mCellLocationMap[p_created_cell] = new_node_index;
00074
00075 return p_created_cell;
00076 }
00077
00078
00079 template<unsigned DIM>
00080 bool AbstractCellCentreBasedTissue<DIM>::IsCellAssociatedWithADeletedLocation(TissueCell& rCell)
00081 {
00082 return GetNodeCorrespondingToCell(rCell)->IsDeleted();
00083 }
00084
00085
00086 template<unsigned DIM>
00087 void AbstractCellCentreBasedTissue<DIM>::UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt)
00088 {
00089
00090 for (typename AbstractTissue<DIM>::Iterator cell_iter = this->Begin();
00091 cell_iter != this->End();
00092 ++cell_iter)
00093 {
00094
00095 unsigned node_index = this->mCellLocationMap[&(*cell_iter)];
00096
00097
00098 double damping_const = this->GetDampingConstant(node_index);
00099
00100
00101 c_vector<double, DIM> new_node_location = this->GetNode(node_index)->rGetLocation() + dt*rNodeForces[node_index]/damping_const;
00102
00103
00104 ChastePoint<DIM> new_point(new_node_location);
00105
00106
00107 this->SetNode(node_index, new_point);
00108 }
00109 }
00110
00111
00112 template<unsigned DIM>
00113 double AbstractCellCentreBasedTissue<DIM>::GetDampingConstant(unsigned nodeIndex)
00114 {
00115 TissueCell& cell = this->rGetCellUsingLocationIndex(nodeIndex);
00116 if (cell.GetMutationState()->IsType<WildTypeCellMutationState>())
00117 {
00118 return TissueConfig::Instance()->GetDampingConstantNormal();
00119 }
00120 else
00121 {
00122 return TissueConfig::Instance()->GetDampingConstantMutant();
00123 }
00124 }
00125
00126
00127 template<unsigned DIM>
00128 bool AbstractCellCentreBasedTissue<DIM>::IsGhostNode(unsigned index)
00129 {
00130 return false;
00131 }
00132
00133
00134 template<unsigned DIM>
00135 void AbstractCellCentreBasedTissue<DIM>::GenerateCellResults(unsigned locationIndex,
00136 std::vector<unsigned>& rCellProliferativeTypeCounter,
00137 std::vector<unsigned>& rCellCyclePhaseCounter)
00138 {
00139 if (IsGhostNode(locationIndex) == true)
00140 {
00141 *(this->mpVizCellProliferativeTypesFile) << INVISIBLE_COLOUR << " ";
00142 }
00143 else
00144 {
00145 AbstractTissue<DIM>::GenerateCellResults(locationIndex,
00146 rCellProliferativeTypeCounter,
00147 rCellCyclePhaseCounter);
00148 }
00149 }
00150
00151
00152 template<unsigned DIM>
00153 void AbstractCellCentreBasedTissue<DIM>::GenerateCellResultsAndWriteToFiles()
00154 {
00155
00156 unsigned num_cell_types = this->mCellProliferativeTypeCount.size();
00157 std::vector<unsigned> cell_type_counter(num_cell_types);
00158 for (unsigned i=0; i<num_cell_types; i++)
00159 {
00160 cell_type_counter[i] = 0;
00161 }
00162
00163
00164 unsigned num_cell_cycle_phases = this->mCellCyclePhaseCount.size();
00165 std::vector<unsigned> cell_cycle_phase_counter(num_cell_cycle_phases);
00166 for (unsigned i=0; i<num_cell_cycle_phases; i++)
00167 {
00168 cell_cycle_phase_counter[i] = 0;
00169 }
00170
00171
00172 for (unsigned node_index=0; node_index<this->GetNumNodes(); node_index++)
00173 {
00174
00175 bool node_corresponds_to_dead_cell = false;
00176 if (this->mLocationCellMap[node_index])
00177 {
00178 node_corresponds_to_dead_cell = this->mLocationCellMap[node_index]->IsDead();
00179 }
00180
00181
00182 if ( !(this->GetNode(node_index)->IsDeleted()) && !node_corresponds_to_dead_cell)
00183 {
00184 this->GenerateCellResults(node_index, cell_type_counter, cell_cycle_phase_counter);
00185 }
00186 }
00187
00188 this->WriteCellResultsToFiles(cell_type_counter, cell_cycle_phase_counter);
00189 }
00190
00191
00193
00195
00196 template class AbstractCellCentreBasedTissue<1>;
00197 template class AbstractCellCentreBasedTissue<2>;
00198 template class AbstractCellCentreBasedTissue<3>;