BuskeElasticForce.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 "BuskeElasticForce.hpp"
00030
00031 template<unsigned DIM>
00032 BuskeElasticForce<DIM>::BuskeElasticForce()
00033 : AbstractTwoBodyInteractionForce<DIM>(),
00034 mDeformationEnergyParameter(4.0/(3.0*5.0))
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
00056 assert(dynamic_cast<NodeBasedCellPopulation<DIM>*>(&rCellPopulation) != NULL);
00057
00058
00059 assert(nodeAGlobalIndex != nodeBGlobalIndex);
00060
00061
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
00066 c_vector<double, DIM> unit_vector = node_b_location - node_a_location;
00067
00068
00069 double distance_between_nodes = norm_2(unit_vector);
00070
00071
00072 if (this->mUseCutOffLength)
00073 {
00074 if (distance_between_nodes >= this->GetCutOffLength())
00075 {
00076 return zero_vector<double>(DIM);
00077 }
00078 }
00079
00080
00081 assert(distance_between_nodes > 0);
00082 assert(!std::isnan(distance_between_nodes));
00083
00084
00085 unit_vector /= distance_between_nodes;
00086
00087
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
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
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
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
00124 AbstractTwoBodyInteractionForce<DIM>::OutputForceParameters(rParamsFile);
00125 }
00126
00128
00130
00131 template class BuskeElasticForce<1>;
00132 template class BuskeElasticForce<2>;
00133 template class BuskeElasticForce<3>;
00134
00135
00136 #include "SerializationExportWrapperForCpp.hpp"
00137 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeElasticForce)