36 #include "Owen11CaBasedDivisionRule.hpp" 37 #include "RandomNumberGenerator.hpp" 38 #include "BaseUnits.hpp" 39 #include "CancerCellMutationState.hpp" 40 #include "QuiescentCancerCellMutationState.hpp" 42 template<
unsigned SPACE_DIM>
47 mReferenceLengthScale(
BaseUnits::Instance()->GetReferenceLengthScale()),
48 mCancerCellCarryingCapacity(2)
52 template<
unsigned SPACE_DIM>
57 template<
unsigned SPACE_DIM>
66 EXCEPTION(
"A regular grid is required for determining vessel based lattice occupancy");
71 unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(pParentCell);
74 unsigned num_cells_at_site = 0;
79 num_cells_at_site = 1;
82 num_cells_at_site += rCellPopulation.GetCellsUsingLocationIndex(node_index).size();
93 if(num_cells_at_site<1)
100 std::set<unsigned> neighbouring_node_indices =
static_cast<PottsMesh<SPACE_DIM>*
>(&(rCellPopulation.rGetMesh()))->GetMooreNeighbouringNodeIndices(node_index);
103 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
104 neighbour_iter != neighbouring_node_indices.end();
107 num_cells_at_site = 0;
111 if(
mpRegularGrid->IsSegmentAtLatticeSite(*neighbour_iter,
false))
113 num_cells_at_site = 1;
117 num_cells_at_site += rCellPopulation.GetCellsUsingLocationIndex(*neighbour_iter).size();
128 if(num_cells_at_site<1)
147 EXCEPTION(
"This division rule is not supported in 1D");
151 template<
unsigned SPACE_DIM>
158 EXCEPTION(
"Trying to divide when there is no room to divide, check your division rule");
165 EXCEPTION(
"A regular grid is required for determining vessel based lattice occupancy");
170 unsigned parent_node_index = rCellPopulation.GetLocationIndexUsingCell(pParentCell);
176 unsigned num_cells_at_site = 0;
179 if(
mpRegularGrid->IsSegmentAtLatticeSite(parent_node_index,
false))
181 num_cells_at_site = 1;
184 num_cells_at_site += rCellPopulation.GetCellsUsingLocationIndex(parent_node_index).size();
187 return parent_node_index;
192 PottsMesh<SPACE_DIM>* static_cast_mesh =
static_cast<PottsMesh<SPACE_DIM>*
>(&(rCellPopulation.rGetMesh()));
195 std::set<unsigned> neighbouring_node_indices = static_cast_mesh->GetMooreNeighbouringNodeIndices(parent_node_index);
196 unsigned num_neighbours = neighbouring_node_indices.size();
199 assert(!neighbouring_node_indices.empty());
201 std::vector<double> neighbouring_node_propensities;
202 std::vector<unsigned> neighbouring_node_indices_vector;
204 double total_propensity = 0.0;
207 for (std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
208 neighbour_iter != neighbouring_node_indices.end();
211 neighbouring_node_indices_vector.push_back(*neighbour_iter);
214 double propensity_dividing_into_neighbour = 0.0;
215 unsigned num_cells_at_site = 0;
218 if(
mpRegularGrid->IsSegmentAtLatticeSite(*neighbour_iter,
false))
220 num_cells_at_site = 1;
223 num_cells_at_site += rCellPopulation.GetCellsUsingLocationIndex(*neighbour_iter).size();
229 propensity_dividing_into_neighbour = 1.0;
234 if(num_cells_at_site<1)
236 propensity_dividing_into_neighbour = 1.0;
240 neighbouring_node_propensities.push_back(propensity_dividing_into_neighbour);
241 total_propensity += propensity_dividing_into_neighbour;
243 assert(total_propensity > 0);
245 for (
unsigned i=0; i<num_neighbours; i++)
247 neighbouring_node_propensities[i] /= total_propensity;
251 RandomNumberGenerator* p_gen = RandomNumberGenerator::Instance();
252 double random_number = p_gen->ranf();
254 double total_probability = 0.0;
255 unsigned daughter_node_index = UNSIGNED_UNSET;
258 for (counter=0; counter < num_neighbours; counter++)
260 total_probability += neighbouring_node_propensities[counter];
261 if (total_probability >= random_number)
264 daughter_node_index = neighbouring_node_indices_vector[counter];
270 assert(daughter_node_index != UNSIGNED_UNSET);
271 assert(daughter_node_index < static_cast_mesh->GetNumNodes());
273 return daughter_node_index;
288 EXCEPTION(
"This division rule is not supported in 1D");
292 template<
unsigned SPACE_DIM>
298 template<
unsigned SPACE_DIM>
304 template<
unsigned SPACE_DIM>
315 #include "SerializationExportWrapperForCpp.hpp" Owen11CaBasedDivisionRule()
boost::shared_ptr< VesselNetwork< SPACE_DIM > > mpVesselNetwork
virtual ~Owen11CaBasedDivisionRule()
virtual bool IsRoomToDivide(CellPtr pParentCell, CaBasedCellPopulation< SPACE_DIM > &rCellPopulation)
void SetReferenceLengthScale(units::quantity< unit::length > referenceLengthScale)
virtual unsigned CalculateDaughterNodeIndex(CellPtr pNewCell, CellPtr pParentCell, CaBasedCellPopulation< SPACE_DIM > &rCellPopulation)
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< SPACE_DIM > > pVesselNetwork)
void SetRegularGrid(boost::shared_ptr< RegularGrid< SPACE_DIM > > mpRegularGrid)
boost::shared_ptr< RegularGrid< SPACE_DIM > > mpRegularGrid
units::quantity< unit::length > mReferenceLengthScale
unsigned mCancerCellCarryingCapacity