Chaste Commit::6e4f5fe395bca70eb7641cf6e0e87f450383ca5a
DeltaNotchEdgeInteriorTrackingModifier.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 "DeltaNotchEdgeInteriorTrackingModifier.hpp"
37#include "CellSrnModel.hpp"
38#include "DeltaNotchInteriorSrnModel.hpp"
39#include "DeltaNotchEdgeSrnModel.hpp"
40
41template<unsigned DIM>
46
47template<unsigned DIM>
51
52template<unsigned DIM>
54{
55 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 // First recover each cell's Notch and Delta concentrations from the ODEs and store
72 // in CellData and CellEdgeData
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 /* Cell Edges delta notch collection */
80 std::vector<double> notch_vec;
81 std::vector<double> delta_vec;
82
83
84 for (unsigned i = 0 ; i < p_cell_edge_model->GetNumEdgeSrn(); i++)
85 {
86 auto p_model = boost::static_pointer_cast<DeltaNotchEdgeSrnModel>(p_cell_edge_model->GetEdgeSrn(i));
87 double edge_delta = p_model->GetDelta();
88 double edge_notch = p_model->GetNotch();
89
90 delta_vec.push_back(edge_delta);
91 notch_vec.push_back(edge_notch);
92 }
93 // Note that the state variables must be in the same order as listed in DeltaNotchOdeSystem
94 cell_iter->GetCellEdgeData()->SetItem("edge delta", delta_vec);
95 cell_iter->GetCellEdgeData()->SetItem("edge notch", notch_vec);
96
97 /* Interior delta notch collection */
98 //Filling interior delta/notch value, interior model must be specified for this edge-interior example
99 assert(p_cell_edge_model->GetInteriorSrn() != nullptr);
100 auto p_interior_model = boost::static_pointer_cast<DeltaNotchInteriorSrnModel>(p_cell_edge_model->GetInteriorSrn());
101
102 // Note that the state variables must be in the same order as listed in DeltaNotchOdeSystem
103 cell_iter->GetCellData()->SetItem("interior delta", p_interior_model->GetDelta());
104 cell_iter->GetCellData()->SetItem("interior notch", p_interior_model->GetNotch());
105 }
106
107 // After the edge data is filled, fill the edge neighbour data
108 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
109 cell_iter != rCellPopulation.End();
110 ++cell_iter)
111 {
112 auto p_cell_edge_model = static_cast<CellSrnModel*>(cell_iter->GetSrnModel());
113 const unsigned num_cell_edges = p_cell_edge_model->GetNumEdgeSrn();
114 std::vector<double> neigh_mean_delta(num_cell_edges);
115
116 // Cell interior
117 double total_edge_delta = 0;
118 double total_edge_notch = 0;
119
120 auto edges_delta = cell_iter->GetCellEdgeData()->GetItem("edge delta");
121 auto edges_notch = cell_iter->GetCellEdgeData()->GetItem("edge notch");
122
123 for (unsigned i = 0 ; i < p_cell_edge_model->GetNumEdgeSrn(); i++)
124 {
125 total_edge_delta += edges_delta[i];
126 total_edge_notch += edges_notch[i];
127 }
128
129 cell_iter->GetCellData()->SetItem("total neighbour edge delta", total_edge_delta);
130 cell_iter->GetCellData()->SetItem("total edge notch", total_edge_notch);
131
132 // Cell edge
133 for (unsigned i=0; i<num_cell_edges; ++i)
134 {
135 // Get neighbouring cell's values of delta on this
136 auto elemNeighbours = rCellPopulation.GetNeighbouringEdgeIndices(*cell_iter, i);
137 double mean_delta = 0;
138 for (auto neighbourIndex: elemNeighbours)
139 {
140 auto neighbourCell = rCellPopulation.GetCellUsingLocationIndex(neighbourIndex.first);
141 std::vector<double> neighbour_delta_vec = neighbourCell->GetCellEdgeData()->GetItem("edge delta");
142 mean_delta += neighbour_delta_vec[neighbourIndex.second];
143 }
144 if (elemNeighbours.size() > 0)
145 {
146 mean_delta = mean_delta/elemNeighbours.size();
147 }
148 neigh_mean_delta[i] = mean_delta;
149 }
150 cell_iter->GetCellEdgeData()->SetItem("neighbour delta", neigh_mean_delta);
151 }
152}
153
154template<unsigned DIM>
156{
157 // No parameters to output, so just call method on direct parent class
159}
160
161
162// Explicit instantiation
166
167// Serialization for Boost >= 1.36
#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
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
void UpdateCellData(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual void UpdateAtEndOfTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)