68 if (!IsRoomToDivide(pParentCell,rCellPopulation))
70 EXCEPTION(
"Trying to divide when there is no room to divide, check your division rule");
80 unsigned num_neighbours = neighbouring_node_indices.size();
83 assert(!neighbouring_node_indices.empty());
85 std::vector<double> neighbouring_node_propensities;
86 std::vector<unsigned> neighbouring_node_indices_vector;
88 double total_propensity = 0.0;
91 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
92 neighbour_iter != neighbouring_node_indices.end();
95 neighbouring_node_indices_vector.push_back(*neighbour_iter);
97 double propensity_dividing_into_neighbour = rCellPopulation.
EvaluateDivisionPropensity(parent_node_index,*neighbour_iter,pParentCell);
101 propensity_dividing_into_neighbour = 0.0;
104 neighbouring_node_propensities.push_back(propensity_dividing_into_neighbour);
105 total_propensity += propensity_dividing_into_neighbour;
107 assert(total_propensity > 0);
109 for (
unsigned i=0; i<num_neighbours; i++)
111 neighbouring_node_propensities[i] /= total_propensity;
116 double random_number = p_gen->
ranf();
118 double total_probability = 0.0;
122 for (counter=0; counter < num_neighbours; counter++)
124 total_probability += neighbouring_node_propensities[counter];
125 if (total_probability >= random_number)
128 daughter_node_index = neighbouring_node_indices_vector[counter];
135 assert(daughter_node_index < static_cast_mesh->GetNumNodes());
137 return daughter_node_index;