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