Chaste  Release::3.4
SimpleTargetAreaModifier.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 "SimpleTargetAreaModifier.hpp"
37 
38 template<unsigned DIM>
41 {
42 }
43 
44 template<unsigned DIM>
46 {
47 }
48 
49 template<unsigned DIM>
51 {
52  // Get target area A of a healthy cell in S, G2 or M phase
53  double cell_target_area = this->mReferenceTargetArea;
54 
55  double g1_duration = pCell->GetCellCycleModel()->GetG1Duration();
56 
57  // If the cell is differentiated then its G1 duration is infinite
58  if (g1_duration == DBL_MAX) // don't use magic number, compare to DBL_MAX
59  {
60  // This is just for fixed cell-cycle models, need to work out how to find the g1 duration
61  g1_duration = pCell->GetCellCycleModel()->GetTransitCellG1Duration();
62  }
63 
64  if (pCell->HasCellProperty<ApoptoticCellProperty>())
65  {
66  // Age of cell when apoptosis begins
67  if (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime() < g1_duration)
68  {
69  cell_target_area *= 0.5*(1 + (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime())/g1_duration);
70  }
71 
72  // The target area of an apoptotic cell decreases linearly to zero (and past it negative)
73  cell_target_area = cell_target_area - 0.5*cell_target_area/(pCell->GetApoptosisTime())*(SimulationTime::Instance()->GetTime()-pCell->GetStartOfApoptosisTime());
74 
75  // Don't allow a negative target area
76  if (cell_target_area < 0)
77  {
78  cell_target_area = 0;
79  }
80  }
81  else
82  {
83  double cell_age = pCell->GetAge();
84 
85  // The target area of a proliferating cell increases linearly from A/2 to A over the course of the G1 phase
86  if (cell_age < g1_duration)
87  {
88  cell_target_area *= 0.5*(1 + cell_age/g1_duration);
89  }
90  else
91  {
99  if (pCell->ReadyToDivide())
100  {
101  cell_target_area = 0.5*this->mReferenceTargetArea;
102  }
103  }
104  }
105 
106  // Set cell data
107  pCell->GetCellData()->SetItem("target area", cell_target_area);
108 }
109 
110 template<unsigned DIM>
112 {
113  // No parameters to output, so just call method on direct parent class
115 }
116 
117 // Explicit instantiation
118 template class SimpleTargetAreaModifier<1>;
119 template class SimpleTargetAreaModifier<2>;
120 template class SimpleTargetAreaModifier<3>;
121 
122 // Serialization for Boost >= 1.36
virtual void UpdateTargetAreaOfCell(const CellPtr pCell)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
static SimulationTime * Instance()
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
double GetTime() const