Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
DeltaNotchEdgeInteriorTrackingModifier.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 "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 boost::shared_ptr<DeltaNotchEdgeSrnModel> p_model
87 = boost::static_pointer_cast<DeltaNotchEdgeSrnModel>(p_cell_edge_model->GetEdgeSrn(i));
88 double edge_delta = p_model->GetDelta();
89 double edge_notch = p_model->GetNotch();
90
91 delta_vec.push_back(edge_delta);
92 notch_vec.push_back(edge_notch);
93 }
94 // Note that the state variables must be in the same order as listed in DeltaNotchOdeSystem
95 cell_iter->GetCellEdgeData()->SetItem("edge delta", delta_vec);
96 cell_iter->GetCellEdgeData()->SetItem("edge notch", notch_vec);
97
98 /* Interior delta notch collection */
99 //Filling interior delta/notch value, interior model must be specified for this edge-interior example
100 assert(p_cell_edge_model->GetInteriorSrn() != nullptr);
101 boost::shared_ptr<DeltaNotchInteriorSrnModel> p_interior_model
102 = boost::static_pointer_cast<DeltaNotchInteriorSrnModel>(p_cell_edge_model->GetInteriorSrn());
103
104 // Note that the state variables must be in the same order as listed in DeltaNotchOdeSystem
105 cell_iter->GetCellData()->SetItem("interior delta", p_interior_model->GetDelta());
106 cell_iter->GetCellData()->SetItem("interior notch", p_interior_model->GetNotch());
107 }
108
109 // After the edge data is filled, fill the edge neighbour data
110 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
111 cell_iter != rCellPopulation.End();
112 ++cell_iter)
113 {
114 auto p_cell_edge_model = static_cast<CellSrnModel*>(cell_iter->GetSrnModel());
115 const unsigned num_cell_edges = p_cell_edge_model->GetNumEdgeSrn();
116 std::vector<double> neigh_mean_delta(num_cell_edges);
117
118 // Cell interior
119 double total_edge_delta = 0;
120 double total_edge_notch = 0;
121
122 auto edges_delta = cell_iter->GetCellEdgeData()->GetItem("edge delta");
123 auto edges_notch = cell_iter->GetCellEdgeData()->GetItem("edge notch");
124
125 for (unsigned i = 0 ; i < p_cell_edge_model->GetNumEdgeSrn(); i++)
126 {
127 total_edge_delta += edges_delta[i];
128 total_edge_notch += edges_notch[i];
129 }
130
131 cell_iter->GetCellData()->SetItem("total neighbour edge delta", total_edge_delta);
132 cell_iter->GetCellData()->SetItem("total edge notch", total_edge_notch);
133
134 // Cell edge
135 for (unsigned i=0; i<num_cell_edges; ++i)
136 {
137 // Get neighbouring cell's values of delta on this
138 auto elemNeighbours = rCellPopulation.GetNeighbouringEdgeIndices(*cell_iter, i);
139 double mean_delta = 0;
140 for (auto neighbourIndex: elemNeighbours)
141 {
142 auto neighbourCell = rCellPopulation.GetCellUsingLocationIndex(neighbourIndex.first);
143 std::vector<double> neighbour_delta_vec = neighbourCell->GetCellEdgeData()->GetItem("edge delta");
144 mean_delta += neighbour_delta_vec[neighbourIndex.second];
145 }
146 if (elemNeighbours.size() > 0)
147 {
148 mean_delta = mean_delta/elemNeighbours.size();
149 }
150 neigh_mean_delta[i] = mean_delta;
151 }
152 cell_iter->GetCellEdgeData()->SetItem("neighbour delta", neigh_mean_delta);
153 }
154}
155
156template<unsigned DIM>
158{
159 // No parameters to output, so just call method on direct parent class
161}
162
163
164// Explicit instantiation
168
169// 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)