36#include "ImmersedBoundaryLinearMembraneForce.hpp"
38template <
unsigned DIM>
41 mElementSpringConst(1e6),
42 mElementRestLength(0.5),
43 mLaminaSpringConst(1e6),
44 mLaminaRestLength(0.5)
48template <
unsigned DIM>
53template <
unsigned DIM>
66 CalculateForcesOnElement(*elem_it, rCellPopulation, intrinsic_spacing_squared);
74 CalculateForcesOnElement(*lam_it, rCellPopulation, intrinsic_spacing_squared);
77 if (this->mAdditiveNormalNoise)
79 this->AddNormalNoiseToNodes(rCellPopulation);
83template <
unsigned DIM>
84template <
unsigned ELEMENT_DIM>
88 double intrinsicSpacingSquared)
91 unsigned elem_idx = rElement.
GetIndex();
95 std::vector<c_vector<double, DIM> > elastic_force_to_next_node(num_nodes);
110 double node_spacing = 0.0;
111 double spring_constant = 0.0;
112 double rest_length = 0.0;
115 if (ELEMENT_DIM < DIM)
119 spring_constant = mLaminaSpringConst * intrinsicSpacingSquared / (node_spacing * node_spacing);
120 rest_length = mLaminaRestLength * node_spacing;
126 spring_constant = mElementSpringConst * intrinsicSpacingSquared / (node_spacing * node_spacing);
127 rest_length = mElementRestLength * node_spacing;
131 for (
unsigned node_idx = 0; node_idx < num_nodes; ++node_idx)
134 unsigned next_idx = (node_idx + 1) % num_nodes;
136 double modified_spring_constant = spring_constant;
137 double modified_rest_length = rest_length;
141 double normed_dist = norm_2(elastic_force_to_next_node[node_idx]);
142 elastic_force_to_next_node[node_idx] *= modified_spring_constant * (normed_dist - modified_rest_length) / normed_dist;
146 for (
unsigned node_idx = 0; node_idx < num_nodes; ++node_idx)
149 unsigned prev_idx = (node_idx + num_nodes - 1) % num_nodes;
151 c_vector<double, DIM> aggregate_force = elastic_force_to_next_node[node_idx] - elastic_force_to_next_node[prev_idx];
154 rElement.
GetNode(node_idx)->AddAppliedForceContribution(aggregate_force);
158template <
unsigned DIM>
160 out_stream& rParamsFile)
162 *rParamsFile <<
"\t\t\t<ElementSpringConstant>" << mElementSpringConst <<
"</ElementSpringConstant>\n";
163 *rParamsFile <<
"\t\t\t<ElementRestLength>" << mElementRestLength <<
"</ElementRestLength>\n";
164 *rParamsFile <<
"\t\t\t<LaminaSpringConstant>" << mLaminaSpringConst <<
"</LaminaSpringConstant>\n";
165 *rParamsFile <<
"\t\t\t<LaminaRestLength>" << mLaminaRestLength <<
"</LaminaRestLength>\n";
171template <
unsigned DIM>
174 return mElementSpringConst;
177template <
unsigned DIM>
179 double elementSpringConst)
181 mElementSpringConst = elementSpringConst;
184template <
unsigned DIM>
187 return mElementRestLength;
190template <
unsigned DIM>
192 double elementRestLength)
194 mElementRestLength = elementRestLength;
197template <
unsigned DIM>
200 return mLaminaSpringConst;
203template <
unsigned DIM>
205 double laminaSpringConst)
207 mLaminaSpringConst = laminaSpringConst;
210template <
unsigned DIM>
213 return mLaminaRestLength;
216template <
unsigned DIM>
218 double laminaRestLength)
220 mLaminaRestLength = laminaRestLength;
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
double GetNodeLocation(unsigned localIndex, unsigned dimension) const
unsigned GetNumNodes() const
unsigned GetIndex() const
virtual void OutputImmersedBoundaryForceParameters(out_stream &rParamsFile)=0
double GetIntrinsicSpacing() const
ImmersedBoundaryMesh< DIM, DIM > & rGetMesh()
void OutputImmersedBoundaryForceParameters(out_stream &rParamsFile)
double GetElementSpringConst() const
ImmersedBoundaryLinearMembraneForce()
void SetLaminaRestLength(double laminaRestLength)
double GetLaminaSpringConst() const
double GetElementRestLength() const
virtual ~ImmersedBoundaryLinearMembraneForce()
void CalculateForcesOnElement(ImmersedBoundaryElement< ELEMENT_DIM, DIM > &rElement, ImmersedBoundaryCellPopulation< DIM > &rCellPopulation, double intrinsicSpacingSquared)
void AddImmersedBoundaryForceContribution(std::vector< std::pair< Node< DIM > *, Node< DIM > * > > &rNodePairs, ImmersedBoundaryCellPopulation< DIM > &rCellPopulation)
void SetElementSpringConst(double elementSpringConst)
void SetLaminaSpringConst(double laminaSpringConst)
void SetElementRestLength(double elementRestLength)
double GetLaminaRestLength() const
ImmersedBoundaryElementIterator GetElementIteratorEnd()
ImmersedBoundaryLaminaIterator GetLaminaIteratorBegin(bool skipDeletedLaminas=true)
ImmersedBoundaryElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
ImmersedBoundaryLaminaIterator GetLaminaIteratorEnd()
double GetAverageNodeSpacingOfElement(unsigned index, bool recalculate=true)
double GetAverageNodeSpacingOfLamina(unsigned index, bool recalculate=true)
c_vector< double, SPACE_DIM > GetVectorFromAtoB(const c_vector< double, SPACE_DIM > &rLocation1, const c_vector< double, SPACE_DIM > &rLocation2)