36 #include "ExclusionCaBasedDivisionRule.hpp"
37 #include "RandomNumberGenerator.hpp"
39 template<
unsigned SPACE_DIM>
51 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
52 neighbour_iter != neighbouring_node_indices.end();
65 template<
unsigned SPACE_DIM>
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;
virtual double EvaluateDivisionPropensity(unsigned currentNodeIndex, unsigned targetNodeIndex, CellPtr pCell)
PottsMesh< DIM > & rGetMesh()
unsigned GetLocationIndexUsingCell(CellPtr pCell)
#define EXCEPTION(message)
virtual bool IsSiteAvailable(unsigned index, CellPtr pCell)
std::set< unsigned > GetMooreNeighbouringNodeIndices(unsigned nodeIndex)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
const unsigned UNSIGNED_UNSET
static RandomNumberGenerator * Instance()
virtual unsigned CalculateDaughterNodeIndex(CellPtr pNewCell, CellPtr pParentCell, CaBasedCellPopulation< SPACE_DIM > &rCellPopulation)
virtual bool IsRoomToDivide(CellPtr pParentCell, CaBasedCellPopulation< SPACE_DIM > &rCellPopulation)