Chaste  Build::
OffLatticeSproutingRule.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 "OffLatticeSproutingRule.hpp"
37 #include "RandomNumberGenerator.hpp"
38 #include "GeometryTools.hpp"
39 #include "UblasIncludes.hpp"
40 #include "UblasCustomFunctions.hpp"
41 #include "BaseUnits.hpp"
42 #include "Owen11Parameters.hpp"
43 
44 template<unsigned DIM>
46  : AbstractSproutingRule<DIM>(),
47  mTipExclusionRadius(80.0 * 1.e-6 * unit::metres),
48  mHalfMaxVegf(Owen11Parameters::mpVegfConventrationAtHalfMaxProbSprouting->GetValue("Owen2011SproutingRule")),
49  mVegfField()
50 {
51  // Owen11 equation is dimensionally inconsistent as it includes an extra vessel surface area term. In order to
52  // have a similar magnitude multiply this value by a typical vessel surface area = 2*pi*R*L
53  // = 2*pi*15*40
54  this->mSproutingProbability = Owen11Parameters::mpMaximumSproutingRate->GetValue("Owen2011SproutingRule")*2.0*M_PI*15.0*40.0;
55  this->mTipExclusionRadius = 80.0*1.e-6*unit::metres;
56 }
57 
58 template<unsigned DIM>
60 {
61 
62 }
63 
64 template <unsigned DIM>
65 boost::shared_ptr<OffLatticeSproutingRule<DIM> > OffLatticeSproutingRule<DIM>::Create()
66 {
67  MAKE_PTR(OffLatticeSproutingRule<DIM>, pSelf);
68  return pSelf;
69 }
70 
71 template<unsigned DIM>
72 std::vector<boost::shared_ptr<VesselNode<DIM> > > OffLatticeSproutingRule<DIM>::GetSprouts(const std::vector<boost::shared_ptr<VesselNode<DIM> > >& rNodes)
73 {
74  if(!this->mpVesselNetwork)
75  {
76  EXCEPTION("A vessel network is required for this type of sprouting rule.");
77  }
78 
79  std::vector<units::quantity<unit::concentration> > probed_solutions(rNodes.size(), 0.0*unit::mole_per_metre_cubed);
80  std::vector<DimensionalChastePoint<DIM> > probe_locations(rNodes.size(), DimensionalChastePoint<DIM>(0.0, 0.0, 0.0, 1.e-6*unit::metres));
81 
82  if(this->mpSolver)
83  {
84  for(unsigned idx=0; idx<rNodes.size(); idx++)
85  {
86  probe_locations[idx] = rNodes[idx]->rGetLocation();
87  }
88  if(probe_locations.size()>0)
89  {
90  probed_solutions = this->mpSolver->GetConcentrations(probe_locations);
91  }
92  }
93 
94  // Set up the output sprouts vector
95  std::vector<boost::shared_ptr<VesselNode<DIM> > > sprouts;
96 
97  // Loop over all nodes and randomly select sprouts
98  for(unsigned idx = 0; idx < rNodes.size(); idx++)
99  {
100  // Check we are not too close to the end of the vessel
101  if(rNodes[idx]->GetNumberOfSegments() != 2)
102  {
103  continue;
104  }
105 
106  if(this->mVesselEndCutoff > 0.0 * unit::metres)
107  {
108  if(rNodes[idx]->GetSegment(0)->GetVessel()->GetClosestEndNodeDistance(rNodes[idx]->rGetLocation())< this->mVesselEndCutoff)
109  {
110  continue;
111  }
112  if(rNodes[idx]->GetSegment(1)->GetVessel()->GetClosestEndNodeDistance(rNodes[idx]->rGetLocation())< this->mVesselEndCutoff)
113  {
114  continue;
115  }
116  }
117 
118  // Check we are not too close to an existing candidate
119  if(mTipExclusionRadius>0.0 * unit::metres)
120  {
121  bool too_close = false;
122  for(unsigned jdx=0; jdx<sprouts.size(); jdx++)
123  {
124  if(rNodes[idx]->GetDistance(sprouts[jdx]->rGetLocation()) < mTipExclusionRadius)
125  {
126  too_close = true;
127  }
128  }
129  if(too_close)
130  {
131  continue;
132  }
133  }
134  units::quantity<unit::concentration> vegf_conc = 0.0*unit::mole_per_metre_cubed;
135  if(this->mpSolver)
136  {
137  vegf_conc = probed_solutions[idx];
138  }
139 
140  double vegf_fraction = vegf_conc/(vegf_conc + mHalfMaxVegf);
141  double max_prob_per_time_step = this->mSproutingProbability*SimulationTime::Instance()->GetTimeStep()*BaseUnits::Instance()->GetReferenceTimeScale();
142  double prob_tip_selection = max_prob_per_time_step*vegf_fraction;
143 
144  if (RandomNumberGenerator::Instance()->ranf() < prob_tip_selection)
145  {
146  sprouts.push_back(rNodes[idx]);
147  }
148  }
149  return sprouts;
150 }
151 
152 // Explicit instantiation
153 template class OffLatticeSproutingRule<2> ;
154 template class OffLatticeSproutingRule<3> ;
units::quantity< unit::concentration > mHalfMaxVegf
virtual std::vector< boost::shared_ptr< VesselNode< DIM > > > GetSprouts(const std::vector< boost::shared_ptr< VesselNode< DIM > > > &rNodes)
static const boost::shared_ptr< ParameterInstance< unit::rate > > mpMaximumSproutingRate
boost::shared_ptr< VesselNetwork< DIM > > mpVesselNetwork
units::quantity< unit::time > GetReferenceTimeScale()
Definition: BaseUnits.cpp:72
boost::shared_ptr< AbstractDiscreteContinuumSolver< DIM > > mpSolver
static boost::shared_ptr< OffLatticeSproutingRule< DIM > > Create()
units::quantity< unit::length > mVesselEndCutoff
units::quantity< unit::rate > mSproutingProbability
static BaseUnits * Instance()
Definition: BaseUnits.cpp:53
units::quantity< unit::length > mTipExclusionRadius