Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #include "BuskeCompressionForce.hpp" 00037 #include "NodeBasedCellPopulation.hpp" 00038 00039 template<unsigned DIM> 00040 BuskeCompressionForce<DIM>::BuskeCompressionForce() 00041 : AbstractForce<DIM>(), 00042 mCompressionEnergyParameter(5.0) 00043 { 00044 } 00045 00046 template<unsigned DIM> 00047 double BuskeCompressionForce<DIM>::GetCompressionEnergyParameter() 00048 { 00049 return mCompressionEnergyParameter; 00050 } 00051 00052 template<unsigned DIM> 00053 void BuskeCompressionForce<DIM>::SetCompressionEnergyParameter(double compressionEnergyParameter) 00054 { 00055 mCompressionEnergyParameter = compressionEnergyParameter; 00056 } 00057 00058 template<unsigned DIM> 00059 void BuskeCompressionForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces, 00060 AbstractCellPopulation<DIM>& rCellPopulation) 00061 { 00062 // This force class is defined for NodeBasedCellPopulations only 00063 assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL); 00064 00065 NodeBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation); 00066 00067 00068 c_vector<double, DIM> unit_vector; 00069 00070 // Loop over cells in the population 00071 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin(); 00072 cell_iter != rCellPopulation.End(); 00073 ++cell_iter) 00074 { 00075 // Get the node index corresponding to this cell 00076 unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter); 00077 00078 // Get the location of this node 00079 c_vector<double, DIM> node_i_location = rCellPopulation.GetNode(node_index)->rGetLocation(); 00080 00081 // Get the radius of this cell 00082 double radius_of_cell_i = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh().GetCellRadius(node_index); 00083 00084 double delta_V_c = 0.0; 00085 c_vector<double, DIM> dVAdd_vector = zero_vector<double>(DIM); 00086 00087 // Get the set of node indices corresponding to this cell's neighbours 00088 std::set<unsigned> neighbouring_node_indices = p_static_cast_cell_population->GetNeighbouringNodeIndices(node_index); 00089 00090 // Loop over this set 00091 for (std::set<unsigned>::iterator iter = neighbouring_node_indices.begin(); 00092 iter != neighbouring_node_indices.end(); 00093 ++iter) 00094 { 00095 // Get the location of this node 00096 c_vector<double, DIM> node_j_location = rCellPopulation.GetNode(*iter)->rGetLocation(); 00097 00098 // Get the unit vector parallel to the line joining the two nodes (assuming no periodicities etc.) 00099 unit_vector = node_j_location - node_i_location; 00100 00101 // Calculate the distance between the two nodes 00102 double dij = norm_2(unit_vector); 00103 00104 unit_vector /= dij; 00105 00106 // Get the radius of the cell corresponding to this node 00107 double radius_of_cell_j = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh().GetCellRadius(*iter); 00108 00109 // If the cells are close enough to exert a force on each other... 00110 if (dij < radius_of_cell_i + radius_of_cell_j) 00111 { 00112 // ...then compute the adhesion force and add it to the vector of forces... 00113 double xij = 0.5*(radius_of_cell_i*radius_of_cell_i - radius_of_cell_j*radius_of_cell_j + dij*dij)/dij; 00114 double dxijdd = 1.0 - xij/dij; 00115 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; 00116 00117 dVAdd_vector += dVAdd*unit_vector; 00118 00119 // ...and add the contribution to the compression force acting on cell i 00120 delta_V_c += M_PI*pow(radius_of_cell_i - xij,2)*(2*radius_of_cell_i - xij)/3.0; 00121 } 00122 } 00123 00124 double V_A = 4.0/3.0*M_PI*pow(radius_of_cell_i,3) - delta_V_c; 00125 00131 double V_T = 5.0; 00132 00133 // Note: the sign in force_magnitude is different from the one in equation (A3) in the Buske paper 00134 rForces[node_index] += -mCompressionEnergyParameter/V_T*(V_T - V_A)*dVAdd_vector; 00135 } 00136 } 00137 00138 template<unsigned DIM> 00139 void BuskeCompressionForce<DIM>::OutputForceParameters(out_stream& rParamsFile) 00140 { 00141 *rParamsFile << "\t\t\t<CompressionEnergyParameter>" << mCompressionEnergyParameter << "</CompressionEnergyParameter>\n"; 00142 00143 // Call method on direct parent class 00144 AbstractForce<DIM>::OutputForceParameters(rParamsFile); 00145 } 00146 00148 // Explicit instantiation 00150 00151 template class BuskeCompressionForce<1>; 00152 template class BuskeCompressionForce<2>; 00153 template class BuskeCompressionForce<3>; 00154 00155 // Serialization for Boost >= 1.36 00156 #include "SerializationExportWrapperForCpp.hpp" 00157 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeCompressionForce)