Chaste  Build::
Owen2011SproutingRule.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4  All rights reserved.
5 
6  University of Oxford means the Chancellor, Masters and Scholars of the
7  University of Oxford, having an administrative office at Wellington
8  Square, Oxford OX1 2JD, UK.
9 
10  This file is part of Chaste.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34  */
35 
36 #include "RandomNumberGenerator.hpp"
37 #include "VesselSegment.hpp"
38 #include "Vessel.hpp"
39 #include "Owen2011SproutingRule.hpp"
40 #include "Owen11Parameters.hpp"
41 
42 template<unsigned DIM>
45  mHalfMaxVegf(Owen11Parameters::mpVegfConventrationAtHalfMaxProbSprouting->GetValue("Owen2011SproutingRule")),
46  mVegfField()
47 {
48  // Owen11 equation is dimensionally inconsistent as it includes an extra vessel surface area term. In order to
49  // have a similar magnitude multiply this value by a typical vessel surface area = 2*pi*R*L
50  // = 2*pi*15*40
51  this->mSproutingProbability = Owen11Parameters::mpMaximumSproutingRate->GetValue("Owen2011SproutingRule")*2.0*M_PI*15.0*40.0;
52  this->mTipExclusionRadius = 80.0*1.e-6*unit::metres;
53  this->mVesselEndCutoff = 80.0*1.e-6* unit::metres;
54 }
55 
56 template <unsigned DIM>
57 boost::shared_ptr<Owen2011SproutingRule<DIM> > Owen2011SproutingRule<DIM>::Create()
58 {
59  MAKE_PTR(Owen2011SproutingRule<DIM>, pSelf);
60  return pSelf;
61 }
62 
63 template<unsigned DIM>
65 {
66 
67 }
68 
69 template<unsigned DIM>
70 void Owen2011SproutingRule<DIM>::SetHalfMaxVegf(units::quantity<unit::concentration> halfMaxVegf)
71 {
72  mHalfMaxVegf = halfMaxVegf;
73 }
74 
75 template<unsigned DIM>
76 std::vector<boost::shared_ptr<VesselNode<DIM> > > Owen2011SproutingRule<DIM>::GetSprouts(const std::vector<boost::shared_ptr<VesselNode<DIM> > >& rNodes)
77 {
78  if(!this->mpGrid)
79  {
80  EXCEPTION("A regular grid is required for this type of sprouting rule.");
81  }
82 
83  if(!this->mpVesselNetwork)
84  {
85  EXCEPTION("A vessel network is required for this type of sprouting rule.");
86  }
87 
88  // Get the VEGF field
89  this->mVegfField = this->mpSolver->GetConcentrations(this->mpGrid);
90 
91  // Set up the output sprouts vector
92  std::vector<boost::shared_ptr<VesselNode<DIM> > > sprouts;
93 
94  // Loop over all nodes and randomly select sprouts
95  for(unsigned idx = 0; idx < rNodes.size(); idx++)
96  {
97  if(rNodes[idx]->GetNumberOfSegments() != 2)
98  {
99  continue;
100  }
101 
102  // Check we are not too close to the end of the vessel
103  if(this->mVesselEndCutoff > 0.0 * unit::metres)
104  {
105  if(rNodes[idx]->GetSegment(0)->GetVessel()->GetClosestEndNodeDistance(rNodes[idx]->rGetLocation())< this->mVesselEndCutoff)
106  {
107  continue;
108  }
109  if(rNodes[idx]->GetSegment(1)->GetVessel()->GetClosestEndNodeDistance(rNodes[idx]->rGetLocation())< this->mVesselEndCutoff)
110  {
111  continue;
112  }
113  }
114 
115  // Check we are not too close to an existing candidate
116  if(this->mTipExclusionRadius>0.0 * unit::metres)
117  {
118  bool too_close = false;
119  for(unsigned jdx=0; jdx<sprouts.size(); jdx++)
120  {
121  if(rNodes[idx]->GetDistance(sprouts[jdx]->rGetLocation()) < this->mTipExclusionRadius)
122  {
123  too_close = true;
124  }
125  }
126  if(too_close)
127  {
128  continue;
129  }
130  }
131 
132  // Get the grid index of the node
133  unsigned grid_index = this->mpGrid->GetNearestGridIndex(rNodes[idx]->rGetLocation());
134  units::quantity<unit::concentration> vegf_conc = this->mVegfField[grid_index];
135  double vegf_fraction = vegf_conc/(vegf_conc + mHalfMaxVegf);
136  double max_prob_per_time_step = this->mSproutingProbability*SimulationTime::Instance()->GetTimeStep()*BaseUnits::Instance()->GetReferenceTimeScale();
137  double prob_tip_selection = max_prob_per_time_step*vegf_fraction;
138 
139  if (RandomNumberGenerator::Instance()->ranf() < prob_tip_selection)
140  {
141  sprouts.push_back(rNodes[idx]);
142  }
143  }
144  return sprouts;
145 }
146 
147 // Explicit instantiation
148 template class Owen2011SproutingRule<2> ;
149 template class Owen2011SproutingRule<3> ;
static const boost::shared_ptr< ParameterInstance< unit::rate > > mpMaximumSproutingRate
std::vector< units::quantity< unit::concentration > > mVegfField
boost::shared_ptr< VesselNetwork< DIM > > mpVesselNetwork
units::quantity< unit::time > GetReferenceTimeScale()
Definition: BaseUnits.cpp:72
boost::shared_ptr< AbstractDiscreteContinuumSolver< DIM > > mpSolver
units::quantity< unit::concentration > mHalfMaxVegf
static boost::shared_ptr< Owen2011SproutingRule< DIM > > Create()
boost::shared_ptr< RegularGrid< DIM > > mpGrid
virtual std::vector< boost::shared_ptr< VesselNode< DIM > > > GetSprouts(const std::vector< boost::shared_ptr< VesselNode< DIM > > > &rNodes)
units::quantity< unit::length > mVesselEndCutoff
units::quantity< unit::rate > mSproutingProbability
static BaseUnits * Instance()
Definition: BaseUnits.cpp:53
void SetHalfMaxVegf(units::quantity< unit::concentration > halfMaxVegf)
units::quantity< unit::length > mTipExclusionRadius