Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
SimpleTargetAreaModifier.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF 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
40template<unsigned DIM>
46
47template<unsigned DIM>
51
52template<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
62 if (dynamic_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel()) == nullptr)
63 {
64 EXCEPTION("If SetGrowthDuration() has not been called, a subclass of AbstractPhaseBasedCellCycleModel must be used");
65 }
66 AbstractPhaseBasedCellCycleModel* p_model = static_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel());
67
68 growth_duration = p_model->GetG1Duration();
69
70 // If the cell is differentiated then its G1 duration is infinite
71 if (growth_duration == DBL_MAX)
72 {
73 // This is just for fixed cell-cycle models, need to work out how to find the g1 duration
74 growth_duration = p_model->GetTransitCellG1Duration();
75 }
76 }
77
78 if (pCell->HasCellProperty<ApoptoticCellProperty>())
79 {
80
81 // Age of cell when apoptosis begins
82 if (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime() < growth_duration)
83 {
84 cell_target_area *= 0.5*(1 + (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime())/growth_duration);
85 }
86
87 // The target area of an apoptotic cell decreases linearly to zero
88 double time_spent_apoptotic = SimulationTime::Instance()->GetTime() - pCell->GetStartOfApoptosisTime();
89
90 cell_target_area *= 1.0 - 0.5/(pCell->GetApoptosisTime())*time_spent_apoptotic;
91 if (cell_target_area < 0)
92 {
93 cell_target_area = 0;
94 }
95
96 }
97 else
98 {
99 double cell_age = pCell->GetAge();
100 // The target area of a proliferating cell increases linearly from A/2 to A over the course of the prescribed duration
101 if (cell_age < growth_duration)
102 {
103 cell_target_area *= 0.5*(1 + cell_age/growth_duration);
104 }
105 else
106 {
114 if (pCell->ReadyToDivide())
115 {
116 cell_target_area = 0.5*this->mReferenceTargetArea;
117 }
118 }
119 }
120 // Set cell data
121 pCell->GetCellData()->SetItem("target area", cell_target_area);
122}
123
124template<unsigned DIM>
126{
127 return mGrowthDuration;
128}
129
130template<unsigned DIM>
132{
133 assert(growthDuration >= 0.0);
134 mGrowthDuration = growthDuration;
135}
136
137template<unsigned DIM>
139{
140 *rParamsFile << "\t\t\t<GrowthDuration>" << mGrowthDuration << "</GrowthDuration>\n";
141
142 // Next, call method on direct parent class
144}
145
146// Explicit instantiation
147template class SimpleTargetAreaModifier<1>;
148template class SimpleTargetAreaModifier<2>;
149template class SimpleTargetAreaModifier<3>;
150
151// Serialization for Boost >= 1.36
const double DOUBLE_UNSET
Definition Exception.hpp:57
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)
void SetGrowthDuration(double growthDuration)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
virtual void UpdateTargetAreaOfCell(const CellPtr pCell)
double GetTime() const
static SimulationTime * Instance()