36 #include "AbstractCentreBasedCellPopulation.hpp"
37 #include "RandomDirectionCentreBasedDivisionRule.hpp"
38 #include "RandomNumberGenerator.hpp"
39 #include "StepSizeException.hpp"
40 #include "WildTypeCellMutationState.hpp"
42 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
44 std::vector<CellPtr>& rCells,
45 const std::vector<unsigned> locationIndices)
47 mMeinekeDivisionSeparation(0.3)
50 std::list<CellPtr>::iterator it = this->
mCells.begin();
53 for (
unsigned i=0; it != this->
mCells.end(); ++it, ++i, ++node_iter)
55 unsigned index = locationIndices.empty() ? node_iter->GetIndex() : locationIndices[i];
62 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
65 mMeinekeDivisionSeparation(0.3)
69 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
72 return GetNodeCorrespondingToCell(pCell)->rGetLocation();
75 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
78 unsigned index = this->GetLocationIndexUsingCell(pCell);
79 return this->GetNode(index);
82 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
84 unsigned pdeNodeIndex,
85 std::string& rVariableName,
86 bool dirichletBoundaryConditionApplies,
87 double dirichletBoundaryValue)
89 CellPtr p_cell = this->GetCellUsingLocationIndex(pdeNodeIndex);
90 double value = p_cell->GetCellData()->GetItem(rVariableName);
95 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
99 std::pair<c_vector<double, SPACE_DIM>, c_vector<double, SPACE_DIM> > positions = mpCentreBasedDivisionRule->CalculateCellDivisionVector(pParentCell, *
this);
101 c_vector<double, SPACE_DIM> parent_position = positions.first;
102 c_vector<double, SPACE_DIM> daughter_position = positions.second;
106 unsigned node_index = this->GetLocationIndexUsingCell(pParentCell);
107 this->SetNode(node_index, parent_point);
116 if (this->GetNode(node_index)->HasNodeAttributes())
121 unsigned new_node_index = this->AddNode(p_new_node);
124 this->mCells.push_back(pNewCell);
127 this->SetCellUsingLocationIndex(new_node_index, pNewCell);
128 this->mCellLocationMap[pNewCell.get()] = new_node_index;
133 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
139 std::pair<CellPtr,CellPtr> cell_pair;
141 if (pCell1->GetCellId() < pCell2->GetCellId())
143 cell_pair.first = pCell1;
144 cell_pair.second = pCell2;
148 cell_pair.first = pCell2;
149 cell_pair.second = pCell1;
154 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
158 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
160 return mMarkedSprings.find(rCellPair) != mMarkedSprings.end();
163 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
167 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
169 mMarkedSprings.insert(rCellPair);
172 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
176 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
178 mMarkedSprings.erase(rCellPair);
181 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
184 return GetNodeCorrespondingToCell(pCell)->IsDeleted();
187 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
190 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
191 return this->GetNeighbouringNodeIndices(node_index);
194 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
197 double length = norm_2(rDisplacement);
199 if ((length > this->mAbsoluteMovementThreshold) && (!this->IsGhostNode(nodeIndex)) && (!this->IsParticle(nodeIndex)))
201 std::ostringstream message;
202 message <<
"Cells are moving by " << length;
203 message <<
", which is more than the AbsoluteMovementThreshold: use a smaller timestep to avoid this exception.";
206 double new_step = 0.95*dt*(this->mAbsoluteMovementThreshold/length);
212 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
215 if (this->IsGhostNode(nodeIndex) || this->IsParticle(nodeIndex))
217 return this->GetDampingConstantNormal();
221 CellPtr p_cell = this->GetCellUsingLocationIndex(nodeIndex);
224 return this->GetDampingConstantNormal();
228 return this->GetDampingConstantMutant();
233 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
239 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
245 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
248 return mMeinekeDivisionSeparation;
251 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
254 assert(divisionSeparation <= 1.0);
255 assert(divisionSeparation >= 0.0);
256 mMeinekeDivisionSeparation = divisionSeparation;
259 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
263 node_iter != this->rGetMesh().GetNodeIteratorEnd();
267 cell_writer_iter != this->mCellWriters.end();
270 CellPtr cell_from_node = this->GetCellUsingLocationIndex(node_iter->GetIndex());
271 this->AcceptCellWriter(*cell_writer_iter, cell_from_node);
276 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
279 return mpCentreBasedDivisionRule;
282 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
285 mpCentreBasedDivisionRule = pCentreBasedDivisionRule;
288 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
291 *rParamsFile <<
"\t\t<MeinekeDivisionSeparation>" << mMeinekeDivisionSeparation <<
"</MeinekeDivisionSeparation>\n";
294 *rParamsFile <<
"\t\t<CentreBasedDivisionRule>\n";
295 mpCentreBasedDivisionRule->OutputCellCentreBasedDivisionRuleInfo(rParamsFile);
296 *rParamsFile <<
"\t\t</CentreBasedDivisionRule>\n";
302 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > mpCentreBasedDivisionRule
void UnmarkSpring(std::pair< CellPtr, CellPtr > &rCellPair)
virtual void AcceptCellWritersAcrossPopulation()
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
virtual bool IsParticle(unsigned index)
double GetMeinekeDivisionSeparation()
std::vector< double > & rGetNodeAttributes()
std::pair< CellPtr, CellPtr > CreateCellPair(CellPtr pCell1, CellPtr pCell2)
virtual bool IsGhostNode(unsigned index)
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
AbstractCentreBasedCellPopulation(AbstractMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
Node< SPACE_DIM > * GetNodeCorrespondingToCell(CellPtr pCell)
virtual double GetDefaultTimeStep()
boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > GetCentreBasedDivisionRule()
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
void MarkSpring(std::pair< CellPtr, CellPtr > &rCellPair)
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
bool IsMarkedSpring(const std::pair< CellPtr, CellPtr > &rCellPair)
std::list< CellPtr > mCells
virtual void AddCellUsingLocationIndex(unsigned index, CellPtr pCell)
void SetMeinekeDivisionSeparation(double divisionSeparation)
virtual double GetDampingConstant(unsigned nodeIndex)
c_vector< double, SPACE_DIM > GetLocationOfCellCentre(CellPtr pCell)
virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector< double, SPACE_DIM > &rDisplacement, double dt)
void SetCentreBasedDivisionRule(boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > pCentreBasedDivisionRule)