BuskeCompressionForce.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 "BuskeCompressionForce.hpp"
00030 #include "NodeBasedCellPopulation.hpp"
00031 
00032 template<unsigned DIM>
00033 BuskeCompressionForce<DIM>::BuskeCompressionForce()
00034     : AbstractForce<DIM>(),
00035       mCompressionEnergyParameter(5.0)
00036 {
00037 }
00038 
00039 template<unsigned DIM>
00040 double BuskeCompressionForce<DIM>::GetCompressionEnergyParameter()
00041 {
00042     return mCompressionEnergyParameter;
00043 }
00044 
00045 template<unsigned DIM>
00046 void BuskeCompressionForce<DIM>::SetCompressionEnergyParameter(double compressionEnergyParameter)
00047 {
00048     mCompressionEnergyParameter = compressionEnergyParameter;
00049 }
00050 
00051 template<unsigned DIM>
00052 void BuskeCompressionForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00053                                                       AbstractCellPopulation<DIM>& rCellPopulation)
00054 {
00055     // This force class is defined for NodeBasedCellPopulations only
00056     assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL);
00057 
00058     NodeBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation);
00059 
00060 
00061     c_vector<double, DIM> unit_vector;
00062 
00063     // Loop over cells in the population
00064     for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
00065          cell_iter != rCellPopulation.End();
00066          ++cell_iter)
00067     {
00068         // Get the node index corresponding to this cell
00069         unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
00070 
00071         // Get the location of this node
00072         c_vector<double, DIM> node_i_location = rCellPopulation.GetNode(node_index)->rGetLocation();
00073 
00074         // Get the radius of this cell
00075         double radius_of_cell_i = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh().GetCellRadius(node_index);
00076 
00077         double delta_V_c = 0.0;
00078         c_vector<double, DIM> dVAdd_vector = zero_vector<double>(DIM);
00079 
00080         // Get the set of node indices corresponding to this cell's neighbours
00081         std::set<unsigned> neighbouring_node_indices = p_static_cast_cell_population->GetNeighbouringNodeIndices(node_index);
00082 
00083         // Loop over this set
00084         for (std::set<unsigned>::iterator iter = neighbouring_node_indices.begin();
00085              iter != neighbouring_node_indices.end();
00086              ++iter)
00087         {
00088             // Get the location of this node
00089             c_vector<double, DIM> node_j_location = rCellPopulation.GetNode(*iter)->rGetLocation();
00090 
00091             // Get the unit vector parallel to the line joining the two nodes (assuming no periodicities etc.)
00092             unit_vector = node_j_location - node_i_location;
00093 
00094             // Calculate the distance between the two nodes
00095             double dij = norm_2(unit_vector);
00096 
00097             unit_vector /= dij;
00098 
00099             // Get the radius of the cell corresponding to this node
00100             double radius_of_cell_j = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh().GetCellRadius(*iter);
00101 
00102             // If the cells are close enough to exert a force on each other...
00103             if (dij < radius_of_cell_i + radius_of_cell_j)
00104             {
00105                 // ...then compute the adhesion force and add it to the vector of forces...
00106                 double xij = 0.5*(radius_of_cell_i*radius_of_cell_i - radius_of_cell_j*radius_of_cell_j + dij*dij)/dij;
00107                 double dxijdd = 1.0 - xij/dij;
00108                 double dVAdd = M_PI*dxijdd*(5.0*pow(radius_of_cell_i,2) + 3.0*pow(xij,2) - 8.0*radius_of_cell_i*xij)/3.0;
00109 
00110                 dVAdd_vector += dVAdd*unit_vector;
00111 
00112                 // ...and add the contribution to the compression force acting on cell i
00113                 delta_V_c += M_PI*pow(radius_of_cell_i - xij,2)*(2*radius_of_cell_i - xij)/3.0;
00114             }
00115         }
00116 
00117         double V_A = 4.0/3.0*M_PI*pow(radius_of_cell_i,3) - delta_V_c;
00118 
00124         double V_T = 5.0;
00125 
00126         // Note: the sign in force_magnitude is different from the one in equation (A3) in the Buske paper
00127         rForces[node_index] += -mCompressionEnergyParameter/V_T*(V_T - V_A)*dVAdd_vector;
00128     }
00129 }
00130 
00131 template<unsigned DIM>
00132 void BuskeCompressionForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00133 {
00134     *rParamsFile << "\t\t\t<CompressionEnergyParameter>" << mCompressionEnergyParameter << "</CompressionEnergyParameter>\n";
00135 
00136     // Call method on direct parent class
00137     AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00138 }
00139 
00141 // Explicit instantiation
00143 
00144 template class BuskeCompressionForce<1>;
00145 template class BuskeCompressionForce<2>;
00146 template class BuskeCompressionForce<3>;
00147 
00148 // Serialization for Boost >= 1.36
00149 #include "SerializationExportWrapperForCpp.hpp"
00150 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeCompressionForce)
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3