36#include "MeshBasedCellPopulation.hpp"
37#include "VtkMeshWriter.hpp"
38#include "CellBasedEventHandler.hpp"
39#include "Cylindrical2dMesh.hpp"
40#include "Cylindrical2dVertexMesh.hpp"
41#include "Toroidal2dMesh.hpp"
42#include "Toroidal2dVertexMesh.hpp"
43#include "NodesOnlyMesh.hpp"
45#include "CellVolumesWriter.hpp"
46#include "CellPopulationElementWriter.hpp"
47#include "VoronoiDataWriter.hpp"
48#include "NodeVelocityWriter.hpp"
49#include "CellPopulationAreaWriter.hpp"
51template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 std::vector<CellPtr>& rCells,
54 const std::vector<unsigned> locationIndices,
58 mpVoronoiTessellation(nullptr),
59 mDeleteMesh(deleteMesh),
60 mUseAreaBasedDampingConstant(false),
61 mAreaBasedDampingConstantParameter(0.1),
62 mWriteVtkAsPoints(false),
63 mBoundVoronoiTessellation(false),
64 mHasVariableRestLength(false)
68 assert(this->
mCells.size() <= this->mrMesh.GetNumNodes());
77 node_iter != this->
rGetMesh().GetNodeIteratorEnd();
80 node_iter->ClearAppliedForce();
84template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
93template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
96 delete mpVoronoiTessellation;
100 delete &this->mrMesh;
104template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
107 return mUseAreaBasedDampingConstant;
110template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
112 [[maybe_unused]]
bool useAreaBasedDampingConstant)
114 if constexpr (SPACE_DIM == 2)
116 mUseAreaBasedDampingConstant = useAreaBasedDampingConstant;
124template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
127 return mpMutableMesh->AddNode(pNewNode);
130template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
136template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
146 if (mUseAreaBasedDampingConstant)
156 if constexpr (SPACE_DIM == 2)
158 double rest_length = 1.0;
159 double d0 = mAreaBasedDampingConstantParameter;
166 double d1 = 2.0*(1.0 - d0)/(sqrt(3.0)*rest_length*rest_length);
168 double area_cell = GetVolumeOfVoronoiElement(nodeIndex);
175 assert(area_cell < 1000);
177 damping_multiplier = d0 + area_cell*d1;
185 return damping_multiplier;
188template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
191 std::vector<bool> validated_node = std::vector<bool>(this->GetNumNodes(),
false);
195 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
196 validated_node[node_index] =
true;
199 for (
unsigned i=0; i<validated_node.size(); i++)
201 if (!validated_node[i])
208template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
211 return *mpMutableMesh;
214template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
217 return *mpMutableMesh;
220template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
223 return mpMutableMesh;
226template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
229 unsigned num_removed = 0;
230 for (std::list<CellPtr>::iterator it = this->mCells.begin();
231 it != this->mCells.end();
237 std::vector<const std::pair<CellPtr,CellPtr>*> pairs_to_remove;
238 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->mMarkedSprings.begin();
239 it1 != this->mMarkedSprings.end();
242 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
244 for (
unsigned i=0; i<2; i++)
246 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
251 pairs_to_remove.push_back(&r_pair);
258 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator pair_it = pairs_to_remove.begin();
259 pair_it != pairs_to_remove.end();
262 this->mMarkedSprings.erase(**pair_it);
270 unsigned location_index_of_removed_node = this->GetLocationIndexUsingCell((*it));
271 this->RemoveCellUsingLocationIndex(location_index_of_removed_node, (*it));
274 it = this->mCells.erase(it);
285template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
289 bool output_node_velocities = (this->
template HasWriter<NodeVelocityWriter>());
301 std::map<unsigned, double> old_node_radius_map;
302 old_node_radius_map.clear();
303 if (this->mrMesh.GetNodeIteratorBegin()->HasNodeAttributes())
305 if (this->mrMesh.GetNodeIteratorBegin()->GetRadius() > 0.0)
308 node_iter != this->mrMesh.GetNodeIteratorEnd();
311 unsigned node_index = node_iter->GetIndex();
312 old_node_radius_map[node_index] = node_iter->GetRadius();
317 std::map<unsigned, c_vector<double, SPACE_DIM> > old_node_applied_force_map;
318 old_node_applied_force_map.clear();
319 if (output_node_velocities)
327 node_iter != this->mrMesh.GetNodeIteratorEnd();
330 unsigned node_index = node_iter->GetIndex();
331 old_node_applied_force_map[node_index] = node_iter->rGetAppliedForce();
335 NodeMap node_map(this->mrMesh.GetNumAllNodes());
340 if (!node_map.IsIdentityMap())
342 UpdateGhostNodesAfterReMesh(node_map);
345 std::map<Cell*, unsigned> old_cell_location_map = this->mCellLocationMap;
348 this->mLocationCellMap.clear();
349 this->mCellLocationMap.clear();
351 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
353 unsigned old_node_index = old_cell_location_map[(*it).get()];
356 assert(!node_map.IsDeleted(old_node_index));
358 unsigned new_node_index = node_map.GetNewIndex(old_node_index);
359 this->SetCellUsingLocationIndex(new_node_index,*it);
361 if (old_node_radius_map[old_node_index] > 0.0)
363 this->GetNode(new_node_index)->SetRadius(old_node_radius_map[old_node_index]);
365 if (output_node_velocities)
367 this->GetNode(new_node_index)->AddAppliedForceContribution(old_node_applied_force_map[old_node_index]);
375 if (old_node_radius_map[this->mCellLocationMap[(*(this->mCells.begin())).get()]] > 0.0)
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)->SetRadius(old_node_radius_map[node_index]);
383 if (output_node_velocities)
385 for (std::list<CellPtr>::iterator it = this->mCells.begin(); it != this->mCells.end(); ++it)
387 unsigned node_index = this->mCellLocationMap[(*it).get()];
388 this->GetNode(node_index)->AddAppliedForceContribution(old_node_applied_force_map[node_index]);
394 std::vector<const std::pair<CellPtr,CellPtr>*> springs_to_remove;
395 for (std::set<std::pair<CellPtr,CellPtr> >::iterator spring_it = this->mMarkedSprings.begin();
396 spring_it != this->mMarkedSprings.end();
399 CellPtr p_cell_1 = spring_it->first;
400 CellPtr p_cell_2 = spring_it->second;
401 Node<SPACE_DIM>* p_node_1 = this->GetNodeCorrespondingToCell(p_cell_1);
402 Node<SPACE_DIM>* p_node_2 = this->GetNodeCorrespondingToCell(p_cell_2);
412 if (node2_elements.find(*elem_iter) != node2_elements.end())
422 springs_to_remove.push_back(&(*spring_it));
427 for (std::vector<
const std::pair<CellPtr,CellPtr>* >::iterator spring_it = springs_to_remove.begin();
428 spring_it != springs_to_remove.end();
431 this->mMarkedSprings.erase(**spring_it);
435 TessellateIfNeeded();
440template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
443 if ((SPACE_DIM==2 || SPACE_DIM==3)&&(ELEMENT_DIM==SPACE_DIM))
446 if (mUseAreaBasedDampingConstant ||
447 this->
template HasWriter<VoronoiDataWriter>() ||
448 this->
template HasWriter<CellPopulationAreaWriter>() ||
449 this->
template HasWriter<CellVolumesWriter>())
451 CreateVoronoiTessellation();
457template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
461 if constexpr (ELEMENT_DIM == 2)
463 std::vector<c_vector<unsigned, 5> > new_nodes;
464 new_nodes = rGetMesh().SplitLongEdges(springDivisionThreshold);
467 for (
unsigned index=0; index<new_nodes.size(); index++)
470 unsigned new_node_index = new_nodes[index][0];
471 unsigned node_a_index = new_nodes[index][1];
472 unsigned node_b_index = new_nodes[index][2];
474 CellPtr p_neighbour_cell = this->GetCellUsingLocationIndex(node_a_index);
482 CellPtr p_new_cell(
new Cell(p_neighbour_cell->GetMutationState(),
483 p_neighbour_cell->GetCellCycleModel()->CreateCellCycleModel(),
484 p_neighbour_cell->GetSrnModel()->CreateSrnModel(),
486 daughter_property_collection));
489 this->mCells.push_back(p_new_cell);
490 this->AddCellUsingLocationIndex(new_node_index,p_new_cell);
495 std::pair<unsigned,unsigned> node_pair = this->CreateOrderedPair(node_a_index, node_b_index);
496 double old_rest_length = mSpringRestLengths[node_pair];
498 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter = mSpringRestLengths.find(node_pair);
499 mSpringRestLengths.erase(iter);
502 node_pair = this->CreateOrderedPair(node_a_index, new_node_index);
503 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
505 node_pair = this->CreateOrderedPair(node_b_index, new_node_index);
506 mSpringRestLengths[node_pair] = 0.5*old_rest_length;
509 for (
unsigned pair_index=3; pair_index<5; pair_index++)
511 unsigned other_node_index = new_nodes[index][pair_index];
515 node_pair = this->CreateOrderedPair(other_node_index, new_node_index);
516 double new_rest_length = rGetMesh().GetDistanceBetweenNodes(new_node_index, other_node_index);
517 mSpringRestLengths[node_pair] = new_rest_length;
528template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
531 return this->mrMesh.GetNode(index);
534template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
537 return this->mrMesh.GetNumAllNodes();
540template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
545template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
553 assert(p_created_cell == pNewCell);
556 std::pair<CellPtr,CellPtr> cell_pair = this->CreateCellPair(pParentCell, p_created_cell);
557 this->MarkSpring(cell_pair);
560 return p_created_cell;
567template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
570 if (this->mOutputResultsForChasteVisualizer)
572 if (!this->
template HasWriter<CellPopulationElementWriter>())
574 this->
template AddPopulationWriter<CellPopulationElementWriter>();
581template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
586 TessellateIfNeeded();
592template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
595 pPopulationWriter->Visit(
this);
598template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
601 pPopulationCountWriter->Visit(
this);
604template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
607 pPopulationEventWriter->Visit(
this);
610template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
613 pCellWriter->VisitCell(pCell,
this);
616template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
622 std::stringstream time;
623 time << num_timesteps;
626 unsigned num_cells_from_mesh = GetNumNodes();
629 unsigned num_cell_data_items = this->Begin()->GetCellData()->GetNumItems();
630 std::vector<std::string> cell_data_names = this->Begin()->GetCellData()->GetKeys();
632 std::vector<std::vector<double> > cell_data;
633 for (
unsigned var=0; var<num_cell_data_items; var++)
635 std::vector<double> cell_data_var(num_cells_from_mesh);
636 cell_data.push_back(cell_data_var);
639 if (mWriteVtkAsPoints)
645 unsigned num_cells = this->GetNumAllCells();
647 cell_writer_iter != this->mCellWriters.end();
651 std::vector<double> vtk_cell_data(num_cells);
655 cell_iter != this->End();
659 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
662 vtk_cell_data[node_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(*cell_iter,
this);
665 cells_writer.
AddPointData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
670 cell_iter != this->End();
674 unsigned node_index = this->GetLocationIndexUsingCell(*cell_iter);
676 for (
unsigned var=0; var<num_cell_data_items; var++)
678 cell_data[var][node_index] = cell_iter->GetCellData()->GetItem(cell_data_names[var]);
681 for (
unsigned var=0; var<num_cell_data_items; var++)
683 cells_writer.
AddPointData(cell_data_names[var], cell_data[var]);
688 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
689 *(this->mpVtkMetaFile) << num_timesteps;
690 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"mesh_results_";
691 *(this->mpVtkMetaFile) << num_timesteps;
692 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
694 if (mpVoronoiTessellation !=
nullptr)
698 std::vector<double> cell_volumes(num_cells_from_mesh);
701 unsigned num_cells = this->GetNumAllCells();
703 cell_writer_iter != this->mCellWriters.end();
707 std::vector<double> vtk_cell_data(num_cells);
711 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
715 unsigned elem_index = elem_iter->GetIndex();
718 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
719 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
722 vtk_cell_data[elem_index] = (*cell_writer_iter)->GetCellDataForVtkOutput(p_cell,
this);
725 mesh_writer.
AddCellData((*cell_writer_iter)->GetVtkCellDataName(), vtk_cell_data);
730 elem_iter != mpVoronoiTessellation->GetElementIteratorEnd();
734 unsigned elem_index = elem_iter->GetIndex();
737 unsigned node_index = mpVoronoiTessellation->GetDelaunayNodeIndexCorrespondingToVoronoiElementIndex(elem_index);
738 CellPtr p_cell = this->GetCellUsingLocationIndex(node_index);
740 for (
unsigned var=0; var<num_cell_data_items; var++)
742 cell_data[var][elem_index] = p_cell->GetCellData()->GetItem(cell_data_names[var]);
746 for (
unsigned var=0; var<cell_data.size(); var++)
748 mesh_writer.
AddCellData(cell_data_names[var], cell_data[var]);
752 *(this->mpVtkMetaFile) <<
" <DataSet timestep=\"";
753 *(this->mpVtkMetaFile) << num_timesteps;
754 *(this->mpVtkMetaFile) <<
"\" group=\"\" part=\"0\" file=\"voronoi_results_";
755 *(this->mpVtkMetaFile) << num_timesteps;
756 *(this->mpVtkMetaFile) <<
".vtu\"/>\n";
761template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
764 double cell_volume = 0;
766 if (ELEMENT_DIM == SPACE_DIM)
769 if (mpVoronoiTessellation ==
nullptr)
771 CreateVoronoiTessellation();
775 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
780 unsigned element_index = mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(node_index);
783 cell_volume = mpVoronoiTessellation->GetVolumeOfElement(element_index);
788 cell_volume = DBL_MAX;
791 else if (SPACE_DIM==3 && ELEMENT_DIM==2)
793 unsigned node_index = this->GetLocationIndexUsingCell(pCell);
805 c_matrix<double, SPACE_DIM, ELEMENT_DIM> jacob;
810 cell_volume += fabs(p_element->
GetVolume(det));
825template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
828 mWriteVtkAsPoints = writeVtkAsPoints;
831template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
834 return mWriteVtkAsPoints;
837template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
840 mBoundVoronoiTessellation = boundVoronoiTessellation;
843template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
846 return mBoundVoronoiTessellation;
849template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
854 *pVizSetupFile <<
"MeshWidth\t" << this->GetWidth(0) <<
"\n";
858 *pVizSetupFile <<
"MeshWidth\t" << this->GetWidth(0) <<
"\n";
859 *pVizSetupFile <<
"MeshHeight\t" << this->GetWidth(1) <<
"\n";
863template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
866 if constexpr (ELEMENT_DIM == 1)
871 else if constexpr (ELEMENT_DIM == 2 && SPACE_DIM == 2)
873 delete mpVoronoiTessellation;
876 bool is_mesh_periodic =
false;
879 is_mesh_periodic =
true;
884 is_mesh_periodic =
true;
892 else if constexpr (ELEMENT_DIM == 3)
897 delete mpVoronoiTessellation;
910template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
916template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
919 return mEdgeIter.GetNodeB();
922template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
925 assert((*
this) != mrCellPopulation.SpringsEnd());
926 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeA()->GetIndex());
929template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
932 assert((*
this) != mrCellPopulation.SpringsEnd());
933 return mrCellPopulation.GetCellUsingLocationIndex(mEdgeIter.GetNodeB()->GetIndex());
936template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
942template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
945 bool edge_is_ghost =
false;
950 if (*
this != mrCellPopulation.SpringsEnd())
952 bool a_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeA()->GetIndex());
953 bool b_is_ghost = mrCellPopulation.IsGhostNode(mEdgeIter.GetNodeB()->GetIndex());
955 edge_is_ghost = (a_is_ghost || b_is_ghost);
958 while (*
this!=mrCellPopulation.SpringsEnd() && edge_is_ghost);
963template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
967 : mrCellPopulation(rCellPopulation),
975 if (a_is_ghost || b_is_ghost)
982template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
988template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
994template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1001template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1004 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1009template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1012 unsigned element_index =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index);
1014 return surface_area;
1017template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1020 unsigned element_index1 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index1);
1021 unsigned element_index2 =
mpVoronoiTessellation->GetVoronoiElementIndexCorrespondingToDelaunayNodeIndex(index2);
1030 EXCEPTION(
"Spring iterator tried to calculate interaction between degenerate cells on the boundary of the mesh. Have you set ghost layers correctly?");
1034template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1038 for (std::list<CellPtr>::iterator it=this->
mCells.begin();
1042 CellPtr p_cell = *it;
1049 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1052 if (p_cell_in_cell_population != p_cell)
1054 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1059 if (p_model->
GetCell() != p_cell)
1061 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1070 for (std::set<std::pair<CellPtr,CellPtr> >::iterator it1 = this->
mMarkedSprings.begin();
1074 const std::pair<CellPtr,CellPtr>& r_pair = *it1;
1076 for (
unsigned i=0; i<2; i++)
1078 CellPtr p_cell = (i==0 ? r_pair.first : r_pair.second);
1084 std::cout <<
"Cell at node " << node_index <<
" addr " << p_cell << std::endl << std::flush;
1088 if (p_cell->IsDead())
1090 std::cout <<
" Cell is dead" << std::endl << std::flush;
1096 if (p_cell_in_cell_population != p_cell)
1098 std::cout <<
" Mismatch with cell population" << std::endl << std::flush;
1103 if (p_model->
GetCell() != p_cell)
1105 std::cout <<
" Mismatch with cycle model" << std::endl << std::flush;
1114template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1120template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1123 assert(areaBasedDampingConstantParameter >= 0.0);
1128template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1137template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1142 *rParamsFile <<
"\t\t<WriteVtkAsPoints>" <<
mWriteVtkAsPoints <<
"</WriteVtkAsPoints>\n";
1150template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1154 double width = this->
mrMesh.GetWidth(rDimension);
1158template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1165 std::set<unsigned> neighbouring_node_indices;
1174 for (
unsigned i=0; i<p_element->
GetNumNodes(); i++)
1178 if (node_index != index)
1180 neighbouring_node_indices.insert(node_index);
1184 return neighbouring_node_indices;
1187template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1201 unsigned nodeA_global_index = p_nodeA->
GetIndex();
1202 unsigned nodeB_global_index = p_nodeB->
GetIndex();
1205 double separation =
rGetMesh().GetDistanceBetweenNodes(nodeA_global_index, nodeB_global_index);
1208 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(nodeA_global_index, nodeB_global_index);
1215template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1220 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1221 std::map<std::pair<unsigned,unsigned>,
double>::const_iterator iter =
mSpringRestLengths.find(node_pair);
1226 return iter->second;
1230 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.");
1239template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
1244 std::pair<unsigned,unsigned> node_pair = this->
CreateOrderedPair(indexA, indexB);
1245 std::map<std::pair<unsigned,unsigned>,
double>::iterator iter =
mSpringRestLengths.find(node_pair);
1250 iter->second = restLength;
1254 EXCEPTION(
"Tried to set the rest length of an edge not in the mesh.");
1259 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.");
#define EXCEPTION(message)
const unsigned UNSIGNED_UNSET
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
AbstractMesh< ELEMENT_DIM, SPACE_DIM > & mrMesh
std::list< CellPtr > mCells
unsigned GetLocationIndexUsingCell(CellPtr pCell)
virtual void WriteResultsToFiles(const std::string &rDirectory)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
std::pair< unsigned, unsigned > CreateOrderedPair(unsigned index1, unsigned index2)
std::set< std::pair< CellPtr, CellPtr > > mMarkedSprings
virtual void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual double GetDampingConstant(unsigned nodeIndex)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
unsigned GetNumNodes() const
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void SetMeshHasChangedSinceLoading()
double GetVolume(double determinant) const
void CalculateJacobian(c_matrix< double, SPACE_DIM, ELEMENT_DIM > &rJacobian, double &rJacobianDeterminant)
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
static void BeginEvent(unsigned event)
static void EndEvent(unsigned event)
MutableMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator mEdgeIter
MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation
bool operator!=(const typename MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM >::SpringIterator &rOther)
SpringIterator(MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation, typename MutableMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator edgeIter)
SpringIterator & operator++()
Node< SPACE_DIM > * GetNodeA()
Node< SPACE_DIM > * GetNodeB()
bool UseAreaBasedDampingConstant()
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > mNodePairs
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > & rGetNodePairs()
std::map< std::pair< unsigned, unsigned >, double > mSpringRestLengths
void TessellateIfNeeded()
void OutputCellPopulationParameters(out_stream &rParamsFile)
bool GetBoundVoronoiTessellation()
virtual void WriteResultsToFiles(const std::string &rDirectory)
bool mBoundVoronoiTessellation
virtual void Update(bool hasHadBirthsOrDeaths=true)
bool mUseAreaBasedDampingConstant
bool mHasVariableRestLength
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationWriter)
double GetDampingConstant(unsigned nodeIndex)
virtual ~MeshBasedCellPopulation()
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< ELEMENT_DIM, SPACE_DIM > > pCellWriter, CellPtr pCell)
void SetWriteVtkAsPoints(bool writeVtkAsPoints)
double GetWidth(const unsigned &rDimension)
MeshBasedCellPopulation(MutableMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, std::vector< CellPtr > &rCells, const std::vector< unsigned > locationIndices={}, bool deleteMesh=false, bool validate=true)
SpringIterator SpringsEnd()
void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > &rNewLocation)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationEventWriter)
void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual TetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetTetrahedralMeshForPdeModifier()
SpringIterator SpringsBegin()
VertexMesh< ELEMENT_DIM, SPACE_DIM > * mpVoronoiTessellation
virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
double GetSurfaceAreaOfVoronoiElement(unsigned index)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
Node< SPACE_DIM > * GetNode(unsigned index)
virtual void UpdateGhostNodesAfterReMesh(NodeMap &rMap)
void SetBoundVoronoiTessellation(bool boundVoronoiTessellation)
void CreateVoronoiTessellation()
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationCountWriter)
double GetVolumeOfVoronoiElement(unsigned index)
virtual unsigned RemoveDeadCells()
void SetRestLength(unsigned indexA, unsigned indexB, double restLength)
bool GetWriteVtkAsPoints()
double mAreaBasedDampingConstantParameter
virtual void WriteDataToVisualizerSetupFile(out_stream &pVizSetupFile)
VertexMesh< ELEMENT_DIM, SPACE_DIM > * GetVoronoiTessellation()
MutableMesh< ELEMENT_DIM, SPACE_DIM > * mpMutableMesh
void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter)
void DivideLongSprings(double springDivisionThreshold)
double GetRestLength(unsigned indexA, unsigned indexB)
double GetVolumeOfCell(CellPtr pCell)
MutableMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
double GetAreaBasedDampingConstantParameter()
void CalculateRestLengths()
virtual void ReMesh(NodeMap &map)
void DeleteNodePriorToReMesh(unsigned index)
virtual void SetNode(unsigned index, ChastePoint< SPACE_DIM > point, bool concreteMove=true)
ContainingElementIterator ContainingElementsEnd() const
std::set< unsigned > & rGetContainingElementIndices()
ContainingElementIterator ContainingElementsBegin() const
unsigned GetIndex() const
static SimulationTime * Instance()
unsigned GetTimeStepsElapsed() const
void WriteVtkUsingMesh(VertexMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, std::string stamp="")
void AddCellData(std::string dataName, std::vector< double > dataPayload)
void AddPointData(std::string name, std::vector< double > data)
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)