Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
NagaiHondaDifferentialAdhesionForce.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 "NagaiHondaDifferentialAdhesionForce.hpp"
37#include "CellLabel.hpp"
38
39template<unsigned DIM>
41 : NagaiHondaForce<DIM>(),
42 mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(1.0),
43 mNagaiHondaLabelledCellCellAdhesionEnergyParameter(1.0),
44 mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(1.0)
45{
46}
47
48template<unsigned DIM>
52
53template<unsigned DIM>
55 Node<DIM>* pNodeB,
56 VertexBasedCellPopulation<DIM>& rVertexCellPopulation)
57{
58 // Find the indices of the elements owned by each node
59 std::set<unsigned> elements_containing_nodeA = pNodeA->rGetContainingElementIndices();
60 std::set<unsigned> elements_containing_nodeB = pNodeB->rGetContainingElementIndices();
61
62 // Find common elements
63 std::set<unsigned> shared_elements;
64 std::set_intersection(elements_containing_nodeA.begin(),
65 elements_containing_nodeA.end(),
66 elements_containing_nodeB.begin(),
67 elements_containing_nodeB.end(),
68 std::inserter(shared_elements, shared_elements.begin()));
69
70 // Check that the nodes have a common edge
71 assert(!shared_elements.empty());
72
73 // If the edge corresponds to a single element, then the cell is on the boundary
74 if (shared_elements.size() == 1)
75 {
76 unsigned element_index = *(shared_elements.begin());
77
78 // Get cell associated with this element
79 CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index);
80
81 if (p_cell->template HasCellProperty<CellLabel>())
82 {
83 // This cell is labelled
84 return this->GetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter();
85 }
86 else
87 {
88 // This cell is not labelled
89 return this->GetNagaiHondaCellBoundaryAdhesionEnergyParameter();
90 }
91 }
92 else
93 {
94 // Work out the number of labelled cells: 0,1 or 2
95 unsigned num_labelled_cells = 0;
96 for (std::set<unsigned>::iterator iter = shared_elements.begin();
97 iter != shared_elements.end();
98 ++iter)
99 {
100 unsigned element_index = *(iter);
101
102 // Get cell associated with this element
103 CellPtr p_cell = rVertexCellPopulation.GetCellUsingLocationIndex(element_index);
104
105 if (p_cell->template HasCellProperty<CellLabel>())
106 {
107 num_labelled_cells++;
108 }
109 }
110
111 if (num_labelled_cells == 2)
112 {
113 // Both cells are labelled
114 return this->GetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter();
115 }
116 else if (num_labelled_cells == 1)
117 {
118 // One cell is labelled
119 return this->GetNagaiHondaLabelledCellCellAdhesionEnergyParameter();
120 }
121 else
122 {
123 // Neither cell is labelled
124 assert(num_labelled_cells == 0);
125 return this->GetNagaiHondaCellCellAdhesionEnergyParameter();
126 }
127 }
128}
129
130template<unsigned DIM>
132{
133 return mNagaiHondaLabelledCellCellAdhesionEnergyParameter;
134}
135
136template<unsigned DIM>
138{
139 return mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter;
140}
141
142template<unsigned DIM>
144{
145 return mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter;
146}
147
148template<unsigned DIM>
150{
151 mNagaiHondaLabelledCellCellAdhesionEnergyParameter = labelledCellCellAdhesionEnergyParameter;
152}
153
154template<unsigned DIM>
156{
157 mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter = labelledCellLabelledCellAdhesionEnergyParameter;
158}
159
160template<unsigned DIM>
162{
163 mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter = labelledCellBoundaryAdhesionEnergyParameter;
164}
165
166template<unsigned DIM>
168{
169 // Output member variables
170 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter> \n";
171 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellCellAdhesionEnergyParameter>" << mNagaiHondaLabelledCellCellAdhesionEnergyParameter << "</NagaiHondaLabelledCellCellAdhesionEnergyParameter> \n";
172 *rParamsFile << "\t\t\t<NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter>" << mNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter << "</NagaiHondaLabelledCellBoundaryAdhesionEnergyParameter> \n";
173
174 // Call method on direct parent class
176}
177
178// Explicit instantiation
182
183// Serialization for Boost >= 1.36
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
void SetNagaiHondaLabelledCellLabelledCellAdhesionEnergyParameter(double labelledCellLabelledCellAdhesionEnergyParameter)
void SetNagaiHondaLabelledCellBoundaryAdhesionEnergyParameter(double labelledCellBoundaryAdhesionEnergyParameter)
void SetNagaiHondaLabelledCellCellAdhesionEnergyParameter(double labelledCellCellAdhesionEnergyParameter)
virtual double GetAdhesionParameter(Node< DIM > *pNodeA, Node< DIM > *pNodeB, VertexBasedCellPopulation< DIM > &rVertexCellPopulation)
void OutputForceParameters(out_stream &rParamsFile)
Definition Node.hpp:59
std::set< unsigned > & rGetContainingElementIndices()
Definition Node.cpp:300