36 #include "MeshBasedCellPopulation.hpp"
37 #include "TrianglesMeshWriter.hpp"
38 #include "VtkMeshWriter.hpp"
39 #include "CellBasedEventHandler.hpp"
40 #include "ApoptoticCellProperty.hpp"
41 #include "Cylindrical2dMesh.hpp"
42 #include "Cylindrical2dVertexMesh.hpp"
43 #include "NodesOnlyMesh.hpp"
47 #include "CellAgesWriter.hpp"
48 #include "CellAncestorWriter.hpp"
49 #include "CellProliferativePhasesWriter.hpp"
50 #include "CellProliferativeTypesWriter.hpp"
51 #include "CellVolumesWriter.hpp"
54 #include "CellMutationStatesCountWriter.hpp"
55 #include "CellPopulationElementWriter.hpp"
56 #include "VoronoiDataWriter.hpp"
57 #include "NodeVelocityWriter.hpp"
58 #include "CellPopulationAreaWriter.hpp"
60 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
62 std::vector<CellPtr>& rCells,
63 const std::vector<unsigned> locationIndices,
67 mpVoronoiTessellation(NULL),
68 mDeleteMesh(deleteMesh),
69 mUseAreaBasedDampingConstant(false),
70 mAreaBasedDampingConstantParameter(0.1),
71 mWriteVtkAsPoints(false),
72 mOutputMeshInVtk(false),
73 mHasVariableRestLength(false)
77 assert(this->
mCells.size() <= this->
mrMesh.GetNumNodes());
86 node_iter != this->
rGetMesh().GetNodeIteratorEnd();
89 node_iter->ClearAppliedForce();
93 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
102 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
105 delete mpVoronoiTessellation;
109 delete &this->mrMesh;
113 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
116 return mUseAreaBasedDampingConstant;
119 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
122 assert(SPACE_DIM==2);
123 mUseAreaBasedDampingConstant = useAreaBasedDampingConstant;
126 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
129 return mpMutableMesh->AddNode(pNewNode);
132 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
138 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
148 if (mUseAreaBasedDampingConstant)
159 assert(SPACE_DIM==2);
161 double rest_length = 1.0;
162 double d0 = mAreaBasedDampingConstantParameter;
169 double d1 = 2.0*(1.0 - d0)/(sqrt(3.0)*rest_length*rest_length);
171 double area_cell = GetVolumeOfVoronoiElement(nodeIndex);
178 assert(area_cell < 1000);
180 damping_multiplier = d0 + area_cell*d1;
183 return damping_multiplier;
186 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
189 std::vector<bool> validated_node = std::vector<bool>(this->GetNumNodes(),
false);
193 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
194 validated_node[node_index] =
true;
197 for (
unsigned i=0; i<validated_node.size(); i++)
199 if (!validated_node[i])
206 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
209 return *mpMutableMesh;
212 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
215 return *mpMutableMesh;
218 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
221 unsigned num_removed = 0;
222 for (std::list<CellPtr>::iterator it = this->mCells.begin();
223 it != this->mCells.end();
229 std::vector<const std::pair<CellPtr,CellPtr>*> pairs_to_remove;
230 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->mMarkedSprings.begin();
231 it1 != this->mMarkedSprings.end();
234 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
236 for (
unsigned i=0; i<2; i++)
238 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
243 pairs_to_remove.push_back(&r_pair);
250 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator pair_it = pairs_to_remove.begin();
251 pair_it != pairs_to_remove.end();
254 this->mMarkedSprings.erase(**pair_it);
262 unsigned location_index_of_removed_node = this->GetLocationIndexUsingCell((*it));
263 this->RemoveCellUsingLocationIndex(location_index_of_removed_node, (*it));
266 it = this->mCells.erase(it);
277 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
281 bool output_node_velocities = (this->
template HasWriter<NodeVelocityWriter>());
293 std::map<unsigned, double> old_node_radius_map;
294 old_node_radius_map.clear();
295 if (this->mrMesh.GetNodeIteratorBegin()->HasNodeAttributes())
297 if (this->mrMesh.GetNodeIteratorBegin()->GetRadius() > 0.0)
300 node_iter != this->mrMesh.GetNodeIteratorEnd();
303 unsigned node_index = node_iter->GetIndex();
304 old_node_radius_map[node_index] = node_iter->GetRadius();
309 std::map<unsigned, c_vector<double, SPACE_DIM> > old_node_applied_force_map;
310 old_node_applied_force_map.clear();
311 if (output_node_velocities)
319 node_iter != this->mrMesh.GetNodeIteratorEnd();
322 unsigned node_index = node_iter->GetIndex();
323 old_node_applied_force_map[node_index] = node_iter->rGetAppliedForce();
327 NodeMap node_map(this->mrMesh.GetNumAllNodes());
332 if (!node_map.IsIdentityMap())
334 UpdateGhostNodesAfterReMesh(node_map);
337 std::map<Cell*, unsigned> old_cell_location_map = this->mCellLocationMap;
340 this->mLocationCellMap.clear();
341 this->mCellLocationMap.clear();
343 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
345 unsigned old_node_index = old_cell_location_map[(*it).get()];
348 assert(!node_map.IsDeleted(old_node_index));
350 unsigned new_node_index = node_map.GetNewIndex(old_node_index);
351 this->SetCellUsingLocationIndex(new_node_index,*it);
353 if (old_node_radius_map[old_node_index] > 0.0)
355 this->GetNode(new_node_index)->SetRadius(old_node_radius_map[old_node_index]);
357 if (output_node_velocities)
359 this->GetNode(new_node_index)->AddAppliedForceContribution(old_node_applied_force_map[old_node_index]);
367 if (old_node_radius_map[this->mCellLocationMap[(*(this->mCells.begin())).get()]] > 0.0)
369 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
371 unsigned node_index = this->mCellLocationMap[(*it).get()];
372 this->GetNode(node_index)->SetRadius(old_node_radius_map[node_index]);
375 if (output_node_velocities)
377 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
379 unsigned node_index = this->mCellLocationMap[(*it).get()];
380 this->GetNode(node_index)->AddAppliedForceContribution(old_node_applied_force_map[node_index]);
386 std::vector<const std::pair<CellPtr,CellPtr>*> springs_to_remove;
387 for (std::set<std::pair<CellPtr,CellPtr> >::iterator spring_it = this->mMarkedSprings.begin();
388 spring_it != this->mMarkedSprings.end();
391 CellPtr p_cell_1 = spring_it->first;
392 CellPtr p_cell_2 = spring_it->second;
393 Node<SPACE_DIM>* p_node_1 = this->GetNodeCorrespondingToCell(p_cell_1);
394 Node<SPACE_DIM>* p_node_2 = this->GetNodeCorrespondingToCell(p_cell_2);
404 if (node2_elements.find(*elem_iter) != node2_elements.end())
414 springs_to_remove.push_back(&(*spring_it));
419 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator spring_it = springs_to_remove.begin();
420 spring_it != springs_to_remove.end();
423 this->mMarkedSprings.erase(**spring_it);
427 TessellateIfNeeded();
432 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
435 if ((SPACE_DIM==2 || SPACE_DIM==3)&&(ELEMENT_DIM==SPACE_DIM))
438 if (mUseAreaBasedDampingConstant ||
439 this->
template HasWriter<VoronoiDataWriter>() ||
440 this->
template HasWriter<CellPopulationAreaWriter>() ||
441 this->
template HasWriter<CellVolumesWriter>())
443 CreateVoronoiTessellation();
449 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
453 assert(ELEMENT_DIM==2);
455 std::vector<c_vector<unsigned, 5> > new_nodes;
456 new_nodes = rGetMesh().SplitLongEdges(springDivisionThreshold);
459 for (
unsigned index=0; index<new_nodes.size(); index++)
462 unsigned new_node_index = new_nodes[index][0];
463 unsigned node_a_index = new_nodes[index][1];
464 unsigned node_b_index = new_nodes[index][2];
466 CellPtr p_neighbour_cell = this->GetCellUsingLocationIndex(node_a_index);
474 CellPtr p_new_cell(
new Cell(p_neighbour_cell->GetMutationState(),
475 p_neighbour_cell->GetCellCycleModel()->CreateCellCycleModel(),
476 p_neighbour_cell->GetSrnModel()->CreateSrnModel(),
478 daughter_property_collection));
481 this->mCells.push_back(p_new_cell);
482 this->AddCellUsingLocationIndex(new_node_index,p_new_cell);
487 std::pair<unsigned,unsigned> node_pair = this->CreateOrderedPair(node_a_index, node_b_index);
488 double old_rest_length = mSpringRestLengths[node_pair];
490 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter = mSpringRestLengths.find(node_pair);
491 mSpringRestLengths.erase(iter);
494 node_pair = this->CreateOrderedPair(node_a_index, new_node_index);
495 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
497 node_pair = this->CreateOrderedPair(node_b_index, new_node_index);
498 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
501 for (
unsigned pair_index=3; pair_index<5; pair_index++)
503 unsigned other_node_index = new_nodes[index][pair_index];
507 node_pair = this->CreateOrderedPair(other_node_index, new_node_index);
508 double new_rest_length = rGetMesh().GetDistanceBetweenNodes(new_node_index, other_node_index);
509 mSpringRestLengths[node_pair] = new_rest_length;
515 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
518 return this->mrMesh.GetNode(index);
521 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
524 return this->mrMesh.GetNumAllNodes();
527 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
532 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
540 assert(p_created_cell == pNewCell);
543 std::pair<CellPtr,CellPtr> cell_pair = this->CreateCellPair(pParentCell, p_created_cell);
544 this->MarkSpring(cell_pair);
547 return p_created_cell;
554 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
557 if (this->mOutputResultsForChasteVisualizer)
559 if (!this->
template HasWriter<CellPopulationElementWriter>())
561 this->
template AddPopulationWriter<CellPopulationElementWriter>();
568 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
573 TessellateIfNeeded();
579 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
582 pPopulationWriter->Visit(
this);
585 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
588 pPopulationCountWriter->Visit(
this);
591 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
594 pCellWriter->VisitCell(pCell,
this);
597 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
603 std::stringstream time;
604 time << num_timesteps;
607 unsigned num_cells_from_mesh = GetNumNodes();
608 if (!mWriteVtkAsPoints && (mpVoronoiTessellation != NULL))
610 num_cells_from_mesh = mpVoronoiTessellation->GetNumElements();
614 unsigned num_cell_data_items = this->Begin()->GetCellData()->GetNumItems();
615 std::vector<std::string> cell_data_names = this->Begin()->GetCellData()->GetKeys();
617 std::vector<std::vector<double> > cell_data;
618 for (
unsigned var=0; var<num_cell_data_items; var++)
620 std::vector<double> cell_data_var(num_cells_from_mesh);
621 cell_data.push_back(cell_data_var);
624 if (mOutputMeshInVtk)
631 if (mWriteVtkAsPoints)
637 unsigned num_cells = this->GetNumAllCells();
639 cell_writer_iter != this->mCellWriters.end();
643 std::vector<double> vtk_cell_data(num_cells);
647 cell_iter != this->End();
651 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
654 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(*cell_iter,
this);
657 cells_writer.AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
662 cell_iter != this->End();
666 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
668 for (
unsigned var=0; var<num_cell_data_items; var++)
670 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
673 for (
unsigned var=0; var<num_cell_data_items; var++)
675 cells_writer.AddPointData(cell_data_names[var], cell_data[var]);
680 std::vector<Node<SPACE_DIM>* > nodes;
681 for (
unsigned index=0; index<this->mrMesh.GetNumNodes(); index++)
684 nodes.push_back(p_node);
689 cells_writer.WriteFilesUsingMesh(mesh);
692 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
693 *(this->mpVtkMetaFile) << num_timesteps;
694 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
695 *(this->mpVtkMetaFile) << num_timesteps;
696 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
698 else if (mpVoronoiTessellation != NULL)
702 std::vector<double> cell_volumes(num_cells_from_mesh);
705 unsigned num_cells = this->GetNumAllCells();
707 cell_writer_iter != this->mCellWriters.end();
711 std::vector<double> vtk_cell_data(num_cells);
715 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
719 unsigned elem_index = elem_iter->GetIndex();
722 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
723 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
726 vtk_cell_data[elem_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
729 mesh_writer.
AddCellData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
734 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
738 unsigned elem_index = elem_iter->GetIndex();
741 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
742 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
744 for (
unsigned var=0; var<num_cell_data_items; var++)
746 cell_data[var][elem_index] = p_cell->GetCellData()->GetItem(cell_data_names[var]);
750 for (
unsigned var=0; var<cell_data.size(); var++)
752 mesh_writer.
AddCellData(cell_data_names[var], cell_data[var]);
756 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
757 *(this->mpVtkMetaFile) << num_timesteps;
758 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
759 *(this->mpVtkMetaFile) << num_timesteps;
760 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
765 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
768 double cell_volume = 0;
770 if (ELEMENT_DIM == SPACE_DIM)
773 if (mpVoronoiTessellation == NULL)
775 CreateVoronoiTessellation();
779 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
784 unsigned element_index = mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(node_index);
787 cell_volume = mpVoronoiTessellation->GetVolumeOfElement(element_index);
792 cell_volume = DBL_MAX;
795 else if (SPACE_DIM==3 && ELEMENT_DIM==2)
797 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
809 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacob;
814 cell_volume += fabs(p_element->
GetVolume(det));
829 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
832 mWriteVtkAsPoints = writeVtkAsPoints;
835 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
838 return mWriteVtkAsPoints;
841 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
844 mOutputMeshInVtk = outputMeshInVtk;
847 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
850 return mOutputMeshInVtk;
857 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
863 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
866 return mEdgeIter.GetNodeB();
869 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
872 assert((*
this) != mrCellPopulation.SpringsEnd());
873 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeA()->GetIndex());
876 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
879 assert((*
this) != mrCellPopulation.SpringsEnd());
880 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeB()->GetIndex());
883 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
889 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
892 bool edge_is_ghost =
false;
897 if (*
this != mrCellPopulation.SpringsEnd())
899 bool a_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeA()->GetIndex());
900 bool b_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeB()->GetIndex());
902 edge_is_ghost = (a_is_ghost || b_is_ghost);
905 while (*
this!=mrCellPopulation.SpringsEnd() && edge_is_ghost);
910 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
914 : mrCellPopulation(rCellPopulation),
922 if (a_is_ghost || b_is_ghost)
929 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
935 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
950 bool is_mesh_periodic =
false;
951 if (dynamic_cast<Cylindrical2dMesh*>(&
mrMesh))
953 is_mesh_periodic =
true;
1016 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1023 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1026 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1031 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1034 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1036 return surface_area;
1039 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1042 unsigned element_index1 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index1);
1043 unsigned element_index2 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index2);
1052 EXCEPTION(
"Spring iterator tried to calculate interaction between degenerate cells on the boundary of the mesh. Have you set ghost layers correctly?");
1056 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1060 for (std::list<CellPtr>::iterator it=this->
mCells.begin();
1064 CellPtr p_cell = *it;
1071 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1073 #define COVERAGE_IGNORE //Debugging code. Shouldn't fail under normal conditions
1074 if (p_cell_in_cell_population != p_cell)
1076 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1081 if (p_model->
GetCell() != p_cell)
1083 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1089 #undef COVERAGE_IGNORE
1092 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->
mMarkedSprings.begin();
1096 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
1098 for (
unsigned i=0; i<2; i++)
1100 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
1106 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1108 #define COVERAGE_IGNORE //Debugging code. Shouldn't fail under normal conditions
1110 if (p_cell->IsDead())
1112 std::cout <<
" Cell is dead" << std::endl << std::flush;
1118 if (p_cell_in_cell_population != p_cell)
1120 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1125 if (p_model->
GetCell() != p_cell)
1127 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1131 #undef COVERAGE_IGNORE
1136 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1142 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1145 assert(areaBasedDampingConstantParameter >= 0.0);
1149 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1157 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1162 *rParamsFile <<
"\t\t<WriteVtkAsPoints>" <<
mWriteVtkAsPoints <<
"</WriteVtkAsPoints>\n";
1163 *rParamsFile <<
"\t\t<OutputMeshInVtk>" <<
mOutputMeshInVtk <<
"</OutputMeshInVtk>\n";
1170 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1174 double width = this->
mrMesh.GetWidth(rDimension);
1178 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1185 std::set<unsigned> neighbouring_node_indices;
1194 for (
unsigned i=0; i<p_element->
GetNumNodes(); i++)
1198 if (node_index != index)
1200 neighbouring_node_indices.insert(node_index);
1204 return neighbouring_node_indices;
1207 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1221 unsigned nodeA_global_index = p_nodeA->
GetIndex();
1222 unsigned nodeB_global_index = p_nodeB->
GetIndex();
1225 double separation =
rGetMesh().GetDistanceBetweenNodes(nodeA_global_index, nodeB_global_index);
1228 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(nodeA_global_index, nodeB_global_index);
1235 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1240 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1241 std::map<std::pair<unsigned,unsigned>,
double>::const_iterator iter =
mSpringRestLengths.find(node_pair);
1246 return iter->second;
1250 EXCEPTION(
"Tried to get a rest length of an edge that doesn't exist. You can only use variable rest lengths if SetUpdateCellPopulationRule is set on the simulation.");
1259 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1264 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1265 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter =
mSpringRestLengths.find(node_pair);
1270 iter->second = restLength;
1274 EXCEPTION(
"Tried to set the rest length of an edge not in the mesh.");
1279 EXCEPTION(
"Tried to set a rest length in a simulation with fixed rest length. You can only use variable rest lengths if SetUpdateCellPopulationRule is set on the simulation.");
double GetSurfaceAreaOfVoronoiElement(unsigned index)
double GetVolumeOfVoronoiElement(unsigned index)
SpringIterator SpringsEnd()
void AddCellData(std::string dataName, std::vector< double > dataPayload)
double GetWidth(const unsigned &rDimension)
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
Node< SPACE_DIM > * GetNodeA()
bool GetOutputMeshInVtk()
SpringIterator SpringsBegin()
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
virtual CellPtr AddCell(CellPtr pNewCell, const c_vector< double, SPACE_DIM > &rCellDivisionVector, CellPtr pParentCell)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
virtual unsigned RemoveDeadCells()
unsigned GetLocationIndexUsingCell(CellPtr pCell)
double GetVolume(double determinant) const
double GetDampingConstant(unsigned nodeIndex)
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void DeleteNodePriorToReMesh(unsigned index)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< ELEMENT_DIM, SPACE_DIM > > pCellWriter, CellPtr pCell)
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > & rGetNodePairs()
void CreateVoronoiTessellation()
#define EXCEPTION(message)
static void BeginEvent(unsigned event)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationCountWriter)
static SimulationTime * Instance()
void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > &rNewLocation)
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
std::set< unsigned > & rGetContainingElementIndices()
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
unsigned GetTimeStepsElapsed() const
Node< SPACE_DIM > * GetNodeB()
virtual void WriteResultsToFiles(const std::string &rDirectory)
virtual void SetNode(unsigned index, ChastePoint< SPACE_DIM > point, bool concreteMove=true)
bool mHasVariableRestLength
MutableMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
bool operator!=(const typename MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM >::SpringIterator &rOther)
void TessellateIfNeeded()
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
double GetRestLength(unsigned indexA, unsigned indexB)
void SetWriteVtkAsPoints(bool writeVtkAsPoints)
std::pair< unsigned, unsigned > CreateOrderedPair(unsigned index1, unsigned index2)
MutableMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator mEdgeIter
virtual ~MeshBasedCellPopulation()
ContainingElementIterator ContainingElementsBegin() const
MutableMesh< ELEMENT_DIM, SPACE_DIM > * mpMutableMesh
bool UseAreaBasedDampingConstant()
bool GetWriteVtkAsPoints()
void SetOutputMeshInVtk(bool outputMeshInVtk)
void DivideLongSprings(double springDivisionThreshold)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationWriter)
bool mUseAreaBasedDampingConstant
VertexMesh< ELEMENT_DIM, SPACE_DIM > * mpVoronoiTessellation
unsigned GetNumNodes() const
SpringIterator(MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation, typename MutableMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator edgeIter)
virtual void Update(bool hasHadBirthsOrDeaths=true)
const unsigned UNSIGNED_UNSET
void WriteVtkUsingMesh(VertexMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, std::string stamp="")
virtual void ReMesh(NodeMap &map)
double GetAreaBasedDampingConstantParameter()
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
virtual void UpdateGhostNodesAfterReMesh(NodeMap &rMap)
void SetRestLength(unsigned indexA, unsigned indexB, double restLength)
void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
std::list< CellPtr > mCells
virtual void WriteResultsToFiles(const std::string &rDirectory)
double mAreaBasedDampingConstantParameter
void ConstructNodesWithoutMesh(const std::vector< Node< SPACE_DIM > * > &rNodes, double maxInteractionDistance)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
void SetMeshHasChangedSinceLoading()
SpringIterator & operator++()
void CalculateJacobian(c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant)
Node< SPACE_DIM > * GetNode(unsigned index)
VertexMesh< ELEMENT_DIM, SPACE_DIM > * GetVoronoiTessellation()
CellPtr AddCell(CellPtr pNewCell, const c_vector< double, SPACE_DIM > &rCellDivisionVector, CellPtr pParentCell=CellPtr())
static void EndEvent(unsigned event)
MeshBasedCellPopulation(MutableMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, std::vector< CellPtr > &rCells, const std::vector< unsigned > locationIndices=std::vector< unsigned >(), bool deleteMesh=false, bool validate=true)
unsigned GetIndex() const
double GetVolumeOfCell(CellPtr pCell)
void OutputCellPopulationParameters(out_stream &rParamsFile)
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > mNodePairs
void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter)
AbstractMesh< ELEMENT_DIM, SPACE_DIM > & mrMesh
virtual double GetDampingConstant(unsigned nodeIndex)
std::map< std::pair< unsigned, unsigned >, double > mSpringRestLengths
ContainingElementIterator ContainingElementsEnd() const
std::set< std::pair< CellPtr, CellPtr > > mMarkedSprings
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation
void CalculateRestLengths()