Chaste  Release::3.4
BuskeCompressionForce.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, 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 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF 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 
39 template<unsigned DIM>
41  : AbstractForce<DIM>(),
42  mCompressionEnergyParameter(5.0)
43 {
44 }
45 
46 template<unsigned DIM>
48 {
49  return mCompressionEnergyParameter;
50 }
51 
52 template<unsigned DIM>
53 void BuskeCompressionForce<DIM>::SetCompressionEnergyParameter(double compressionEnergyParameter)
54 {
55  mCompressionEnergyParameter = compressionEnergyParameter;
56 }
57 
58 template<unsigned DIM>
60 {
61  // This force class is defined for NodeBasedCellPopulations only
62  assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL);
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  c_vector<double, DIM> 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  c_vector<double, DIM> 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 = node_j_location - 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 
141 template<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
151 template class BuskeCompressionForce<1>;
152 template class BuskeCompressionForce<2>;
153 template class BuskeCompressionForce<3>;
154 
155 // Serialization for Boost >= 1.36
virtual Node< SPACE_DIM > * GetNode(unsigned index)=0
void SetCompressionEnergyParameter(double compressionEnergyParameter)
void OutputForceParameters(out_stream &rParamsFile)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
Definition: Node.hpp:58
unsigned GetLocationIndexUsingCell(CellPtr pCell)
void AddAppliedForceContribution(c_vector< double, SPACE_DIM > &forceContribution)
Definition: Node.cpp:225
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
const c_vector< double, SPACE_DIM > & rGetLocation() const
Definition: Node.cpp:140
double GetRadius()
Definition: Node.cpp:249
virtual void OutputForceParameters(out_stream &rParamsFile)=0