Chaste Commit::8b5d759ac2eb95e67ae57699734101efccb0a0a9
BuskeCompressionForce.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 "BuskeCompressionForce.hpp"
37#include "NodeBasedCellPopulation.hpp"
38
39template<unsigned DIM>
41 : AbstractForce<DIM>(),
42 mCompressionEnergyParameter(5.0)
43{
44}
45
46template<unsigned DIM>
48{
49 return mCompressionEnergyParameter;
50}
51
52template<unsigned DIM>
53void BuskeCompressionForce<DIM>::SetCompressionEnergyParameter(double compressionEnergyParameter)
54{
55 mCompressionEnergyParameter = compressionEnergyParameter;
56}
57
58template<unsigned DIM>
60{
61 // This force class is defined for NodeBasedCellPopulations only
62 assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != nullptr);
63
64 NodeBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation);
65
66 c_vector<double, DIM> unit_vector;
67
68 // Loop over cells in the population
69 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
70 cell_iter != rCellPopulation.End();
71 ++cell_iter)
72 {
73 // Get the node index corresponding to this cell
74 unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
75
76 Node<DIM>* p_node_i = rCellPopulation.GetNode(node_index);
77
78 // Get the location of this node
79 const c_vector<double, DIM>& r_node_i_location = p_node_i->rGetLocation();
80
81 // Get the radius of this cell
82 double radius_of_cell_i = p_node_i->GetRadius();
83
84 double delta_V_c = 0.0;
85 c_vector<double, DIM> dVAdd_vector = zero_vector<double>(DIM);
86
87 // Get the set of node indices corresponding to this cell's neighbours
88 std::set<unsigned> neighbouring_node_indices = p_static_cast_cell_population->GetNeighbouringNodeIndices(node_index);
89
90 // Loop over this set
91 for (std::set<unsigned>::iterator iter = neighbouring_node_indices.begin();
92 iter != neighbouring_node_indices.end();
93 ++iter)
94 {
95 Node<DIM>* p_node_j = rCellPopulation.GetNode(*iter);
96
97 // Get the location of this node
98 const c_vector<double, DIM>& r_node_j_location = p_node_j->rGetLocation();
99
100 // Get the unit vector parallel to the line joining the two nodes (assuming no periodicities etc.)
101 unit_vector = r_node_j_location - r_node_i_location;
102
103 // Calculate the distance between the two nodes
104 double dij = norm_2(unit_vector);
105
106 unit_vector /= dij;
107
108 // Get the radius of the cell corresponding to this node
109 double radius_of_cell_j = p_node_j->GetRadius();
110
111 // If the cells are close enough to exert a force on each other...
112 if (dij < radius_of_cell_i + radius_of_cell_j)
113 {
114 // ...then compute the adhesion force and add it to the vector of forces...
115 double xij = 0.5*(radius_of_cell_i*radius_of_cell_i - radius_of_cell_j*radius_of_cell_j + dij*dij)/dij;
116 double dxijdd = 1.0 - xij/dij;
117 double dVAdd = M_PI*dxijdd*(5.0*pow(radius_of_cell_i,2.0) + 3.0*pow(xij,2.0) - 8.0*radius_of_cell_i*xij)/3.0;
118
119 dVAdd_vector += dVAdd*unit_vector;
120
121 // ...and add the contribution to the compression force acting on cell i
122 delta_V_c += M_PI*pow(radius_of_cell_i - xij,2.0)*(2*radius_of_cell_i - xij)/3.0;
123 }
124 }
125
126 double V_A = 4.0/3.0*M_PI*pow(radius_of_cell_i,3.0) - delta_V_c;
127
133 double V_T = 5.0;
134
135 // Note: the sign in force_magnitude is different from the one in equation (A3) in the Buske paper
136 c_vector<double, DIM> applied_force = -mCompressionEnergyParameter/V_T*(V_T - V_A)*dVAdd_vector;
137 p_node_i->AddAppliedForceContribution(applied_force);
138 }
139}
140
141template<unsigned DIM>
143{
144 *rParamsFile << "\t\t\t<CompressionEnergyParameter>" << mCompressionEnergyParameter << "</CompressionEnergyParameter>\n";
145
146 // Call method on direct parent class
148}
149
150// Explicit instantiation
151template class BuskeCompressionForce<1>;
152template class BuskeCompressionForce<2>;
153template class BuskeCompressionForce<3>;
154
155// Serialization for Boost >= 1.36
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual Node< SPACE_DIM > * GetNode(unsigned index)=0
unsigned GetLocationIndexUsingCell(CellPtr pCell)
virtual void OutputForceParameters(out_stream &rParamsFile)=0
void OutputForceParameters(out_stream &rParamsFile)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
void SetCompressionEnergyParameter(double compressionEnergyParameter)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
Definition Node.hpp:59
const c_vector< double, SPACE_DIM > & rGetLocation() const
Definition Node.cpp:139
void AddAppliedForceContribution(const c_vector< double, SPACE_DIM > &rForceContribution)
Definition Node.cpp:224
double GetRadius()
Definition Node.cpp:248