36 #include "AbstractTwoBodyInteractionForce.hpp"
39 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
42 mUseCutOffLength(false),
43 mMechanicsCutOffLength(DBL_MAX)
47 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
50 return mUseCutOffLength;
53 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
56 assert(cutOffLength > 0.0);
57 mUseCutOffLength =
true;
58 mMechanicsCutOffLength = cutOffLength;
61 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
64 return mMechanicsCutOffLength;
67 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
73 EXCEPTION(
"Subclasses of AbstractTwoBodyInteractionForce are to be used with subclasses of AbstractCentreBasedCellPopulation only");
83 spring_iterator != p_static_cast_cell_population->
SpringsEnd();
86 unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
87 unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
90 c_vector<double, SPACE_DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rCellPopulation);
93 c_vector<double, SPACE_DIM> negative_force = -1.0*force;
94 spring_iterator.GetNodeB()->AddAppliedForceContribution(negative_force);
95 spring_iterator.GetNodeA()->AddAppliedForceContribution(force);
105 iter != r_node_pairs.end();
110 unsigned node_a_index = pair.first->
GetIndex();
111 unsigned node_b_index = pair.second->GetIndex();
114 c_vector<double, SPACE_DIM> force = CalculateForceBetweenNodes(node_a_index, node_b_index, rCellPopulation);
115 for (
unsigned j=0; j<SPACE_DIM; j++)
117 assert(!std::isnan(force[j]));
121 c_vector<double, SPACE_DIM> negative_force = -1.0*force;
122 pair.first->AddAppliedForceContribution(force);
123 pair.second->AddAppliedForceContribution(negative_force);
128 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
131 *rParamsFile <<
"\t\t\t<UseCutOffLength>" << mUseCutOffLength <<
"</UseCutOffLength>\n";
132 *rParamsFile <<
"\t\t\t<CutOffLength>" << mMechanicsCutOffLength <<
"</CutOffLength>\n";
virtual void OutputForceParameters(out_stream &rParamsFile)
SpringIterator SpringsEnd()
SpringIterator SpringsBegin()
void SetCutOffLength(double cutOffLength)
bool GetUseCutOffLength()
AbstractTwoBodyInteractionForce()
#define EXCEPTION(message)
void AddForceContribution(AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation)
virtual std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > & rGetNodePairs()=0
unsigned GetIndex() const
virtual void OutputForceParameters(out_stream &rParamsFile)=0