36 #include "ExclusionCaBasedDivisionRule.hpp"
37 #include "RandomNumberGenerator.hpp"
39 template<
unsigned SPACE_DIM>
53 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
54 neighbour_iter != neighbouring_node_indices.end();
67 template<
unsigned SPACE_DIM>
75 if (!IsRoomToDivide(pParentCell,rCellPopulation))
77 EXCEPTION(
"Trying to divide when there is no room to divide, check your division rule");
87 unsigned num_neighbours = neighbouring_node_indices.size();
90 assert(!neighbouring_node_indices.empty());
92 std::vector<double> neighbouring_node_propensities;
93 std::vector<unsigned> neighbouring_node_indices_vector;
95 double total_propensity = 0.0;
98 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
99 neighbour_iter != neighbouring_node_indices.end();
102 neighbouring_node_indices_vector.push_back(*neighbour_iter);
104 double propensity_dividing_into_neighbour = rCellPopulation.
EvaluateDivisionPropensity(parent_node_index,*neighbour_iter,pParentCell);
108 propensity_dividing_into_neighbour = 0.0;
111 neighbouring_node_propensities.push_back(propensity_dividing_into_neighbour);
112 total_propensity += propensity_dividing_into_neighbour;
114 assert(total_propensity>0);
116 for (
unsigned i=0; i<num_neighbours; i++)
118 neighbouring_node_propensities[i] /= total_propensity;
123 double random_number = p_gen->
ranf();
125 double total_probability = 0.0;
129 for (counter=0; counter < num_neighbours; counter++)
131 total_probability += neighbouring_node_propensities[counter];
132 if (total_probability >= random_number)
135 daughter_node_index = neighbouring_node_indices_vector[counter];
142 assert(daughter_node_index < static_cast_mesh->GetNumNodes());
144 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)