36#include "AbstractCentreBasedCellPopulation.hpp"
38#include "RandomDirectionCentreBasedDivisionRule.hpp"
39#include "RandomNumberGenerator.hpp"
40#include "StepSizeException.hpp"
41#include "WildTypeCellMutationState.hpp"
43template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
45 std::vector<CellPtr>& rCells,
46 const std::vector<unsigned> locationIndices)
48 mMeinekeDivisionSeparation(0.3)
51 std::list<CellPtr>::iterator it = this->
mCells.begin();
54 for (
unsigned i = 0; it != this->
mCells.end(); ++it, ++i, ++node_iter)
56 unsigned index = locationIndices.empty() ? node_iter->GetIndex() : locationIndices[i];
63template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
66 mMeinekeDivisionSeparation(0.3)
70template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
73 return GetNodeCorrespondingToCell(pCell)->rGetLocation();
76template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
79 unsigned index = this->GetLocationIndexUsingCell(pCell);
80 return this->GetNode(index);
83template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
85 unsigned pdeNodeIndex,
86 std::string& rVariableName,
87 bool dirichletBoundaryConditionApplies,
88 double dirichletBoundaryValue)
90 CellPtr p_cell = this->GetCellUsingLocationIndex(pdeNodeIndex);
91 double value = p_cell->GetCellData()->GetItem(rVariableName);
96template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
100 std::pair<c_vector<double, SPACE_DIM>, c_vector<double, SPACE_DIM> > positions = mpCentreBasedDivisionRule->CalculateCellDivisionVector(pParentCell, *
this);
102 c_vector<double, SPACE_DIM> parent_position = positions.first;
103 c_vector<double, SPACE_DIM> daughter_position = positions.second;
107 unsigned node_index = this->GetLocationIndexUsingCell(pParentCell);
108 this->SetNode(node_index, parent_point);
117 if (this->GetNode(node_index)->HasNodeAttributes())
122 unsigned new_node_index = this->AddNode(p_new_node);
125 this->mCells.push_back(pNewCell);
128 this->SetCellUsingLocationIndex(new_node_index, pNewCell);
129 this->mCellLocationMap[pNewCell.get()] = new_node_index;
134template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
140 std::pair<CellPtr,CellPtr> cell_pair;
142 if (pCell1->GetCellId() < pCell2->GetCellId())
144 cell_pair.first = pCell1;
145 cell_pair.second = pCell2;
149 cell_pair.first = pCell2;
150 cell_pair.second = pCell1;
155template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
159 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
161 return mMarkedSprings.find(rCellPair) != mMarkedSprings.end();
164template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
168 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
170 mMarkedSprings.insert(rCellPair);
173template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
177 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
179 mMarkedSprings.erase(rCellPair);
182template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
185 return GetNodeCorrespondingToCell(pCell)->IsDeleted();
188template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
191 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
192 return this->GetNeighbouringNodeIndices(node_index);
195template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
198 double length = norm_2(rDisplacement);
200 if ((length > this->mAbsoluteMovementThreshold) && (!this->IsGhostNode(nodeIndex)) && (!this->IsParticle(nodeIndex)))
202 std::ostringstream message;
203 message <<
"Cells are moving by " << length;
204 message <<
", which is more than the AbsoluteMovementThreshold: use a smaller timestep to avoid this exception.";
207 double new_step = 0.95*dt*(this->mAbsoluteMovementThreshold/length);
213template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
216 if (this->IsGhostNode(nodeIndex) || this->IsParticle(nodeIndex))
218 return this->GetDampingConstantNormal();
222 CellPtr p_cell = this->GetCellUsingLocationIndex(nodeIndex);
225 return this->GetDampingConstantNormal();
229 return this->GetDampingConstantMutant();
234template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
240template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
246template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
249 return mMeinekeDivisionSeparation;
252template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
255 assert(divisionSeparation <= 1.0);
256 assert(divisionSeparation >= 0.0);
257 mMeinekeDivisionSeparation = divisionSeparation;
260template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
264 node_iter != this->rGetMesh().GetNodeIteratorEnd();
268 cell_writer_iter != this->mCellWriters.end();
271 CellPtr cell_from_node = this->GetCellUsingLocationIndex(node_iter->GetIndex());
272 this->AcceptCellWriter(*cell_writer_iter, cell_from_node);
277template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
280 return mpCentreBasedDivisionRule;
283template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
286 mpCentreBasedDivisionRule = pCentreBasedDivisionRule;
289template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
292 *rParamsFile <<
"\t\t<MeinekeDivisionSeparation>" << mMeinekeDivisionSeparation <<
"</MeinekeDivisionSeparation>\n";
295 *rParamsFile <<
"\t\t<CentreBasedDivisionRule>\n";
296 mpCentreBasedDivisionRule->OutputCellCentreBasedDivisionRuleInfo(rParamsFile);
297 *rParamsFile <<
"\t\t</CentreBasedDivisionRule>\n";
303template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
virtual void AddCellUsingLocationIndex(unsigned index, CellPtr pCell)
std::list< CellPtr > mCells
void MarkSpring(std::pair< CellPtr, CellPtr > &rCellPair)
virtual double GetDefaultTimeStep()
void UnmarkSpring(std::pair< CellPtr, CellPtr > &rCellPair)
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
AbstractCentreBasedCellPopulation(AbstractMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
double GetMeinekeDivisionSeparation()
virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector< double, SPACE_DIM > &rDisplacement, double dt)
virtual bool IsParticle(unsigned index)
std::pair< CellPtr, CellPtr > CreateCellPair(CellPtr pCell1, CellPtr pCell2)
void SetCentreBasedDivisionRule(boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > pCentreBasedDivisionRule)
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
void SetMeinekeDivisionSeparation(double divisionSeparation)
virtual double GetDampingConstant(unsigned nodeIndex)
bool IsMarkedSpring(const std::pair< CellPtr, CellPtr > &rCellPair)
boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > mpCentreBasedDivisionRule
virtual bool IsGhostNode(unsigned index)
c_vector< double, SPACE_DIM > GetLocationOfCellCentre(CellPtr pCell)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
virtual std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
Node< SPACE_DIM > * GetNodeCorrespondingToCell(CellPtr pCell)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
virtual void AcceptCellWritersAcrossPopulation()
boost::shared_ptr< AbstractCentreBasedDivisionRule< ELEMENT_DIM, SPACE_DIM > > GetCentreBasedDivisionRule()
NodeIterator GetNodeIteratorBegin(bool skipDeletedNodes=true)
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
std::vector< double > & rGetNodeAttributes()