BuskeCompressionForce.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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(AbstractCellPopulation<DIM>& rCellPopulation)
00060 {
00061
00062 assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL);
00063
00064 NodeBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation);
00065
00066
00067 c_vector<double, DIM> unit_vector;
00068
00069
00070 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
00071 cell_iter != rCellPopulation.End();
00072 ++cell_iter)
00073 {
00074
00075 unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
00076
00077 Node<DIM>* p_node_i = rCellPopulation.GetNode(node_index);
00078
00079
00080 c_vector<double, DIM> node_i_location = p_node_i->rGetLocation();
00081
00082
00083 double radius_of_cell_i = p_node_i->GetRadius();
00084
00085 double delta_V_c = 0.0;
00086 c_vector<double, DIM> dVAdd_vector = zero_vector<double>(DIM);
00087
00088
00089 std::set<unsigned> neighbouring_node_indices = p_static_cast_cell_population->GetNeighbouringNodeIndices(node_index);
00090
00091
00092 for (std::set<unsigned>::iterator iter = neighbouring_node_indices.begin();
00093 iter != neighbouring_node_indices.end();
00094 ++iter)
00095 {
00096 Node<DIM>* p_node_j = rCellPopulation.GetNode(*iter);
00097
00098
00099 c_vector<double, DIM> node_j_location = p_node_j->rGetLocation();
00100
00101
00102 unit_vector = node_j_location - node_i_location;
00103
00104
00105 double dij = norm_2(unit_vector);
00106
00107 unit_vector /= dij;
00108
00109
00110 double radius_of_cell_j = p_node_j->GetRadius();
00111
00112
00113 if (dij < radius_of_cell_i + radius_of_cell_j)
00114 {
00115
00116 double xij = 0.5*(radius_of_cell_i*radius_of_cell_i - radius_of_cell_j*radius_of_cell_j + dij*dij)/dij;
00117 double dxijdd = 1.0 - xij/dij;
00118 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;
00119
00120 dVAdd_vector += dVAdd*unit_vector;
00121
00122
00123 delta_V_c += M_PI*pow(radius_of_cell_i - xij,2.0)*(2*radius_of_cell_i - xij)/3.0;
00124 }
00125 }
00126
00127 double V_A = 4.0/3.0*M_PI*pow(radius_of_cell_i,3.0) - delta_V_c;
00128
00134 double V_T = 5.0;
00135
00136
00137 c_vector<double, DIM> applied_force = -mCompressionEnergyParameter/V_T*(V_T - V_A)*dVAdd_vector;
00138 p_node_i->AddAppliedForceContribution(applied_force);
00139 }
00140 }
00141
00142 template<unsigned DIM>
00143 void BuskeCompressionForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00144 {
00145 *rParamsFile << "\t\t\t<CompressionEnergyParameter>" << mCompressionEnergyParameter << "</CompressionEnergyParameter>\n";
00146
00147
00148 AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00149 }
00150
00152
00154
00155 template class BuskeCompressionForce<1>;
00156 template class BuskeCompressionForce<2>;
00157 template class BuskeCompressionForce<3>;
00158
00159
00160 #include "SerializationExportWrapperForCpp.hpp"
00161 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeCompressionForce)