Chaste  Release::2018.1
SimpleTargetAreaModifier.cpp
1 /*
2 
3 Copyright (c) 2005-2018, 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 "SimpleTargetAreaModifier.hpp"
37 #include "AbstractPhaseBasedCellCycleModel.hpp"
38 #include "ApoptoticCellProperty.hpp"
39 
40 template<unsigned DIM>
43  mGrowthDuration(DOUBLE_UNSET)
44 {
45 }
46 
47 template<unsigned DIM>
49 {
50 }
51 
52 template<unsigned DIM>
54 {
55  // Get target area A of a healthy cell in S, G2 or M phase
56  double cell_target_area = this->mReferenceTargetArea;
57 
58  double growth_duration = mGrowthDuration;
59  if (growth_duration == DOUBLE_UNSET)
60  {
61  if (dynamic_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel()) == nullptr)
62  {
63  EXCEPTION("If SetGrowthDuration() has not been called, a subclass of AbstractPhaseBasedCellCycleModel must be used");
64  }
65  AbstractPhaseBasedCellCycleModel* p_model = static_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel());
66 
67  growth_duration = p_model->GetG1Duration();
68 
69  // If the cell is differentiated then its G1 duration is infinite
70  if (growth_duration == DBL_MAX)
71  {
72  // This is just for fixed cell-cycle models, need to work out how to find the g1 duration
73  growth_duration = p_model->GetTransitCellG1Duration();
74  }
75  }
76 
77  if (pCell->HasCellProperty<ApoptoticCellProperty>())
78  {
79  // Age of cell when apoptosis begins
80  if (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime() < growth_duration)
81  {
82  cell_target_area *= 0.5*(1 + (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime())/growth_duration);
83  }
84 
85  // The target area of an apoptotic cell decreases linearly to zero
86  double time_spent_apoptotic = SimulationTime::Instance()->GetTime() - pCell->GetStartOfApoptosisTime();
87 
88  cell_target_area *= 1.0 - 0.5/(pCell->GetApoptosisTime())*time_spent_apoptotic;
89  if (cell_target_area < 0)
90  {
91  cell_target_area = 0;
92  }
93  }
94  else
95  {
96  double cell_age = pCell->GetAge();
97 
98  // The target area of a proliferating cell increases linearly from A/2 to A over the course of the prescribed duration
99  if (cell_age < growth_duration)
100  {
101  cell_target_area *= 0.5*(1 + cell_age/growth_duration);
102  }
103  else
104  {
112  if (pCell->ReadyToDivide())
113  {
114  cell_target_area = 0.5*this->mReferenceTargetArea;
115  }
116  }
117  }
118 
119  // Set cell data
120  pCell->GetCellData()->SetItem("target area", cell_target_area);
121 }
122 
123 template<unsigned DIM>
125 {
126  return mGrowthDuration;
127 }
128 
129 template<unsigned DIM>
131 {
132  assert(growthDuration >= 0.0);
133  mGrowthDuration = growthDuration;
134 }
135 
136 template<unsigned DIM>
138 {
139  *rParamsFile << "\t\t\t<GrowthDuration>" << mGrowthDuration << "</GrowthDuration>\n";
140 
141  // Next, call method on direct parent class
143 }
144 
145 // Explicit instantiation
146 template class SimpleTargetAreaModifier<1>;
147 template class SimpleTargetAreaModifier<2>;
148 template class SimpleTargetAreaModifier<3>;
149 
150 // Serialization for Boost >= 1.36
virtual void UpdateTargetAreaOfCell(const CellPtr pCell)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
#define EXCEPTION(message)
Definition: Exception.hpp:143
static SimulationTime * Instance()
const double DOUBLE_UNSET
Definition: Exception.hpp:56
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void SetGrowthDuration(double growthDuration)
double GetTime() const