36 #include <boost/lexical_cast.hpp> 37 #include "UblasIncludes.hpp" 38 #include "RandomNumberGenerator.hpp" 39 #include "VesselNode.hpp" 40 #include "VesselSegment.hpp" 41 #include "VesselNode.hpp" 42 #include "AngiogenesisSolver.hpp" 43 #include "StalkCellMutationState.hpp" 44 #include "TipCellMutationState.hpp" 45 #include "VesselNetworkWriter.hpp" 47 template<
unsigned DIM>
50 mNodeAnastamosisRadius(5.0 *
unit::microns),
57 mCellPopulationReferenceLength(5.0 *
unit::microns),
64 template<
unsigned DIM>
70 template<
unsigned DIM>
77 template<
unsigned DIM>
83 template<
unsigned DIM>
89 template<
unsigned DIM>
95 template<
unsigned DIM>
102 template<
unsigned DIM>
108 template<
unsigned DIM>
114 template<
unsigned DIM>
120 template<
unsigned DIM>
126 template<
unsigned DIM>
132 template<
unsigned DIM>
136 std::vector<boost::shared_ptr<VesselNode<DIM> > > candidate_sprouts =
mpSproutingRule->GetSprouts(
mpNetwork->GetNodes());
137 for (
unsigned idx = 0; idx < candidate_sprouts.size(); idx++)
139 candidate_sprouts[idx]->SetIsMigrating(
true);
145 template<
unsigned DIM>
149 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
mpNetwork->GetNodes();
150 std::vector<boost::shared_ptr<VesselNode<DIM> > > tips;
151 for (
unsigned idx = 0; idx < nodes.size(); idx++)
155 if (nodes[idx]->IsMigrating() && nodes[idx]->GetNumberOfSegments() == 2)
157 tips.push_back(nodes[idx]);
162 if (nodes[idx]->IsMigrating() && nodes[idx]->GetNumberOfSegments() == 1)
164 tips.push_back(nodes[idx]);
175 for (
unsigned idx = 0; idx < tips.size(); idx++)
177 if(tips[idx]->GetFlowProperties()->IsInputNode() or tips[idx]->GetFlowProperties()->IsOutputNode())
179 tips[idx]->SetIsMigrating(
false);
183 if (indices[idx] >= 0 )
188 tips[idx]->SetIsMigrating(
false);
194 p_new_node->SetLocation(
mpVesselGrid->GetLocationOf1dIndex(indices[idx]));
195 mpNetwork->ExtendVessel(tips[idx]->GetSegment(0)->GetVessel(), tips[idx], p_new_node);
196 tips[idx]->SetIsMigrating(
false);
197 p_new_node->SetIsMigrating(
true);
203 if (sprouting && tips[idx]->GetNumberOfSegments() == 2)
205 tips[idx]->SetIsMigrating(
false);
218 std::vector<DimensionalChastePoint<DIM> > movement_vectors =
mpMigrationRule->GetDirections(tips);
219 std::vector<DimensionalChastePoint<DIM> > candidate_tip_locations;
220 std::vector<bool> candidate_tips_inside_domain(tips.size(),
true);
221 for (
unsigned idx = 0; idx < tips.size(); idx++)
223 candidate_tip_locations.push_back(tips[idx]->rGetLocation() + movement_vectors[idx]);
228 candidate_tips_inside_domain =
mpBoundingDomain->IsPointInPart(candidate_tip_locations);
231 for (
unsigned idx = 0; idx < tips.size(); idx++)
233 if(tips[idx]->GetFlowProperties()->IsInputNode() or tips[idx]->GetFlowProperties()->IsOutputNode())
235 tips[idx]->SetIsMigrating(
false);
239 if (movement_vectors[idx].GetNorm2() > 0.0*unit::metres)
241 if (candidate_tips_inside_domain[idx])
245 mpNetwork->FormSprout(tips[idx]->rGetLocation(), candidate_tip_locations[idx]);
247 tips[idx]->SetIsMigrating(
false);
252 p_new_node->SetLocation(candidate_tip_locations[idx]);
253 mpNetwork->ExtendVessel(tips[idx]->GetSegment(0)->GetVessel(), tips[idx], p_new_node);
254 tips[idx]->SetIsMigrating(
false);
255 p_new_node->SetIsMigrating(
true);
261 if (sprouting && tips[idx]->GetNumberOfSegments() == 2)
263 tips[idx]->SetIsMigrating(
false);
271 template<
unsigned DIM>
275 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
mpNetwork->GetNodes();
277 for (
unsigned idx = 0; idx < nodes.size(); idx++)
280 if (nodes[idx]->IsMigrating() && nodes[idx]->GetNumberOfSegments() == 1)
284 std::vector<std::vector<boost::shared_ptr<VesselNode<DIM> > > > point_node_map =
mpVesselGrid->GetPointNodeMap();
285 unsigned grid_index =
mpVesselGrid->GetNearestGridIndex(nodes[idx]->rGetLocation());
286 if (point_node_map[grid_index].size() >= 2)
289 if (point_node_map[grid_index][0] == nodes[idx])
292 point_node_map[grid_index][1]->GetSegment(0)->GetVessel(), nodes[idx]->rGetLocation());
297 point_node_map[grid_index][0]->GetSegment(0)->GetVessel(), nodes[idx]->rGetLocation());
301 p_merge_node->SetIsMigrating(
false);
302 if (nodes[idx]->GetSegment(0)->GetNode(0) == nodes[idx])
304 nodes[idx]->GetSegment(0)->ReplaceNode(0, p_merge_node);
308 nodes[idx]->GetSegment(0)->ReplaceNode(1, p_merge_node);
316 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > segment_pair =
317 mpNetwork->GetNearestSegment(nodes[idx],
false);
320 && nodes[idx]->GetSegment(0)->GetLength() > segment_pair.second)
327 original_location,
true);
328 nodes[idx]->SetLocation(divide_location);
330 boost::shared_ptr<VesselNode<DIM> > p_merge_node =
mpNetwork->DivideVessel(
331 segment_pair.first->GetVessel(), nodes[idx]->rGetLocation());
334 if ((nodes[idx]->GetSegment(0)->GetNode(0) == p_merge_node)
335 || (nodes[idx]->GetSegment(0)->GetNode(1) == p_merge_node))
337 nodes[idx]->SetLocation(original_location);
341 p_merge_node->SetIsMigrating(
false);
342 if (nodes[idx]->GetSegment(0)->GetNode(0) == nodes[idx])
344 nodes[idx]->GetSegment(0)->ReplaceNode(0, p_merge_node);
348 nodes[idx]->GetSegment(0)->ReplaceNode(1, p_merge_node);
358 template<
unsigned DIM>
363 EXCEPTION(
"The angiogenesis solver needs an initial vessel network");
416 CellPtr p_reference_cell;
417 for (
typename AbstractCellPopulation<DIM, DIM>::Iterator cell_iter =
mpCellPopulation->Begin();
420 p_reference_cell = (*cell_iter);
421 if ((*cell_iter)->GetMutationState()->IsSame(p_EC_Tip_state))
423 (*cell_iter)->SetMutationState(p_EC_state);
428 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
mpNetwork->GetNodes();
429 for (
unsigned idx = 0; idx < nodes.size(); idx++)
431 if (nodes[idx]->IsMigrating())
433 unsigned location_index =
mpVesselGrid->GetNearestGridIndex(nodes[idx]->rGetLocation());
438 if (
mpCellPopulation->GetCellUsingLocationIndex(location_index)->GetMutationState()->IsSame(p_EC_state))
440 mpCellPopulation->GetCellUsingLocationIndex(location_index)->SetMutationState(p_EC_Tip_state);
446 CellPtr p_new_cell(
new Cell(p_EC_Tip_state, p_reference_cell->GetCellCycleModel()->CreateCellCycleModel()));
447 p_new_cell->GetCellCycleModel()->InitialiseDaughterCell();
448 p_new_cell->SetApoptosisTime(p_reference_cell->GetApoptosisTime());
459 template<
unsigned DIM>
466 while (!SimulationTime::Instance()->IsFinished())
471 p_network_writer->SetFileName(
472 mpFileHandler->GetOutputDirectoryFullPath() +
"/vessel_network_" 473 + boost::lexical_cast<std::string>(SimulationTime::Instance()->GetTimeStepsElapsed())
475 p_network_writer->SetVesselNetwork(
mpNetwork);
476 p_network_writer->Write();
487 SimulationTime::Instance()->IncrementTimeOneStep();
void SetMigrationRule(boost::shared_ptr< AbstractMigrationRule< DIM > > pMigrationRule)
void SetAnastamosisRadius(units::quantity< unit::length > radius)
void SetVesselGrid(boost::shared_ptr< RegularGrid< DIM > >pVesselGrid)
static boost::shared_ptr< VesselNode< DIM > > Create(double v1=0.0, double v2=0.0, double v3=0.0)
static boost::shared_ptr< VesselNetworkWriter< DIM > > Create()
void SetCellPopulation(boost::shared_ptr< AbstractCellPopulation< DIM > > pCellPopulation, units::quantity< unit::length > cellPopulationReferenceLength)
void SetSproutingRule(boost::shared_ptr< AbstractSproutingRule< DIM > > pSproutingRule)
boost::shared_ptr< AbstractMigrationRule< DIM > > mpMigrationRule
virtual void DoAnastamosis()
virtual void UpdateNodalPositions(bool sprouting=false)
virtual void DoSprouting()
void SetOutputFileHandler(boost::shared_ptr< OutputFileHandler > pHandler)
units::quantity< unit::length > mCellPopulationReferenceLength
boost::shared_ptr< OutputFileHandler > mpFileHandler
units::quantity< unit::length > mNodeAnastamosisRadius
static boost::shared_ptr< AngiogenesisSolver< DIM > > Create()
boost::shared_ptr< AbstractCellPopulation< DIM > > mpCellPopulation
boost::shared_ptr< Part< DIM > > mpBoundingDomain
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pNetwork)
boost::shared_ptr< VesselNetwork< DIM > > mpNetwork
virtual ~AngiogenesisSolver()
void Run(bool writeOutput=false)
boost::shared_ptr< RegularGrid< DIM > > mpVesselGrid
void SetBoundingDomain(boost::shared_ptr< Part< DIM > > pDomain)
bool IsSproutingRuleSet()
boost::shared_ptr< AbstractSproutingRule< DIM > > mpSproutingRule