BuskeAdhesiveForce.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "BuskeAdhesiveForce.hpp"
00030 
00031 template<unsigned DIM>
00032 BuskeAdhesiveForce<DIM>::BuskeAdhesiveForce()
00033    : AbstractTwoBodyInteractionForce<DIM>(),
00034      mAdhesionEnergyParameter(0.2)        // Denoted by epsilon in Buske et al (2011) (doi:10.1371/journal.pcbi.1001045).
00035 {
00036 }
00037 
00038 template<unsigned DIM>
00039 double BuskeAdhesiveForce<DIM>::GetAdhesionEnergyParameter()
00040 {
00041     return mAdhesionEnergyParameter;
00042 }
00043 
00044 template<unsigned DIM>
00045 void BuskeAdhesiveForce<DIM>::SetAdhesionEnergyParameter(double adhesionEnergyParameter)
00046 {
00047     mAdhesionEnergyParameter = adhesionEnergyParameter;
00048 }
00049 
00050 template<unsigned DIM>
00051 c_vector<double, DIM> BuskeAdhesiveForce<DIM>::CalculateForceBetweenNodes(unsigned nodeAGlobalIndex,
00052                                                                           unsigned nodeBGlobalIndex,
00053                                                                           AbstractCellPopulation<DIM>& rCellPopulation)
00054 {
00055     // This force class is defined for NodeBasedCellPopulations only
00056     assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL);
00057 
00058     // We should only ever calculate the force between two distinct nodes
00059     assert(nodeAGlobalIndex != nodeBGlobalIndex);
00060 
00061     // Get the node locations
00062     c_vector<double, DIM> node_a_location = rCellPopulation.GetNode(nodeAGlobalIndex)->rGetLocation();
00063     c_vector<double, DIM> node_b_location = rCellPopulation.GetNode(nodeBGlobalIndex)->rGetLocation();
00064 
00065     // Get the unit vector parallel to the line joining the two nodes (assuming no periodicities etc.)
00066     c_vector<double, DIM> unit_vector = node_b_location - node_a_location;
00067 
00068     // Calculate the distance between the two nodes
00069     double distance_between_nodes = norm_2(unit_vector);
00070 
00071     // Account for any cutoff in the force law
00072     if (this->mUseCutOffLength)
00073     {
00074         if (distance_between_nodes >= this->GetCutOffLength())
00075         {
00076             return zero_vector<double>(DIM);
00077         }
00078     }
00079 
00080     // Assert that the nodes are a finite, non-zero distance apart
00081     assert(distance_between_nodes > 0);
00082     assert(!std::isnan(distance_between_nodes));
00083 
00084     // Normalize the unit vector
00085     unit_vector /= distance_between_nodes;
00086 
00087     // Get the cell radii
00088     NodesOnlyMesh<DIM>& r_mesh = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh();
00089     double radius_of_cell_one = r_mesh.GetCellRadius(nodeAGlobalIndex);
00090     double radius_of_cell_two = r_mesh.GetCellRadius(nodeBGlobalIndex);
00091 
00092     // Compute the force vector
00093     c_vector<double, DIM> force_between_nodes = GetMagnitudeOfForce(distance_between_nodes,radius_of_cell_one,radius_of_cell_two) * unit_vector;
00094 
00095     return force_between_nodes;
00096 }
00097 
00098 template<unsigned DIM>
00099 double BuskeAdhesiveForce<DIM>::GetMagnitudeOfForce(double distanceBetweenNodes, double radiusOfCellOne, double radiusOfCellTwo)
00100 {
00101     double dWAdd = 0.0;
00102 
00103     // If the cells are close enough...
00104     if (distanceBetweenNodes < radiusOfCellOne + radiusOfCellTwo)
00105     {
00106         // ...calculate the force contribution from their adhesive interaction energy
00107         double xij = 0.5*(radiusOfCellOne*radiusOfCellOne - radiusOfCellTwo*radiusOfCellTwo + distanceBetweenNodes*distanceBetweenNodes)/distanceBetweenNodes;
00108         double dxijdd = 1.0 - xij/distanceBetweenNodes;
00109         dWAdd = 2.0*mAdhesionEnergyParameter*M_PI*xij*dxijdd;
00110     }
00111 
00112     return dWAdd;
00113 }
00114 
00115 template<unsigned DIM>
00116 void BuskeAdhesiveForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00117 {
00118     *rParamsFile << "\t\t\t<AdhesionEnergyParameter>" << mAdhesionEnergyParameter << "</AdhesionEnergyParameter>\n";
00119 
00120     // Call method on direct parent class
00121     AbstractTwoBodyInteractionForce<DIM>::OutputForceParameters(rParamsFile);
00122 }
00123 
00125 // Explicit instantiation
00127 
00128 template class BuskeAdhesiveForce<1>;
00129 template class BuskeAdhesiveForce<2>;
00130 template class BuskeAdhesiveForce<3>;
00131 
00132 // Serialization for Boost >= 1.36
00133 #include "SerializationExportWrapperForCpp.hpp"
00134 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeAdhesiveForce)
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3