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 "AbstractTwoBodyInteractionForce.hpp"
00030
00031
00032 template<unsigned DIM>
00033 AbstractTwoBodyInteractionForce<DIM>::AbstractTwoBodyInteractionForce()
00034 : AbstractForce<DIM>(),
00035 mUseCutoffPoint(false)
00036 {
00037 }
00038
00039
00040 template<unsigned DIM>
00041 void AbstractTwoBodyInteractionForce<DIM>::UseCutoffPoint(double cutoffPoint)
00042 {
00043 assert(cutoffPoint > 0.0);
00044 mUseCutoffPoint = true;
00045 TissueConfig::Instance()->SetMechanicsCutOffLength(cutoffPoint);
00046 }
00047
00048
00049 template<unsigned DIM>
00050 double AbstractTwoBodyInteractionForce<DIM>::GetCutoffPoint()
00051 {
00052 return TissueConfig::Instance()->GetMechanicsCutOffLength();
00053 }
00054
00055
00056 template<unsigned DIM>
00057 void AbstractTwoBodyInteractionForce<DIM>::AddForceContribution(std::vector<c_vector<double, DIM> >& rForces,
00058 AbstractTissue<DIM>& rTissue)
00059 {
00060 if (rTissue.HasMesh())
00061 {
00062
00063 for (typename MeshBasedTissue<DIM>::SpringIterator spring_iterator=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsBegin();
00064 spring_iterator!=(static_cast<MeshBasedTissue<DIM>*>(&rTissue))->SpringsEnd();
00065 ++spring_iterator)
00066 {
00067 unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00068 unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00069
00070
00071 c_vector<double, DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rTissue);
00072
00073
00074 rForces[nodeB_global_index] -= force;
00075 rForces[nodeA_global_index] += force;
00076 }
00077 }
00078 else
00079 {
00080 std::set< std::pair<Node<DIM>*, Node<DIM>* > >& r_node_pairs = (static_cast<NodeBasedTissue<DIM>*>(&rTissue))->rGetNodePairs();
00081
00082 assert(DIM==2);
00083
00084 for (typename std::set< std::pair<Node<DIM>*, Node<DIM>* > >::iterator iter = r_node_pairs.begin();
00085 iter != r_node_pairs.end();
00086 iter++)
00087 {
00088 std::pair<Node<DIM>*, Node<DIM>* > pair = *iter;
00089
00090 unsigned node_a_index = pair.first->GetIndex();
00091 unsigned node_b_index = pair.second->GetIndex();
00092
00093
00094 c_vector<double, DIM> force = CalculateForceBetweenNodes(node_a_index, node_b_index, rTissue);
00095 for (unsigned j=0; j<DIM; j++)
00096 {
00097 assert(!std::isnan(force[j]));
00098 }
00099
00100
00101 rForces[node_a_index] += force;
00102 rForces[node_b_index] -= force;
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 }
00124 }
00125
00126
00127
00129
00131
00132 template class AbstractTwoBodyInteractionForce<1>;
00133 template class AbstractTwoBodyInteractionForce<2>;
00134 template class AbstractTwoBodyInteractionForce<3>;