36 #include "MeshBasedCellPopulation.hpp"
37 #include "VtkMeshWriter.hpp"
38 #include "CellBasedEventHandler.hpp"
39 #include "Cylindrical2dMesh.hpp"
40 #include "Cylindrical2dVertexMesh.hpp"
41 #include "NodesOnlyMesh.hpp"
43 #include "CellVolumesWriter.hpp"
44 #include "CellPopulationElementWriter.hpp"
45 #include "VoronoiDataWriter.hpp"
46 #include "NodeVelocityWriter.hpp"
47 #include "CellPopulationAreaWriter.hpp"
49 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
51 std::vector<CellPtr>& rCells,
52 const std::vector<unsigned> locationIndices,
56 mpVoronoiTessellation(nullptr),
57 mDeleteMesh(deleteMesh),
58 mUseAreaBasedDampingConstant(false),
59 mAreaBasedDampingConstantParameter(0.1),
60 mWriteVtkAsPoints(false),
61 mOutputMeshInVtk(false),
62 mHasVariableRestLength(false)
66 assert(this->
mCells.size() <= this->
mrMesh.GetNumNodes());
75 node_iter != this->
rGetMesh().GetNodeIteratorEnd();
78 node_iter->ClearAppliedForce();
82 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
91 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
94 delete mpVoronoiTessellation;
102 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
105 return mUseAreaBasedDampingConstant;
108 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
111 assert(SPACE_DIM == 2);
112 mUseAreaBasedDampingConstant = useAreaBasedDampingConstant;
115 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
118 return mpMutableMesh->AddNode(pNewNode);
121 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
127 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
137 if (mUseAreaBasedDampingConstant)
147 assert(SPACE_DIM == 2);
149 double rest_length = 1.0;
150 double d0 = mAreaBasedDampingConstantParameter;
157 double d1 = 2.0*(1.0 - d0)/(sqrt(3.0)*rest_length*rest_length);
159 double area_cell = GetVolumeOfVoronoiElement(nodeIndex);
166 assert(area_cell < 1000);
168 damping_multiplier = d0 + area_cell*d1;
171 return damping_multiplier;
174 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
177 std::vector<bool> validated_node = std::vector<bool>(this->GetNumNodes(),
false);
181 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
182 validated_node[node_index] =
true;
185 for (
unsigned i=0; i<validated_node.size(); i++)
187 if (!validated_node[i])
194 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
197 return *mpMutableMesh;
200 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
203 return *mpMutableMesh;
206 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
209 return mpMutableMesh;
212 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
215 unsigned num_removed = 0;
216 for (std::list<CellPtr>::iterator it = this->mCells.begin();
217 it != this->mCells.end();
223 std::vector<const std::pair<CellPtr,CellPtr>*> pairs_to_remove;
224 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->mMarkedSprings.begin();
225 it1 != this->mMarkedSprings.end();
228 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
230 for (
unsigned i=0; i<2; i++)
232 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
237 pairs_to_remove.push_back(&r_pair);
244 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator pair_it = pairs_to_remove.begin();
245 pair_it != pairs_to_remove.end();
248 this->mMarkedSprings.erase(**pair_it);
256 unsigned location_index_of_removed_node = this->GetLocationIndexUsingCell((*it));
257 this->RemoveCellUsingLocationIndex(location_index_of_removed_node, (*it));
260 it = this->mCells.erase(it);
271 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
275 bool output_node_velocities = (this->
template HasWriter<NodeVelocityWriter>());
287 std::map<unsigned, double> old_node_radius_map;
288 old_node_radius_map.clear();
289 if (this->mrMesh.GetNodeIteratorBegin()->HasNodeAttributes())
291 if (this->mrMesh.GetNodeIteratorBegin()->GetRadius() > 0.0)
294 node_iter != this->mrMesh.GetNodeIteratorEnd();
297 unsigned node_index = node_iter->GetIndex();
298 old_node_radius_map[node_index] = node_iter->GetRadius();
303 std::map<unsigned, c_vector<double, SPACE_DIM> > old_node_applied_force_map;
304 old_node_applied_force_map.clear();
305 if (output_node_velocities)
313 node_iter != this->mrMesh.GetNodeIteratorEnd();
316 unsigned node_index = node_iter->GetIndex();
317 old_node_applied_force_map[node_index] = node_iter->rGetAppliedForce();
321 NodeMap node_map(this->mrMesh.GetNumAllNodes());
326 if (!node_map.IsIdentityMap())
328 UpdateGhostNodesAfterReMesh(node_map);
331 std::map<Cell*, unsigned> old_cell_location_map = this->mCellLocationMap;
334 this->mLocationCellMap.clear();
335 this->mCellLocationMap.clear();
337 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
339 unsigned old_node_index = old_cell_location_map[(*it).get()];
342 assert(!node_map.IsDeleted(old_node_index));
344 unsigned new_node_index = node_map.GetNewIndex(old_node_index);
345 this->SetCellUsingLocationIndex(new_node_index,*it);
347 if (old_node_radius_map[old_node_index] > 0.0)
349 this->GetNode(new_node_index)->SetRadius(old_node_radius_map[old_node_index]);
351 if (output_node_velocities)
353 this->GetNode(new_node_index)->AddAppliedForceContribution(old_node_applied_force_map[old_node_index]);
361 if (old_node_radius_map[this->mCellLocationMap[(*(this->mCells.begin())).get()]] > 0.0)
363 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
365 unsigned node_index = this->mCellLocationMap[(*it).get()];
366 this->GetNode(node_index)->SetRadius(old_node_radius_map[node_index]);
369 if (output_node_velocities)
371 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
373 unsigned node_index = this->mCellLocationMap[(*it).get()];
374 this->GetNode(node_index)->AddAppliedForceContribution(old_node_applied_force_map[node_index]);
380 std::vector<const std::pair<CellPtr,CellPtr>*> springs_to_remove;
381 for (std::set<std::pair<CellPtr,CellPtr> >::iterator spring_it = this->mMarkedSprings.begin();
382 spring_it != this->mMarkedSprings.end();
385 CellPtr p_cell_1 = spring_it->first;
386 CellPtr p_cell_2 = spring_it->second;
387 Node<SPACE_DIM>* p_node_1 = this->GetNodeCorrespondingToCell(p_cell_1);
388 Node<SPACE_DIM>* p_node_2 = this->GetNodeCorrespondingToCell(p_cell_2);
398 if (node2_elements.find(*elem_iter) != node2_elements.end())
408 springs_to_remove.push_back(&(*spring_it));
413 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator spring_it = springs_to_remove.begin();
414 spring_it != springs_to_remove.end();
417 this->mMarkedSprings.erase(**spring_it);
421 TessellateIfNeeded();
426 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
429 if ((SPACE_DIM==2 || SPACE_DIM==3)&&(ELEMENT_DIM==SPACE_DIM))
432 if (mUseAreaBasedDampingConstant ||
433 this->
template HasWriter<VoronoiDataWriter>() ||
434 this->
template HasWriter<CellPopulationAreaWriter>() ||
435 this->
template HasWriter<CellVolumesWriter>())
437 CreateVoronoiTessellation();
443 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
447 assert(ELEMENT_DIM == 2);
449 std::vector<c_vector<unsigned, 5> > new_nodes;
450 new_nodes = rGetMesh().SplitLongEdges(springDivisionThreshold);
453 for (
unsigned index=0; index<new_nodes.size(); index++)
456 unsigned new_node_index = new_nodes[index][0];
457 unsigned node_a_index = new_nodes[index][1];
458 unsigned node_b_index = new_nodes[index][2];
460 CellPtr p_neighbour_cell = this->GetCellUsingLocationIndex(node_a_index);
468 CellPtr p_new_cell(
new Cell(p_neighbour_cell->GetMutationState(),
469 p_neighbour_cell->GetCellCycleModel()->CreateCellCycleModel(),
470 p_neighbour_cell->GetSrnModel()->CreateSrnModel(),
472 daughter_property_collection));
475 this->mCells.push_back(p_new_cell);
476 this->AddCellUsingLocationIndex(new_node_index,p_new_cell);
481 std::pair<unsigned,unsigned> node_pair = this->CreateOrderedPair(node_a_index, node_b_index);
482 double old_rest_length = mSpringRestLengths[node_pair];
484 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter = mSpringRestLengths.find(node_pair);
485 mSpringRestLengths.erase(iter);
488 node_pair = this->CreateOrderedPair(node_a_index, new_node_index);
489 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
491 node_pair = this->CreateOrderedPair(node_b_index, new_node_index);
492 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
495 for (
unsigned pair_index=3; pair_index<5; pair_index++)
497 unsigned other_node_index = new_nodes[index][pair_index];
501 node_pair = this->CreateOrderedPair(other_node_index, new_node_index);
502 double new_rest_length = rGetMesh().GetDistanceBetweenNodes(new_node_index, other_node_index);
503 mSpringRestLengths[node_pair] = new_rest_length;
509 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
512 return this->mrMesh.GetNode(index);
515 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
518 return this->mrMesh.GetNumAllNodes();
521 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
526 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
534 assert(p_created_cell == pNewCell);
537 std::pair<CellPtr,CellPtr> cell_pair = this->CreateCellPair(pParentCell, p_created_cell);
538 this->MarkSpring(cell_pair);
541 return p_created_cell;
548 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
551 if (this->mOutputResultsForChasteVisualizer)
553 if (!this->
template HasWriter<CellPopulationElementWriter>())
555 this->
template AddPopulationWriter<CellPopulationElementWriter>();
562 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
567 TessellateIfNeeded();
573 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
576 pPopulationWriter->Visit(
this);
579 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
582 pPopulationCountWriter->Visit(
this);
585 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
588 pCellWriter->VisitCell(pCell,
this);
591 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
597 std::stringstream time;
598 time << num_timesteps;
601 unsigned num_cells_from_mesh = GetNumNodes();
602 if (!mWriteVtkAsPoints && (mpVoronoiTessellation !=
nullptr))
604 num_cells_from_mesh = mpVoronoiTessellation->GetNumElements();
608 unsigned num_cell_data_items = this->Begin()->GetCellData()->GetNumItems();
609 std::vector<std::string> cell_data_names = this->Begin()->GetCellData()->GetKeys();
611 std::vector<std::vector<double> > cell_data;
612 for (
unsigned var=0; var<num_cell_data_items; var++)
614 std::vector<double> cell_data_var(num_cells_from_mesh);
615 cell_data.push_back(cell_data_var);
618 if (mOutputMeshInVtk)
625 if (mWriteVtkAsPoints)
631 unsigned num_cells = this->GetNumAllCells();
633 cell_writer_iter != this->mCellWriters.end();
637 std::vector<double> vtk_cell_data(num_cells);
641 cell_iter != this->End();
645 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
648 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(*cell_iter,
this);
651 cells_writer.AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
656 cell_iter != this->End();
660 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
662 for (
unsigned var=0; var<num_cell_data_items; var++)
664 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
667 for (
unsigned var=0; var<num_cell_data_items; var++)
669 cells_writer.AddPointData(cell_data_names[var], cell_data[var]);
674 std::vector<Node<SPACE_DIM>* > nodes;
675 for (
unsigned index=0; index<this->mrMesh.GetNumNodes(); index++)
678 nodes.push_back(p_node);
683 cells_writer.WriteFilesUsingMesh(mesh);
686 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
687 *(this->mpVtkMetaFile) << num_timesteps;
688 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
689 *(this->mpVtkMetaFile) << num_timesteps;
690 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
692 else if (mpVoronoiTessellation !=
nullptr)
696 std::vector<double> cell_volumes(num_cells_from_mesh);
699 unsigned num_cells = this->GetNumAllCells();
701 cell_writer_iter != this->mCellWriters.end();
705 std::vector<double> vtk_cell_data(num_cells);
709 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
713 unsigned elem_index = elem_iter->GetIndex();
716 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
717 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
720 vtk_cell_data[elem_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
723 mesh_writer.
AddCellData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
728 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
732 unsigned elem_index = elem_iter->GetIndex();
735 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
736 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
738 for (
unsigned var=0; var<num_cell_data_items; var++)
740 cell_data[var][elem_index] = p_cell->GetCellData()->GetItem(cell_data_names[var]);
744 for (
unsigned var=0; var<cell_data.size(); var++)
746 mesh_writer.
AddCellData(cell_data_names[var], cell_data[var]);
750 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
751 *(this->mpVtkMetaFile) << num_timesteps;
752 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"results_";
753 *(this->mpVtkMetaFile) << num_timesteps;
754 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
759 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
762 double cell_volume = 0;
764 if (ELEMENT_DIM == SPACE_DIM)
767 if (mpVoronoiTessellation ==
nullptr)
769 CreateVoronoiTessellation();
773 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
778 unsigned element_index = mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(node_index);
781 cell_volume = mpVoronoiTessellation->GetVolumeOfElement(element_index);
786 cell_volume = DBL_MAX;
789 else if (SPACE_DIM==3 && ELEMENT_DIM==2)
791 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
803 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacob;
808 cell_volume += fabs(p_element->
GetVolume(det));
823 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
826 mWriteVtkAsPoints = writeVtkAsPoints;
829 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
832 return mWriteVtkAsPoints;
835 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
838 mOutputMeshInVtk = outputMeshInVtk;
841 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
844 return mOutputMeshInVtk;
847 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
850 if (
bool(dynamic_cast<Cylindrical2dMesh*>(&(this->mrMesh))))
852 *pVizSetupFile <<
"MeshWidth\t" << this->GetWidth(0) <<
"\n";
860 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
866 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
869 return mEdgeIter.GetNodeB();
872 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
875 assert((*
this) != mrCellPopulation.SpringsEnd());
876 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeA()->GetIndex());
879 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
882 assert((*
this) != mrCellPopulation.SpringsEnd());
883 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeB()->GetIndex());
886 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
892 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
895 bool edge_is_ghost =
false;
900 if (*
this != mrCellPopulation.SpringsEnd())
902 bool a_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeA()->GetIndex());
903 bool b_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeB()->GetIndex());
905 edge_is_ghost = (a_is_ghost || b_is_ghost);
908 while (*
this!=mrCellPopulation.SpringsEnd() && edge_is_ghost);
913 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
917 : mrCellPopulation(rCellPopulation),
925 if (a_is_ghost || b_is_ghost)
932 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
938 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
953 bool is_mesh_periodic =
false;
954 if (
bool(dynamic_cast<Cylindrical2dMesh*>(&
mrMesh)))
956 is_mesh_periodic =
true;
1029 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1036 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1039 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1044 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1047 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1049 return surface_area;
1052 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1055 unsigned element_index1 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index1);
1056 unsigned element_index2 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index2);
1065 EXCEPTION(
"Spring iterator tried to calculate interaction between degenerate cells on the boundary of the mesh. Have you set ghost layers correctly?");
1069 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1073 for (std::list<CellPtr>::iterator it=this->
mCells.begin();
1077 CellPtr p_cell = *it;
1084 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1087 if (p_cell_in_cell_population != p_cell)
1089 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1094 if (p_model->
GetCell() != p_cell)
1096 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1105 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->
mMarkedSprings.begin();
1109 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
1111 for (
unsigned i=0; i<2; i++)
1113 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
1119 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1123 if (p_cell->IsDead())
1125 std::cout <<
" Cell is dead" << std::endl << std::flush;
1131 if (p_cell_in_cell_population != p_cell)
1133 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1138 if (p_model->
GetCell() != p_cell)
1140 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1149 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1155 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1158 assert(areaBasedDampingConstantParameter >= 0.0);
1163 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1172 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1177 *rParamsFile <<
"\t\t<WriteVtkAsPoints>" <<
mWriteVtkAsPoints <<
"</WriteVtkAsPoints>\n";
1178 *rParamsFile <<
"\t\t<OutputMeshInVtk>" <<
mOutputMeshInVtk <<
"</OutputMeshInVtk>\n";
1185 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1189 double width = this->
mrMesh.GetWidth(rDimension);
1193 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1200 std::set<unsigned> neighbouring_node_indices;
1209 for (
unsigned i=0; i<p_element->
GetNumNodes(); i++)
1213 if (node_index != index)
1215 neighbouring_node_indices.insert(node_index);
1219 return neighbouring_node_indices;
1222 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1236 unsigned nodeA_global_index = p_nodeA->
GetIndex();
1237 unsigned nodeB_global_index = p_nodeB->
GetIndex();
1240 double separation =
rGetMesh().GetDistanceBetweenNodes(nodeA_global_index, nodeB_global_index);
1243 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(nodeA_global_index, nodeB_global_index);
1250 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1255 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1256 std::map<std::pair<unsigned,unsigned>,
double>::const_iterator iter =
mSpringRestLengths.find(node_pair);
1261 return iter->second;
1265 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.");
1274 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1279 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1280 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter =
mSpringRestLengths.find(node_pair);
1285 iter->second = restLength;
1289 EXCEPTION(
"Tried to set the rest length of an edge not in the mesh.");
1294 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()
virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
SpringIterator SpringsBegin()
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
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()
virtual void WriteDataToVisualizerSetupFile(out_stream &pVizSetupFile)
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)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
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()
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
virtual TetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetTetrahedralMeshForPdeModifier()
std::set< std::pair< CellPtr, CellPtr > > mMarkedSprings
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation
void CalculateRestLengths()