36 #include "AbstractCentreBasedCellPopulation.hpp"
38 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
40 std::vector<CellPtr>& rCells,
41 const std::vector<unsigned> locationIndices)
43 mMeinekeDivisionSeparation(0.3)
46 std::list<CellPtr>::iterator it = this->
mCells.begin();
49 for (
unsigned i=0; it != this->
mCells.end(); ++it, ++i, ++node_iter)
51 unsigned index = locationIndices.empty() ? node_iter->GetIndex() : locationIndices[i];
56 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
59 mMeinekeDivisionSeparation(0.3)
64 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
67 return GetNodeCorrespondingToCell(pCell)->rGetLocation();
70 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
73 unsigned index = this->GetLocationIndexUsingCell(pCell);
74 return this->GetNode(index);
77 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
82 unsigned new_node_index = this->AddNode(p_new_node);
85 this->mCells.push_back(pNewCell);
88 this->SetCellUsingLocationIndex(new_node_index, pNewCell);
89 this->mCellLocationMap[pNewCell.get()] = new_node_index;
94 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
100 std::pair<CellPtr,CellPtr> cell_pair;
102 if (pCell1->GetCellId() < pCell2->GetCellId())
104 cell_pair.first = pCell1;
105 cell_pair.second = pCell2;
109 cell_pair.first = pCell2;
110 cell_pair.second = pCell1;
115 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
119 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
121 return mMarkedSprings.find(rCellPair) != mMarkedSprings.end();
124 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
128 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
130 mMarkedSprings.insert(rCellPair);
133 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
137 assert(rCellPair.first->GetCellId() < rCellPair.second->GetCellId());
139 mMarkedSprings.erase(rCellPair);
142 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
145 return GetNodeCorrespondingToCell(pCell)->IsDeleted();
148 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
151 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
152 return this->GetNeighbouringNodeIndices(node_index);
155 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
160 cell_iter != this->End();
164 unsigned node_index = this->GetLocationIndexUsingCell((*cell_iter));
167 double damping_const = this->GetDampingConstant(node_index);
170 c_vector<double,SPACE_DIM> displacement=dt*this->GetNode(node_index)->rGetAppliedForce()/damping_const;
173 if (norm_2(displacement) > this->mAbsoluteMovementThreshold)
175 EXCEPTION(
"Cells are moving by: " << norm_2(displacement) <<
176 ", which is more than the AbsoluteMovementThreshold: "
177 << this->mAbsoluteMovementThreshold <<
178 ". Use a smaller timestep to avoid this exception.");
182 c_vector<double, SPACE_DIM> new_node_location = this->GetNode(node_index)->rGetLocation() + displacement;
188 this->SetNode(node_index, new_point);
192 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
195 CellPtr p_cell = this->GetCellUsingLocationIndex(nodeIndex);
198 return this->GetDampingConstantNormal();
202 return this->GetDampingConstantMutant();
206 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
212 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
218 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
221 return mMeinekeDivisionSeparation;
224 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
227 assert(divisionSeparation <= 1.0);
228 assert(divisionSeparation >= 0.0);
229 mMeinekeDivisionSeparation = divisionSeparation;
232 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
236 node_iter != this->rGetMesh().GetNodeIteratorEnd();
240 cell_writer_iter != this->mCellWriters.end();
243 CellPtr cell_from_node = this->GetCellUsingLocationIndex(node_iter->GetIndex());
244 this->AcceptCellWriter(*cell_writer_iter, cell_from_node);
249 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
252 *rParamsFile <<
"\t\t<MeinekeDivisionSeparation>" << mMeinekeDivisionSeparation <<
"</MeinekeDivisionSeparation>\n";
void UnmarkSpring(std::pair< CellPtr, CellPtr > &rCellPair)
virtual void AcceptCellWritersAcrossPopulation()
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
#define EXCEPTION(message)
virtual bool IsParticle(unsigned index)
double GetMeinekeDivisionSeparation()
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)
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
CellPtr AddCell(CellPtr pNewCell, const c_vector< double, SPACE_DIM > &rCellDivisionVector, CellPtr pParentCell=CellPtr())
virtual void UpdateNodeLocations(double dt)
virtual void AddCellUsingLocationIndex(unsigned index, CellPtr pCell)
void SetMeinekeDivisionSeparation(double divisionSeparation)
virtual double GetDampingConstant(unsigned nodeIndex)
c_vector< double, SPACE_DIM > GetLocationOfCellCentre(CellPtr pCell)