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