BuskeElasticForce.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 "BuskeElasticForce.hpp"
00030 
00031 template<unsigned DIM>
00032 BuskeElasticForce<DIM>::BuskeElasticForce()
00033    : AbstractTwoBodyInteractionForce<DIM>(),
00034      mDeformationEnergyParameter(4.0/(3.0*5.0)) // Denoted by D in Buske et al (2011) (doi:10.1371/journal.pcbi.1001045).
00035 {
00036 }
00037 
00038 template<unsigned DIM>
00039 double BuskeElasticForce<DIM>::GetDeformationEnergyParameter()
00040 {
00041     return mDeformationEnergyParameter;
00042 }
00043 
00044 template<unsigned DIM>
00045 void BuskeElasticForce<DIM>::SetDeformationEnergyParameter(double deformationEnergyParameter)
00046 {
00047     mDeformationEnergyParameter = deformationEnergyParameter;
00048 }
00049 
00050 template<unsigned DIM>
00051 c_vector<double, DIM> BuskeElasticForce<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 BuskeElasticForce<DIM>::GetMagnitudeOfForce(double distanceBetweenNodes, double radiusOfCellOne, double radiusOfCellTwo)
00100 {
00101     // Calculate contribution from deformation interaction energy
00102     double dWDdd;
00103 
00104     if (distanceBetweenNodes < radiusOfCellOne + radiusOfCellTwo)
00105     {
00106         dWDdd = -pow(radiusOfCellOne + radiusOfCellTwo - distanceBetweenNodes,1.5)
00107                 *pow(radiusOfCellOne*radiusOfCellTwo/(radiusOfCellOne+radiusOfCellTwo),0.5)
00108                 /mDeformationEnergyParameter;
00109     }
00110     else  // no deformation energy contribution as too far apart
00111     {
00112         dWDdd = 0.0;
00113     }
00114 
00115     return dWDdd; //
00116 }
00117 
00118 template<unsigned DIM>
00119 void BuskeElasticForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00120 {
00121     *rParamsFile << "\t\t\t<DeformationEnergyParameter>" << mDeformationEnergyParameter << "</DeformationEnergyParameter>\n";
00122 
00123     // Call method on direct parent class
00124     AbstractTwoBodyInteractionForce<DIM>::OutputForceParameters(rParamsFile);
00125 }
00126 
00128 // Explicit instantiation
00130 
00131 template class BuskeElasticForce<1>;
00132 template class BuskeElasticForce<2>;
00133 template class BuskeElasticForce<3>;
00134 
00135 // Serialization for Boost >= 1.36
00136 #include "SerializationExportWrapperForCpp.hpp"
00137 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeElasticForce)
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3