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
00030
00031
00032
00033
00034
00035
00036 #include "AbstractCentreBasedCellPopulation.hpp"
00037
00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00039 AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::AbstractCentreBasedCellPopulation( AbstractMesh<ELEMENT_DIM, SPACE_DIM>& rMesh,
00040 std::vector<CellPtr>& rCells,
00041 const std::vector<unsigned> locationIndices)
00042 : AbstractOffLatticeCellPopulation<ELEMENT_DIM, SPACE_DIM>(rMesh, rCells, locationIndices),
00043 mMeinekeDivisionSeparation(0.3)
00044 {
00045
00046 std::list<CellPtr>::iterator it = this->mCells.begin();
00047 typename AbstractMesh<ELEMENT_DIM, SPACE_DIM>::NodeIterator node_iter = rMesh.GetNodeIteratorBegin();
00048
00049 for (unsigned i=0; it != this->mCells.end(); ++it, ++i, ++node_iter)
00050 {
00051 unsigned index = locationIndices.empty() ? node_iter->GetIndex() : locationIndices[i];
00052 AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>::AddCellUsingLocationIndex(index,*it);
00053 }
00054 }
00055
00056 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00057 AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::AbstractCentreBasedCellPopulation(AbstractMesh<ELEMENT_DIM, SPACE_DIM>& rMesh)
00058 : AbstractOffLatticeCellPopulation<ELEMENT_DIM, SPACE_DIM>(rMesh),
00059 mMeinekeDivisionSeparation(0.3)
00060
00061 {
00062 }
00063
00064 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00065 c_vector<double, SPACE_DIM> AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::GetLocationOfCellCentre(CellPtr pCell)
00066 {
00067 return GetNodeCorrespondingToCell(pCell)->rGetLocation();
00068 }
00069
00070 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00071 Node<SPACE_DIM>* AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::GetNodeCorrespondingToCell(CellPtr pCell)
00072 {
00073 unsigned index = this->GetLocationIndexUsingCell(pCell);
00074 return this->GetNode(index);
00075 }
00076
00077 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00078 CellPtr AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::AddCell(CellPtr pNewCell, const c_vector<double,SPACE_DIM>& rCellDivisionVector, CellPtr pParentCell)
00079 {
00080
00081 Node<SPACE_DIM>* p_new_node = new Node<SPACE_DIM>(this->GetNumNodes(), rCellDivisionVector, false);
00082 unsigned new_node_index = this->AddNode(p_new_node);
00083
00084
00085 this->mCells.push_back(pNewCell);
00086
00087
00088 this->SetCellUsingLocationIndex(new_node_index, pNewCell);
00089 this->mCellLocationMap[pNewCell.get()] = new_node_index;
00090
00091 return pNewCell;
00092 }
00093
00094 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00095 std::pair<CellPtr,CellPtr> AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::CreateCellPair(CellPtr pCell1, CellPtr pCell2)
00096 {
00097 assert(pCell1);
00098 assert(pCell2);
00099
00100 std::pair<CellPtr,CellPtr> cell_pair;
00101
00102 if (pCell1->GetCellId() < pCell2->GetCellId())
00103 {
00104 cell_pair.first = pCell1;
00105 cell_pair.second = pCell2;
00106 }
00107 else
00108 {
00109 cell_pair.first = pCell2;
00110 cell_pair.second = pCell1;
00111 }
00112 return cell_pair;
00113 }
00114
00115 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00116 bool AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::IsMarkedSpring(const std::pair<CellPtr,CellPtr>& rCellPair)
00117 {
00118
00119 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
00120
00121 return mMarkedSprings.find(rCellPair) != mMarkedSprings.end();
00122 }
00123
00124 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00125 void AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::MarkSpring(std::pair<CellPtr,CellPtr>& rCellPair)
00126 {
00127
00128 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
00129
00130 mMarkedSprings.insert(rCellPair);
00131 }
00132
00133 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00134 void AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::UnmarkSpring(std::pair<CellPtr,CellPtr>& rCellPair)
00135 {
00136
00137 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
00138
00139 mMarkedSprings.erase(rCellPair);
00140 }
00141
00142 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00143 bool AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::IsCellAssociatedWithADeletedLocation(CellPtr pCell)
00144 {
00145 return GetNodeCorrespondingToCell(pCell)->IsDeleted();
00146 }
00147
00148 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00149 void AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::UpdateNodeLocations(double dt)
00150 {
00151
00152 for (typename AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>::Iterator cell_iter = this->Begin();
00153 cell_iter != this->End();
00154 ++cell_iter)
00155 {
00156
00157 unsigned node_index = this->GetLocationIndexUsingCell((*cell_iter));
00158
00159
00160 double damping_const = this->GetDampingConstant(node_index);
00161
00162
00163 c_vector<double,SPACE_DIM> displacement=dt*this->GetNode(node_index)->rGetAppliedForce()/damping_const;
00164
00165
00166 if (norm_2(displacement) > this->mAbsoluteMovementThreshold)
00167 {
00168 EXCEPTION("Cells are moving by: " << norm_2(displacement) <<
00169 ", which is more than the AbsoluteMovementThreshold: "
00170 << this->mAbsoluteMovementThreshold <<
00171 ". Use a smaller timestep to avoid this exception.");
00172 }
00173
00174
00175 c_vector<double, SPACE_DIM> new_node_location = this->GetNode(node_index)->rGetLocation() + displacement;
00176
00177
00178 ChastePoint<SPACE_DIM> new_point(new_node_location);
00179
00180
00181 this->SetNode(node_index, new_point);
00182 }
00183 }
00184
00185 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00186 double AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::GetDampingConstant(unsigned nodeIndex)
00187 {
00188 CellPtr p_cell = this->GetCellUsingLocationIndex(nodeIndex);
00189 if (p_cell->GetMutationState()->IsType<WildTypeCellMutationState>() && !p_cell->HasCellProperty<CellLabel>())
00190 {
00191 return this->GetDampingConstantNormal();
00192 }
00193 else
00194 {
00195 return this->GetDampingConstantMutant();
00196 }
00197 }
00198
00199 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00200 bool AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::IsGhostNode(unsigned index)
00201 {
00202 return false;
00203 }
00204
00205 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00206 bool AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::IsParticle(unsigned index)
00207 {
00208 return false;
00209 }
00210
00211 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00212 double AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::GetMeinekeDivisionSeparation()
00213 {
00214 return mMeinekeDivisionSeparation;
00215 }
00216
00217 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00218 void AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::SetMeinekeDivisionSeparation(double divisionSeparation)
00219 {
00220 assert(divisionSeparation <= 1.0);
00221 assert(divisionSeparation >= 0.0);
00222 mMeinekeDivisionSeparation = divisionSeparation;
00223 }
00224
00225 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00226 void AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>::OutputCellPopulationParameters(out_stream& rParamsFile)
00227 {
00228 *rParamsFile << "\t\t<MeinekeDivisionSeparation>" << mMeinekeDivisionSeparation << "</MeinekeDivisionSeparation>\n";
00229
00230
00231 AbstractOffLatticeCellPopulation<ELEMENT_DIM, SPACE_DIM>::OutputCellPopulationParameters(rParamsFile);
00232 }
00233
00235
00237
00238 template class AbstractCentreBasedCellPopulation<1,1>;
00239 template class AbstractCentreBasedCellPopulation<1,2>;
00240 template class AbstractCentreBasedCellPopulation<2,2>;
00241 template class AbstractCentreBasedCellPopulation<1,3>;
00242 template class AbstractCentreBasedCellPopulation<2,3>;
00243 template class AbstractCentreBasedCellPopulation<3,3>;