50 EXCEPTION(
"RepulsionForce is to be used with a NodeBasedCellPopulation only");
54 for (
const auto& [p_node_a, p_node_b] : r_node_pairs)
57 const c_vector<double, DIM>& r_node_a_location = p_node_a->
rGetLocation();
58 const c_vector<double, DIM>& r_node_b_location = p_node_b->rGetLocation();
61 double node_a_radius = p_node_a->GetRadius();
62 double node_b_radius = p_node_b->GetRadius();
65 c_vector<double, DIM> unit_difference;
67 unit_difference = (
static_cast<NodeBasedCellPopulation<DIM>*
>(&rCellPopulation))->rGetMesh().GetVectorFromAtoB(r_node_a_location, r_node_b_location);
70 double rest_length = node_a_radius+node_b_radius;
72 if (norm_2(unit_difference) < rest_length)
75 c_vector<double, DIM> force = this->CalculateForceBetweenNodes(p_node_a->GetIndex(), p_node_b->GetIndex(), rCellPopulation);
76 c_vector<double, DIM> negative_force = -1.0 * force;
77 for (
unsigned j=0; j<DIM; j++)
79 assert(!std::isnan(force[j]));
82 p_node_a->AddAppliedForceContribution(force);
83 p_node_b->AddAppliedForceContribution(negative_force);