36 #include "HeterotypicBoundaryLengthWriter.hpp" 38 #include "AbstractCellPopulation.hpp" 39 #include "MeshBasedCellPopulation.hpp" 40 #include "CaBasedCellPopulation.hpp" 41 #include "NodeBasedCellPopulation.hpp" 42 #include "PottsBasedCellPopulation.hpp" 43 #include "VertexBasedCellPopulation.hpp" 45 #include "CellLabel.hpp" 47 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
57 double heterotypic_boundary_length = 0.0;
58 double total_shared_edges_length = 0.0;
59 double num_heterotypic_pairs = 0.0;
60 double total_num_pairs = 0.0;
68 cell_iter != pCellPopulation->
End();
75 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
81 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
82 neighbour_iter != neighbour_indices.end();
86 unsigned neighbour_index = *neighbour_iter;
93 total_shared_edges_length += edge_length;
94 total_num_pairs += 1.0;
98 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
101 if (cell_is_labelled != neighbour_is_labelled)
104 heterotypic_boundary_length += edge_length;
105 num_heterotypic_pairs += 1.0;
112 heterotypic_boundary_length *= 0.5;
113 total_shared_edges_length *= 0.5;
116 num_heterotypic_pairs *= 0.5;
117 total_num_pairs *= 0.5;
119 *this->
mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
122 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
126 double heterotypic_boundary_length = 0.0;
127 double total_shared_edges_length = 0.0;
128 double num_heterotypic_pairs = 0.0;
129 double total_num_pairs = 0.0;
133 cell_iter != pCellPopulation->
End();
140 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
143 std::set<unsigned> neighbour_node_indices = pCellPopulation->
rGetMesh().GetVonNeumannNeighbouringNodeIndices(index);
146 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
147 neighbour_iter != neighbour_node_indices.end();
151 double edge_length = 1.0;
153 unsigned neighbour_index = *neighbour_iter;
159 total_shared_edges_length += edge_length;
160 total_num_pairs += 1.0;
163 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
166 if (cell_is_labelled != neighbour_is_labelled)
169 heterotypic_boundary_length += edge_length;
170 num_heterotypic_pairs += 1.0;
177 heterotypic_boundary_length *= 0.5;
178 total_shared_edges_length *= 0.5;
181 num_heterotypic_pairs *= 0.5;
182 total_num_pairs *= 0.5;
184 *this->
mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
187 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
192 pCellPopulation->
Update();
195 double heterotypic_boundary_length = 0.0;
196 double total_shared_edges_length = 0.0;
197 double num_heterotypic_pairs = 0.0;
198 double total_num_pairs = 0.0;
202 cell_iter != pCellPopulation->
End();
206 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
210 double node_radius = pCellPopulation->
GetNode(node_index)->GetRadius();
215 if (!neighbour_indices.empty())
218 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
219 neighbour_iter != neighbour_indices.end();
223 double neighbour_radius = pCellPopulation->
GetNode(*neighbour_iter)->GetRadius();
227 double sum_of_radii = node_radius + neighbour_radius;
230 if (separation < sum_of_radii)
233 double a = node_radius;
234 double b = neighbour_radius;
235 double c = separation;
236 double s = 0.5*(a + b + c);
237 double A = sqrt(s*(s-a)*(s-b)*(s-c));
238 double edge_length = 4.0*A/c;
240 total_shared_edges_length += edge_length;
241 total_num_pairs += 1.0;
245 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
248 if (cell_is_labelled != neighbour_is_labelled)
251 heterotypic_boundary_length += edge_length;
252 num_heterotypic_pairs += 1.0;
260 heterotypic_boundary_length *= 0.5;
261 total_shared_edges_length *= 0.5;
264 num_heterotypic_pairs *= 0.5;
265 total_num_pairs *= 0.5;
267 *this->
mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
270 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
276 double heterotypic_boundary_length = 0.0;
277 double total_shared_edges_length = 0.0;
278 double num_heterotypic_pairs = 0.0;
279 double total_num_pairs = 0.0;
283 cell_iter != pCellPopulation->
End();
287 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
290 unsigned num_nodes_in_elem = pCellPopulation->
rGetMesh().GetElement(elem_index)->GetNumNodes();
293 for (
unsigned local_index=0; local_index<num_nodes_in_elem; local_index++)
296 unsigned global_index = pCellPopulation->
rGetMesh().GetElement(elem_index)->GetNodeGlobalIndex(local_index);
297 std::set<unsigned> neighbour_node_indices = pCellPopulation->
rGetMesh().GetVonNeumannNeighbouringNodeIndices(global_index);
300 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
301 neighbour_iter != neighbour_node_indices.end();
305 std::set<unsigned> neighbour_elem_indices = pCellPopulation->
GetNode(*neighbour_iter)->rGetContainingElementIndices();
307 if (neighbour_elem_indices.size() == 1)
309 unsigned neigbour_elem_index = *(neighbour_elem_indices.begin());
311 if (neigbour_elem_index != elem_index)
314 total_shared_edges_length += 1.0;
318 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
321 if (cell_is_labelled != neighbour_is_labelled)
324 heterotypic_boundary_length += 1.0;
338 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
339 neighbour_iter != neighbour_node_indices.end();
342 total_num_pairs += 1.0;
345 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
348 if (cell_is_labelled != neighbour_is_labelled)
351 num_heterotypic_pairs += 1.0;
357 heterotypic_boundary_length *= 0.5;
358 total_shared_edges_length *= 0.5;
361 num_heterotypic_pairs *= 0.5;
362 total_num_pairs *= 0.5;
364 *this->
mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
367 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
372 pCellPopulation->
Update();
375 double heterotypic_boundary_length = 0.0;
376 double total_shared_edges_length = 0.0;
377 double num_heterotypic_pairs = 0.0;
378 double total_num_pairs = 0.0;
382 cell_iter != pCellPopulation->
End();
386 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
393 for (std::set<unsigned>::iterator neighbour_iter = neighbour_elem_indices.begin();
394 neighbour_iter != neighbour_elem_indices.end();
398 unsigned neighbour_index = *neighbour_iter;
401 total_shared_edges_length += edge_length;
402 total_num_pairs += 1.0;
406 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
409 if (cell_is_labelled != neighbour_is_labelled)
412 heterotypic_boundary_length += edge_length;
413 num_heterotypic_pairs += 1.0;
419 heterotypic_boundary_length *= 0.5;
420 total_shared_edges_length *= 0.5;
423 num_heterotypic_pairs *= 0.5;
424 total_num_pairs *= 0.5;
426 *this->
mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
NodesOnlyMesh< DIM > & rGetMesh()
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
PottsMesh< DIM > & rGetMesh()
unsigned GetLocationIndexUsingCell(CellPtr pCell)
Node< DIM > * GetNode(unsigned index)
PottsMesh< DIM > & rGetMesh()
void CreateVoronoiTessellation()
Node< DIM > * GetNode(unsigned index)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
virtual bool IsCellAttachedToLocationIndex(unsigned index)
virtual bool IsGhostNode(unsigned index)
double GetDistanceBetweenNodes(unsigned indexA, unsigned indexB)
MutableVertexMesh< DIM, DIM > & rGetMesh()
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
void Update(bool hasHadBirthsOrDeaths=true)
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
virtual void Visit(MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > *pCellPopulation)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
std::set< unsigned > GetNeighbouringElementIndices(unsigned elementIndex)
HeterotypicBoundaryLengthWriter()
void Update(bool hasHadBirthsOrDeaths=true)
double GetEdgeLength(unsigned elementIndex1, unsigned elementIndex2)