Chaste  Build::
Owen2011TrackingModifier.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 "Owen2011TrackingModifier.hpp"
37 #include "Owen2011OxygenBasedCellCycleModel.hpp"
38 #include "QuiescentCancerCellMutationState.hpp"
39 #include "CancerCellMutationState.hpp"
40 #include "WildTypeCellMutationState.hpp"
41 #include "PottsMesh.hpp"
42 
43 template<unsigned DIM>
46  {
47  }
48 
49 template<unsigned DIM>
51 {
52 }
53 
54 template<unsigned DIM>
55 void Owen2011TrackingModifier<DIM>::UpdateAtEndOfTimeStep(AbstractCellPopulation<DIM,DIM>& rCellPopulation)
56 {
57  UpdateCellData(rCellPopulation);
58 }
59 
60 template<unsigned DIM>
61 void Owen2011TrackingModifier<DIM>::SetupSolve(AbstractCellPopulation<DIM,DIM>& rCellPopulation, std::string outputDirectory)
62 {
63  /*
64  * We must update CellData in SetupSolve(), otherwise it will not have been
65  * fully initialised by the time we enter the main time loop.
66  */
67  UpdateCellData(rCellPopulation);
68 }
69 
70 template<unsigned DIM>
71 void Owen2011TrackingModifier<DIM>::UpdateCellData(AbstractCellPopulation<DIM,DIM>& rCellPopulation)
72 {
73 
74  // Make sure the cell population is updated
75  rCellPopulation.Update();
76 
77  // Recover each cell's concentrations from the ODEs and store in CellData
78  for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
79  cell_iter != rCellPopulation.End();
80  ++cell_iter)
81  {
82  Owen2011OxygenBasedCellCycleModel* p_model = static_cast<Owen2011OxygenBasedCellCycleModel*>(cell_iter->GetCellCycleModel());
83  double this_phi = p_model->GetPhi();
84  double this_p53 = p_model->GetP53();
85  double this_VEGF = p_model->GetVEGF();
86 
87  // Note that the state variables must be in the same order as listed in Owen2011OxygenBasedOdeSystem
88  cell_iter->GetCellData()->SetItem("Phi", this_phi);
89  cell_iter->GetCellData()->SetItem("p53", this_p53);
90  cell_iter->GetCellData()->SetItem("VEGF", this_VEGF);
91 
92  // also calculate number of normal and cancerous neighbours
93  unsigned number_of_normal_neighbours = 0;
94  unsigned number_of_cancerous_neighbours = 0;
95 
96  std::set<unsigned> neighbouring_node_indices = static_cast<PottsMesh<DIM>& >(rCellPopulation.rGetMesh()).GetMooreNeighbouringNodeIndices(rCellPopulation.GetLocationIndexUsingCell(*cell_iter));
97  std::set<unsigned>::iterator node_it;
98  for (node_it = neighbouring_node_indices.begin(); node_it != neighbouring_node_indices.end(); node_it++)
99  {
100  if (rCellPopulation.IsCellAttachedToLocationIndex(*node_it))
101  {
102  std::set<CellPtr> neighbour_cells = rCellPopulation.GetCellsUsingLocationIndex(*node_it);
103  std::set<CellPtr>::iterator cell_neighbour_it;
104  for (cell_neighbour_it = neighbour_cells.begin(); cell_neighbour_it != neighbour_cells.end(); cell_neighbour_it++)
105  {
106 
107  if ((*cell_neighbour_it)->GetMutationState()->template IsType<WildTypeCellMutationState>())
108  {
109  number_of_normal_neighbours++;
110  }
111  if ((*cell_neighbour_it)->GetMutationState()->template IsType<CancerCellMutationState>() ||
112  (*cell_neighbour_it)->GetMutationState()->template IsType<QuiescentCancerCellMutationState>())
113  {
114  number_of_cancerous_neighbours++;
115  }
116 
117  }
118  }
119  }
120 
121  cell_iter->GetCellData()->SetItem("Number_of_cancerous_neighbours", number_of_cancerous_neighbours);
122  cell_iter->GetCellData()->SetItem("Number_of_normal_neighbours", number_of_normal_neighbours);
123  }
124 }
125 
126 template<unsigned DIM>
128 {
129  // No parameters to output, so just call method on direct parent class
131 }
132 
133 // Explicit instantiation
134 template class Owen2011TrackingModifier<1>;
135 template class Owen2011TrackingModifier<2>;
136 template class Owen2011TrackingModifier<3>;
137 
138 // Serialization for Boost >= 1.36
139 #include "SerializationExportWrapperForCpp.hpp"
140 EXPORT_TEMPLATE_CLASS_SAME_DIMS(Owen2011TrackingModifier)
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
void UpdateCellData(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual void UpdateAtEndOfTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)