Chaste Commit::6e4f5fe395bca70eb7641cf6e0e87f450383ca5a
DeltaNotchEdgeTrackingModifier.cpp
1/*
2
3Copyright (c) 2005-2026, 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 "DeltaNotchEdgeTrackingModifier.hpp"
37#include "CellSrnModel.hpp"
38#include "DeltaNotchEdgeSrnModel.hpp"
39
40template<unsigned DIM>
45
46template<unsigned DIM>
50
51template<unsigned DIM>
53{
54 // Update the cell
55 this->UpdateCellData(rCellPopulation);
56}
57
58template<unsigned DIM>
60{
61 /*
62 * We must update CellData in SetupSolve(), otherwise it will not have been
63 * fully initialised by the time we enter the main time loop.
64 */
65 UpdateCellData(rCellPopulation);
66}
67
68template<unsigned DIM>
70{
71 // Recovers each cell's edge levels of notch and delta, and those of its neighbor's
72 // Then saves them
73 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
74 cell_iter != rCellPopulation.End();
75 ++cell_iter)
76 {
77 auto p_cell_edge_model = static_cast<CellSrnModel*>(cell_iter->GetSrnModel());
78
79 /* Cells edge data */
80 std::vector<double> notch_vec;
81 std::vector<double> delta_vec;
82 for (unsigned i = 0 ; i < p_cell_edge_model->GetNumEdgeSrn(); i++)
83 {
84 auto p_model = boost::static_pointer_cast<DeltaNotchEdgeSrnModel>(p_cell_edge_model->GetEdgeSrn(i));
85 double this_delta = p_model->GetDelta();
86 double this_notch = p_model->GetNotch();
87 delta_vec.push_back(this_delta);
88 notch_vec.push_back(this_notch);
89 }
90 // Note that the state variables must be in the same order as listed in DeltaNotchOdeSystem
91 cell_iter->GetCellEdgeData()->SetItem("edge notch", notch_vec);
92 cell_iter->GetCellEdgeData()->SetItem("edge delta", delta_vec);
93
94 /* Cell interior data */
95 //We're not using interior model so interiors are set to 0
96 cell_iter->GetCellData()->SetItem("interior delta", 0);
97 cell_iter->GetCellData()->SetItem("interior notch", 0);
98 }
99
100 // After the edge data is filled, fill the edge neighbour data
101 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
102 cell_iter != rCellPopulation.End();
103 ++cell_iter)
104 {
105 auto p_cell_edge_model = static_cast<CellSrnModel*>(cell_iter->GetSrnModel());
106 const unsigned num_cell_edges = p_cell_edge_model->GetNumEdgeSrn();
107 std::vector<double> neigh_mean_delta(num_cell_edges);
108
109 for (unsigned i=0; i<num_cell_edges; ++i)
110 {
111 // Get neighbouring cell's values of delta on this
112 auto elemNeighbours = rCellPopulation.GetNeighbouringEdgeIndices(*cell_iter, i);
113 double mean_delta = 0;
114 for (auto neighbourIndex: elemNeighbours)
115 {
116 auto neighbourCell = rCellPopulation.GetCellUsingLocationIndex(neighbourIndex.first);
117 std::vector<double> neighbour_delta_vec = neighbourCell->GetCellEdgeData()->GetItem("edge delta");
118 mean_delta += neighbour_delta_vec[neighbourIndex.second];
119 }
120 if (elemNeighbours.size() > 0)
121 {
122 mean_delta = mean_delta/elemNeighbours.size();
123 }
124 neigh_mean_delta[i] = mean_delta;
125 }
126 cell_iter->GetCellEdgeData()->SetItem("neighbour delta", neigh_mean_delta);
127 }
128
129}
130
131template<unsigned DIM>
133{
134 // No parameters to output, so just call method on direct parent class
136}
137
138// Explicit instantiation
142
143// Serialization for Boost >= 1.36
145
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)=0
virtual std::set< std::pair< unsigned, unsigned > > GetNeighbouringEdgeIndices(CellPtr pCell, unsigned pEdgeIndex)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
unsigned GetNumEdgeSrn() const
void UpdateCellData(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual void UpdateAtEndOfTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
void OutputSimulationModifierParameters(out_stream &rParamsFile)