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 #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
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
00064 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = rCellPopulation.Begin();
00065 cell_iter != rCellPopulation.End();
00066 ++cell_iter)
00067 {
00068
00069 unsigned node_index = rCellPopulation.GetLocationIndexUsingCell(*cell_iter);
00070
00071
00072 c_vector<double, DIM> node_i_location = rCellPopulation.GetNode(node_index)->rGetLocation();
00073
00074
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
00081 std::set<unsigned> neighbouring_node_indices = p_static_cast_cell_population->GetNeighbouringNodeIndices(node_index);
00082
00083
00084 for (std::set<unsigned>::iterator iter = neighbouring_node_indices.begin();
00085 iter != neighbouring_node_indices.end();
00086 ++iter)
00087 {
00088
00089 c_vector<double, DIM> node_j_location = rCellPopulation.GetNode(*iter)->rGetLocation();
00090
00091
00092 unit_vector = node_j_location - node_i_location;
00093
00094
00095 double dij = norm_2(unit_vector);
00096
00097 unit_vector /= dij;
00098
00099
00100 double radius_of_cell_j = static_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation)->rGetMesh().GetCellRadius(*iter);
00101
00102
00103 if (dij < radius_of_cell_i + radius_of_cell_j)
00104 {
00105
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
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
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
00137 AbstractForce<DIM>::OutputForceParameters(rParamsFile);
00138 }
00139
00141
00143
00144 template class BuskeCompressionForce<1>;
00145 template class BuskeCompressionForce<2>;
00146 template class BuskeCompressionForce<3>;
00147
00148
00149 #include "SerializationExportWrapperForCpp.hpp"
00150 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeCompressionForce)