BuskeAdhesiveForce.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 "BuskeAdhesiveForce.hpp"
00030
00031 template<unsigned DIM>
00032 BuskeAdhesiveForce<DIM>::BuskeAdhesiveForce()
00033 : AbstractTwoBodyInteractionForce<DIM>(),
00034 mAdhesionEnergyParameter(0.2)
00035 {
00036 }
00037
00038 template<unsigned DIM>
00039 double BuskeAdhesiveForce<DIM>::GetAdhesionEnergyParameter()
00040 {
00041 return mAdhesionEnergyParameter;
00042 }
00043
00044 template<unsigned DIM>
00045 void BuskeAdhesiveForce<DIM>::SetAdhesionEnergyParameter(double adhesionEnergyParameter)
00046 {
00047 mAdhesionEnergyParameter = adhesionEnergyParameter;
00048 }
00049
00050 template<unsigned DIM>
00051 c_vector<double, DIM> BuskeAdhesiveForce<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 BuskeAdhesiveForce<DIM>::GetMagnitudeOfForce(double distanceBetweenNodes, double radiusOfCellOne, double radiusOfCellTwo)
00100 {
00101 double dWAdd = 0.0;
00102
00103
00104 if (distanceBetweenNodes < radiusOfCellOne + radiusOfCellTwo)
00105 {
00106
00107 double xij = 0.5*(radiusOfCellOne*radiusOfCellOne - radiusOfCellTwo*radiusOfCellTwo + distanceBetweenNodes*distanceBetweenNodes)/distanceBetweenNodes;
00108 double dxijdd = 1.0 - xij/distanceBetweenNodes;
00109 dWAdd = 2.0*mAdhesionEnergyParameter*M_PI*xij*dxijdd;
00110 }
00111
00112 return dWAdd;
00113 }
00114
00115 template<unsigned DIM>
00116 void BuskeAdhesiveForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00117 {
00118 *rParamsFile << "\t\t\t<AdhesionEnergyParameter>" << mAdhesionEnergyParameter << "</AdhesionEnergyParameter>\n";
00119
00120
00121 AbstractTwoBodyInteractionForce<DIM>::OutputForceParameters(rParamsFile);
00122 }
00123
00125
00127
00128 template class BuskeAdhesiveForce<1>;
00129 template class BuskeAdhesiveForce<2>;
00130 template class BuskeAdhesiveForce<3>;
00131
00132
00133 #include "SerializationExportWrapperForCpp.hpp"
00134 EXPORT_TEMPLATE_CLASS_SAME_DIMS(BuskeAdhesiveForce)