36 #include "HeterotypicBoundaryLengthWriter.hpp"
37 #include "AbstractCellPopulation.hpp"
38 #include "MeshBasedCellPopulation.hpp"
39 #include "CaBasedCellPopulation.hpp"
40 #include "NodeBasedCellPopulation.hpp"
41 #include "PottsBasedCellPopulation.hpp"
42 #include "VertexBasedCellPopulation.hpp"
44 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
50 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
54 double heterotypic_boundary_length = 0.0;
55 double total_shared_edges_length = 0.0;
56 double num_heterotypic_pairs = 0.0;
57 double total_num_pairs = 0.0;
65 cell_iter != pCellPopulation->
End();
72 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
78 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
79 neighbour_iter != neighbour_indices.end();
83 unsigned neighbour_index = *neighbour_iter;
90 total_shared_edges_length += edge_length;
91 total_num_pairs += 1.0;
95 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
98 if (cell_is_labelled != neighbour_is_labelled)
101 heterotypic_boundary_length += edge_length;
102 num_heterotypic_pairs += 1.0;
109 heterotypic_boundary_length *= 0.5;
110 total_shared_edges_length *= 0.5;
113 num_heterotypic_pairs *= 0.5;
114 total_num_pairs *= 0.5;
116 *this->mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
119 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
123 double heterotypic_boundary_length = 0.0;
124 double total_shared_edges_length = 0.0;
125 double num_heterotypic_pairs = 0.0;
126 double total_num_pairs = 0.0;
130 cell_iter != pCellPopulation->
End();
137 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
141 std::set<unsigned> neighbour_node_indices = pCellPopulation->
rGetMesh().GetVonNeumannNeighbouringNodeIndices(index);
144 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
145 neighbour_iter != neighbour_node_indices.end();
149 double edge_length = 1.0;
151 unsigned neighbour_index = *neighbour_iter;
157 total_shared_edges_length += edge_length;
158 total_num_pairs += 1.0;
161 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
164 if (cell_is_labelled != neighbour_is_labelled)
167 heterotypic_boundary_length += edge_length;
168 num_heterotypic_pairs += 1.0;
175 heterotypic_boundary_length *= 0.5;
176 total_shared_edges_length *= 0.5;
179 num_heterotypic_pairs *= 0.5;
180 total_num_pairs *= 0.5;
182 *this->mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
185 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
190 pCellPopulation->
Update();
193 double heterotypic_boundary_length = 0.0;
194 double total_shared_edges_length = 0.0;
195 double num_heterotypic_pairs = 0.0;
196 double total_num_pairs = 0.0;
200 cell_iter != pCellPopulation->
End();
204 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
208 double node_radius = pCellPopulation->
GetNode(node_index)->GetRadius();
213 if (!neighbour_indices.empty())
216 for (std::set<unsigned>::iterator neighbour_iter = neighbour_indices.begin();
217 neighbour_iter != neighbour_indices.end();
221 double neighbour_radius = pCellPopulation->
GetNode(*neighbour_iter)->GetRadius();
225 double sum_of_radii = node_radius + neighbour_radius;
228 if (separation < sum_of_radii)
231 double a = node_radius;
232 double b = neighbour_radius;
233 double c = separation;
234 double s = 0.5*(a + b + c);
235 double A = sqrt(s*(s-a)*(s-b)*(s-c));
236 double edge_length = 4.0*A/c;
238 total_shared_edges_length += edge_length;
239 total_num_pairs += 1.0;
243 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
246 if (cell_is_labelled != neighbour_is_labelled)
249 heterotypic_boundary_length += edge_length;
250 num_heterotypic_pairs += 1.0;
258 heterotypic_boundary_length *= 0.5;
259 total_shared_edges_length *= 0.5;
262 num_heterotypic_pairs *= 0.5;
263 total_num_pairs *= 0.5;
265 *this->mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
268 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
274 double heterotypic_boundary_length = 0.0;
275 double total_shared_edges_length = 0.0;
276 double num_heterotypic_pairs = 0.0;
277 double total_num_pairs = 0.0;
281 cell_iter != pCellPopulation->
End();
285 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
288 unsigned num_nodes_in_elem = pCellPopulation->
rGetMesh().GetElement(elem_index)->GetNumNodes();
291 for (
unsigned local_index=0; local_index<num_nodes_in_elem; local_index++)
294 unsigned global_index = pCellPopulation->
rGetMesh().GetElement(elem_index)->GetNodeGlobalIndex(local_index);
295 std::set<unsigned> neighbour_node_indices = pCellPopulation->
rGetMesh().GetVonNeumannNeighbouringNodeIndices(global_index);
298 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
299 neighbour_iter != neighbour_node_indices.end();
303 std::set<unsigned> neighbour_elem_indices = pCellPopulation->
GetNode(*neighbour_iter)->rGetContainingElementIndices();
305 if (neighbour_elem_indices.size() == 1)
307 unsigned neigbour_elem_index = *(neighbour_elem_indices.begin());
309 if (neigbour_elem_index != elem_index)
312 total_shared_edges_length += 1.0;
316 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
319 if (cell_is_labelled != neighbour_is_labelled)
322 heterotypic_boundary_length += 1.0;
336 for (std::set<unsigned>::iterator neighbour_iter = neighbour_node_indices.begin();
337 neighbour_iter != neighbour_node_indices.end();
340 total_num_pairs += 1.0;
343 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
346 if (cell_is_labelled != neighbour_is_labelled)
349 num_heterotypic_pairs += 1.0;
355 heterotypic_boundary_length *= 0.5;
356 total_shared_edges_length *= 0.5;
359 num_heterotypic_pairs *= 0.5;
360 total_num_pairs *= 0.5;
362 *this->mpOutStream << heterotypic_boundary_length <<
"\t" << total_shared_edges_length <<
"\t" << num_heterotypic_pairs <<
"\t" << total_num_pairs;
365 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
370 pCellPopulation->
Update();
373 double heterotypic_boundary_length = 0.0;
374 double total_shared_edges_length = 0.0;
375 double num_heterotypic_pairs = 0.0;
376 double total_num_pairs = 0.0;
380 cell_iter != pCellPopulation->
End();
384 bool cell_is_labelled = cell_iter->template HasCellProperty<CellLabel>();
391 for (std::set<unsigned>::iterator neighbour_iter = neighbour_elem_indices.begin();
392 neighbour_iter != neighbour_elem_indices.end();
396 unsigned neighbour_index = *neighbour_iter;
399 total_shared_edges_length += edge_length;
400 total_num_pairs += 1.0;
404 bool neighbour_is_labelled = p_neighbour_cell->template HasCellProperty<CellLabel>();
407 if (cell_is_labelled != neighbour_is_labelled)
410 heterotypic_boundary_length += edge_length;
411 num_heterotypic_pairs += 1.0;
417 heterotypic_boundary_length *= 0.5;
418 total_shared_edges_length *= 0.5;
421 num_heterotypic_pairs *= 0.5;
422 total_num_pairs *= 0.5;
424 *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)
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)