36 #include "RepulsionForce.hpp"
39 template<
unsigned DIM>
45 template<
unsigned DIM>
51 EXCEPTION(
"RepulsionForce is to be used with a NodeBasedCellPopulation only");
56 for (
typename std::vector< std::pair<
Node<DIM>*,
Node<DIM>* > >::iterator iter = r_node_pairs.begin();
57 iter != r_node_pairs.end();
60 std::pair<Node<DIM>*,
Node<DIM>* > pair = *iter;
66 c_vector<double, DIM> node_a_location = p_node_a->
rGetLocation();
67 c_vector<double, DIM> node_b_location = p_node_b->
rGetLocation();
70 double node_a_radius = p_node_a->
GetRadius();
71 double node_b_radius = p_node_b->
GetRadius();
74 c_vector<double, DIM> unit_difference;
76 unit_difference = (
static_cast<NodeBasedCellPopulation<DIM>*
>(&rCellPopulation))->rGetMesh().GetVectorFromAtoB(node_a_location, node_b_location);
79 double rest_length = node_a_radius+node_b_radius;
81 if (norm_2(unit_difference) < rest_length)
84 c_vector<double, DIM> force = this->CalculateForceBetweenNodes(p_node_a->
GetIndex(), p_node_b->
GetIndex(), rCellPopulation);
85 c_vector<double, DIM> negative_force = -1.0 * force;
86 for (
unsigned j=0; j<DIM; j++)
88 assert(!std::isnan(force[j]));
97 template<
unsigned DIM>
void AddAppliedForceContribution(c_vector< double, SPACE_DIM > &forceContribution)
virtual void OutputForceParameters(out_stream &rParamsFile)
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
const c_vector< double, SPACE_DIM > & rGetLocation() const
virtual void OutputForceParameters(out_stream &rParamsFile)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
unsigned GetIndex() const